aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2021-04-21 10:34:43 +0900
committerMichael Paquier <michael@paquier.xyz>2021-04-21 10:34:43 +0900
commit22b2dec31b2ef4dfee299290b16375e9fa6e6932 (patch)
tree035790e4c0fd62798abebbba2c4d7c1ab3689bf1
parent783be78ca91166ac7f80c953f2bbc5af1f61c6cd (diff)
downloadpostgresql-22b2dec31b2ef4dfee299290b16375e9fa6e6932.tar.gz
postgresql-22b2dec31b2ef4dfee299290b16375e9fa6e6932.zip
Add CURRENT_ROLE to list of roles for tab completion of GRANT in psql
This compatibility has been added in 45b9805, but psql forgot the call. Author: Wei Wang Reviewed-by: Aleksander Alekseev Discussion: https://postgr.es/m/OS3PR01MB6275935F62E161BCD393D6559E489@OS3PR01MB6275.jpnprd01.prod.outlook.com
-rw-r--r--src/bin/psql/tab-complete.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index cfd0a840c7c..ed84b3789c6 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -764,6 +764,7 @@ static const SchemaQuery Query_for_list_of_collations = {
" FROM pg_catalog.pg_roles "\
" WHERE substring(pg_catalog.quote_ident(rolname),1,%d)='%s'"\
" UNION ALL SELECT 'PUBLIC'"\
+" UNION ALL SELECT 'CURRENT_ROLE'"\
" UNION ALL SELECT 'CURRENT_USER'"\
" UNION ALL SELECT 'SESSION_USER'"
@@ -3450,7 +3451,7 @@ psql_completion(const char *text, int start, int end)
/*
* Complete "GRANT/REVOKE ... TO/FROM" with username, PUBLIC,
- * CURRENT_USER, or SESSION_USER.
+ * CURRENT_ROLE, CURRENT_USER, or SESSION_USER.
*/
else if ((HeadMatches("GRANT") && TailMatches("TO")) ||
(HeadMatches("REVOKE") && TailMatches("FROM")))
@@ -3884,6 +3885,7 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH("FOR");
else if (Matches("CREATE", "USER", "MAPPING", "FOR"))
COMPLETE_WITH_QUERY(Query_for_list_of_roles
+ " UNION SELECT 'CURRENT_ROLE'"
" UNION SELECT 'CURRENT_USER'"
" UNION SELECT 'PUBLIC'"
" UNION SELECT 'USER'");