Skip to content

Commit 1455d34

Browse files
michaelpqpull[bot]
authored andcommitted
Add support for GRANT SET in psql tab completion
3d14e17 has added support for this query but psql was not able to complete it. Spotted while working on a different patch in the same area. Reviewed-by: Robert Haas Discussion: https://postgr.es/m/Y3hw7yvG0VwpC1jq@paquier.xyz
1 parent 98f297e commit 1455d34

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/bin/psql/tab-complete.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3773,7 +3773,7 @@ psql_completion(const char *text, int start, int end)
37733773
*/
37743774
/* Complete GRANT/REVOKE with a list of roles and privileges */
37753775
else if (TailMatches("GRANT|REVOKE") ||
3776-
TailMatches("REVOKE", "ADMIN|GRANT|INHERIT", "OPTION", "FOR"))
3776+
TailMatches("REVOKE", "ADMIN|GRANT|INHERIT|SET", "OPTION", "FOR"))
37773777
{
37783778
/*
37793779
* With ALTER DEFAULT PRIVILEGES, restrict completion to grantable
@@ -3792,18 +3792,21 @@ psql_completion(const char *text, int start, int end)
37923792
Privilege_options_of_grant_and_revoke,
37933793
"GRANT OPTION FOR",
37943794
"ADMIN OPTION FOR",
3795-
"INHERIT OPTION FOR");
3795+
"INHERIT OPTION FOR",
3796+
"SET OPTION FOR");
37963797
else if (TailMatches("REVOKE", "GRANT", "OPTION", "FOR"))
37973798
COMPLETE_WITH(Privilege_options_of_grant_and_revoke);
3798-
else if (TailMatches("REVOKE", "ADMIN|INHERIT", "OPTION", "FOR"))
3799+
else if (TailMatches("REVOKE", "ADMIN|INHERIT|SET", "OPTION", "FOR"))
37993800
COMPLETE_WITH_QUERY(Query_for_list_of_roles);
38003801
}
38013802

38023803
else if (TailMatches("GRANT|REVOKE", "ALTER") ||
38033804
TailMatches("REVOKE", "GRANT", "OPTION", "FOR", "ALTER"))
38043805
COMPLETE_WITH("SYSTEM");
38053806

3806-
else if (TailMatches("GRANT|REVOKE", "SET") ||
3807+
else if (TailMatches("REVOKE", "SET"))
3808+
COMPLETE_WITH("ON PARAMETER", "OPTION FOR");
3809+
else if (TailMatches("GRANT", "SET") ||
38073810
TailMatches("REVOKE", "GRANT", "OPTION", "FOR", "SET") ||
38083811
TailMatches("GRANT|REVOKE", "ALTER", "SYSTEM") ||
38093812
TailMatches("REVOKE", "GRANT", "OPTION", "FOR", "ALTER", "SYSTEM"))
@@ -3942,14 +3945,16 @@ psql_completion(const char *text, int start, int end)
39423945
else if (HeadMatches("GRANT") && TailMatches("TO", MatchAny))
39433946
COMPLETE_WITH("WITH ADMIN",
39443947
"WITH INHERIT",
3948+
"WITH SET",
39453949
"WITH GRANT OPTION",
39463950
"GRANTED BY");
39473951
else if (HeadMatches("GRANT") && TailMatches("TO", MatchAny, "WITH"))
39483952
COMPLETE_WITH("ADMIN",
39493953
"INHERIT",
3954+
"SET",
39503955
"GRANT OPTION");
39513956
else if (HeadMatches("GRANT") &&
3952-
(TailMatches("TO", MatchAny, "WITH", "ADMIN|INHERIT")))
3957+
(TailMatches("TO", MatchAny, "WITH", "ADMIN|INHERIT|SET")))
39533958
COMPLETE_WITH("OPTION", "TRUE", "FALSE");
39543959
else if (HeadMatches("GRANT") && TailMatches("TO", MatchAny, "WITH", MatchAny, "OPTION"))
39553960
COMPLETE_WITH("GRANTED BY");

0 commit comments

Comments
 (0)