mirror of
https://github.com/postgres/postgres.git
synced 2025-05-17 06:41:24 +03:00
Add more tab completion support for ALTER DEFAULT PRIVILEGES in psql.
This adds tab completion of "GRANT" and "REVOKE [GRANT OPTION FOR]" for ALTER DEFAULT PRIVILEGES, and adds "WITH GRANT OPTION" for ALTER DEFAULT PRIVILEGES ... GRANT ... TO role. Author: Vignesh C, with cosmetic adjustments by me Reviewed-by: Shubham Khanna, Masahiko Sawada Discussion: https://postgr.es/m/CALDaNm1aEdJb-QJi%3DGWStkfj_%2BEDUK_VtDkn%2BTjQ2z7HyU0MBw%40mail.gmail.com
This commit is contained in:
parent
3b08133cd1
commit
304b6b1a6b
@ -2147,7 +2147,7 @@ psql_completion(const char *text, int start, int end)
|
||||
|
||||
/* ALTER DEFAULT PRIVILEGES */
|
||||
else if (Matches("ALTER", "DEFAULT", "PRIVILEGES"))
|
||||
COMPLETE_WITH("FOR ROLE", "IN SCHEMA");
|
||||
COMPLETE_WITH("FOR", "GRANT", "IN SCHEMA", "REVOKE");
|
||||
/* ALTER DEFAULT PRIVILEGES FOR */
|
||||
else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "FOR"))
|
||||
COMPLETE_WITH("ROLE");
|
||||
@ -3949,9 +3949,18 @@ psql_completion(const char *text, int start, int end)
|
||||
* privileges (can't grant roles)
|
||||
*/
|
||||
if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES"))
|
||||
COMPLETE_WITH("SELECT", "INSERT", "UPDATE",
|
||||
"DELETE", "TRUNCATE", "REFERENCES", "TRIGGER",
|
||||
"CREATE", "EXECUTE", "USAGE", "MAINTAIN", "ALL");
|
||||
{
|
||||
if (TailMatches("GRANT") ||
|
||||
TailMatches("REVOKE", "GRANT", "OPTION", "FOR"))
|
||||
COMPLETE_WITH("SELECT", "INSERT", "UPDATE",
|
||||
"DELETE", "TRUNCATE", "REFERENCES", "TRIGGER",
|
||||
"CREATE", "EXECUTE", "USAGE", "MAINTAIN", "ALL");
|
||||
else if (TailMatches("REVOKE"))
|
||||
COMPLETE_WITH("SELECT", "INSERT", "UPDATE",
|
||||
"DELETE", "TRUNCATE", "REFERENCES", "TRIGGER",
|
||||
"CREATE", "EXECUTE", "USAGE", "MAINTAIN", "ALL",
|
||||
"GRANT OPTION FOR");
|
||||
}
|
||||
else if (TailMatches("GRANT"))
|
||||
COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_roles,
|
||||
Privilege_options_of_grant_and_revoke);
|
||||
@ -4133,6 +4142,9 @@ psql_completion(const char *text, int start, int end)
|
||||
else if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES") && TailMatches("TO|FROM"))
|
||||
COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_roles,
|
||||
Keywords_for_list_of_grant_roles);
|
||||
/* Offer WITH GRANT OPTION after that */
|
||||
else if (HeadMatches("ALTER", "DEFAULT", "PRIVILEGES") && TailMatches("TO", MatchAny))
|
||||
COMPLETE_WITH("WITH GRANT OPTION");
|
||||
/* Complete "GRANT/REVOKE ... ON * *" with TO/FROM */
|
||||
else if (HeadMatches("GRANT") && TailMatches("ON", MatchAny, MatchAny))
|
||||
COMPLETE_WITH("TO");
|
||||
|
Loading…
x
Reference in New Issue
Block a user