> On Nov 20, 2026, at 16:57, Neil Chen <[email protected]> wrote:
> 
> Hi hackers,
> 
> While trying REVOKE ... GRANTED BY in PostgreSQL 19, I noticed that
> psql doesn't complete the clause or the grantor's name.
> 
> I tried the corresponding GRANT and found that pressing Tab after
> a trailing space on this line inserts TO, making the statement invalid.
> 
> GRANT SELECT ON t TO r WITH GRANT OPTION
> 
> Before the patch, the generic GRANT rule treats the trailing GRANT
> OPTION as GRANT followed by a role name. The patch matches WITH
> GRANT OPTION first, so Tab inserts GRANTED BY. It also completes
> the clause and grantor name in both commands.
> 

Hi Neil,

Thanks for the patch. I reviewed and tested this patch, and I have a few 
comments.

1
```
evantest=# revoke select ON all functions in schema public FROM chaol GRANTED 
BY chaol

```

After “GRANTED BY x”, [ CASCADE | RESTRICT ] can be specified, so we should 
support them as well.

2
```
+       /* GRANTED can itself be a role name, including after GROUP or a comma. 
*/
+       else if (Matches("GRANT", MatchAnyN, "TO", MatchAnyExcept("GROUP"), 
"GRANTED") ||
+                        Matches("REVOKE", MatchAnyN, "FROM", 
MatchAnyExcept("GROUP"), "GRANTED") ||
+                        Matches("GRANT", MatchAnyN, "TO", MatchAny, "WITH",
+                                        "GRANT", "OPTION", "GRANTED") ||
+                        Matches("GRANT", MatchAnyN, "TO", MatchAny, "WITH",
+                                        "ADMIN|INHERIT|SET", 
"OPTION|TRUE|FALSE", "GRANTED"))
+       {
+               if (!ends_with(prev2_wd, ','))
+                       COMPLETE_WITH("BY");
+       }
```

Is the check of comma really needed? At least for the latter 2 matches, 
prev2_wd would be OPTION|TRUE|FALSE, impossible to be comma.

In the immediate next branch, the check on prev3_wd has a similar problem.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/






Reply via email to