diff options
author | Michael Paquier <michael@paquier.xyz> | 2022-12-12 16:47:24 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2022-12-12 16:47:24 +0900 |
commit | 9d0cf574920f1d5e6c260815d242b6691d37d5dc (patch) | |
tree | d36d6241bcb2860601816417074cd793f3e1089d | |
parent | eae7fe485998ac493a3d9dadf254a89c9265891e (diff) | |
download | postgresql-9d0cf574920f1d5e6c260815d242b6691d37d5dc.tar.gz postgresql-9d0cf574920f1d5e6c260815d242b6691d37d5dc.zip |
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
-rw-r--r-- | src/bin/psql/tab-complete.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 7d222680f53..dd7d0216197 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3773,7 +3773,7 @@ psql_completion(const char *text, int start, int end) */ /* Complete GRANT/REVOKE with a list of roles and privileges */ else if (TailMatches("GRANT|REVOKE") || - TailMatches("REVOKE", "ADMIN|GRANT|INHERIT", "OPTION", "FOR")) + TailMatches("REVOKE", "ADMIN|GRANT|INHERIT|SET", "OPTION", "FOR")) { /* * With ALTER DEFAULT PRIVILEGES, restrict completion to grantable @@ -3792,10 +3792,11 @@ psql_completion(const char *text, int start, int end) Privilege_options_of_grant_and_revoke, "GRANT OPTION FOR", "ADMIN OPTION FOR", - "INHERIT OPTION FOR"); + "INHERIT OPTION FOR", + "SET OPTION FOR"); else if (TailMatches("REVOKE", "GRANT", "OPTION", "FOR")) COMPLETE_WITH(Privilege_options_of_grant_and_revoke); - else if (TailMatches("REVOKE", "ADMIN|INHERIT", "OPTION", "FOR")) + else if (TailMatches("REVOKE", "ADMIN|INHERIT|SET", "OPTION", "FOR")) COMPLETE_WITH_QUERY(Query_for_list_of_roles); } @@ -3803,7 +3804,9 @@ psql_completion(const char *text, int start, int end) TailMatches("REVOKE", "GRANT", "OPTION", "FOR", "ALTER")) COMPLETE_WITH("SYSTEM"); - else if (TailMatches("GRANT|REVOKE", "SET") || + else if (TailMatches("REVOKE", "SET")) + COMPLETE_WITH("ON PARAMETER", "OPTION FOR"); + else if (TailMatches("GRANT", "SET") || TailMatches("REVOKE", "GRANT", "OPTION", "FOR", "SET") || TailMatches("GRANT|REVOKE", "ALTER", "SYSTEM") || TailMatches("REVOKE", "GRANT", "OPTION", "FOR", "ALTER", "SYSTEM")) @@ -3942,14 +3945,16 @@ psql_completion(const char *text, int start, int end) else if (HeadMatches("GRANT") && TailMatches("TO", MatchAny)) COMPLETE_WITH("WITH ADMIN", "WITH INHERIT", + "WITH SET", "WITH GRANT OPTION", "GRANTED BY"); else if (HeadMatches("GRANT") && TailMatches("TO", MatchAny, "WITH")) COMPLETE_WITH("ADMIN", "INHERIT", + "SET", "GRANT OPTION"); else if (HeadMatches("GRANT") && - (TailMatches("TO", MatchAny, "WITH", "ADMIN|INHERIT"))) + (TailMatches("TO", MatchAny, "WITH", "ADMIN|INHERIT|SET"))) COMPLETE_WITH("OPTION", "TRUE", "FALSE"); else if (HeadMatches("GRANT") && TailMatches("TO", MatchAny, "WITH", MatchAny, "OPTION")) COMPLETE_WITH("GRANTED BY"); |