Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit acd18ed

Browse files
author
Commitfest Bot
committed
[CF 52/5414] v1 - Tab completion for ALTER USER RESET
This commit was automatically generated by a robot at cfbot.cputube.org. It is based on patches submitted to the PostgreSQL mailing lists and registered in the PostgreSQL Commitfest application. This branch will be overwritten each time a new patch version is posted to the email thread, and also periodically to check for bitrot caused by changes on the master branch. Commitfest entry: https://commitfest.postgresql.org/52/5414 Patch(es): https://www.postgresql.org/message-id/CAEP4nAx2xeR+GiCaOZhEcMdq_5J6yUDd5u5FYGHkfs9ULKd0eA@mail.gmail.com Author(s):
2 parents 75dfde1 + 6fe0403 commit acd18ed

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/bin/psql/tab-complete.in.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,15 @@ static const SchemaQuery Query_for_trigger_of_table = {
10001000
"SELECT datname FROM pg_catalog.pg_database "\
10011001
" WHERE datname LIKE '%s'"
10021002

1003+
#define Query_for_list_of_database_vars \
1004+
"SELECT conf FROM ("\
1005+
" SELECT setdatabase, pg_catalog.split_part(unnest(setconfig),'=',1) conf"\
1006+
" FROM pg_db_role_setting "\
1007+
" ) s, pg_database d "\
1008+
" WHERE s.setdatabase = d.oid "\
1009+
" AND conf LIKE '%s'"\
1010+
" AND d.datname LIKE '%s'"
1011+
10031012
#define Query_for_list_of_tablespaces \
10041013
"SELECT spcname FROM pg_catalog.pg_tablespace "\
10051014
" WHERE spcname LIKE '%s'"
@@ -1068,6 +1077,11 @@ Keywords_for_list_of_owner_roles, "PUBLIC"
10681077
" FROM pg_catalog.pg_user_mappings "\
10691078
" WHERE usename LIKE '%s'"
10701079

1080+
#define Query_for_list_of_user_vars \
1081+
" SELECT pg_catalog.split_part(pg_catalog.unnest(rolconfig),'=',1) "\
1082+
" FROM pg_catalog.pg_roles "\
1083+
" WHERE rolname LIKE '%s'"
1084+
10711085
#define Query_for_list_of_access_methods \
10721086
" SELECT amname "\
10731087
" FROM pg_catalog.pg_am "\
@@ -2320,6 +2334,13 @@ match_previous_words(int pattern_id,
23202334
"IS_TEMPLATE", "ALLOW_CONNECTIONS",
23212335
"CONNECTION LIMIT");
23222336

2337+
/* ALTER DATABASE <name> RESET */
2338+
else if (Matches("ALTER", "DATABASE", MatchAny, "RESET"))
2339+
{
2340+
set_completion_reference(prev2_wd);
2341+
COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_database_vars, "ALL");
2342+
}
2343+
23232344
/* ALTER DATABASE <name> SET TABLESPACE */
23242345
else if (Matches("ALTER", "DATABASE", MatchAny, "SET", "TABLESPACE"))
23252346
COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
@@ -2471,6 +2492,10 @@ match_previous_words(int pattern_id,
24712492
"RENAME TO", "REPLICATION", "RESET", "SET", "SUPERUSER",
24722493
"VALID UNTIL", "WITH");
24732494

2495+
/* ALTER USER,ROLE <name> RESET */
2496+
else if (Matches("ALTER", "USER|ROLE", MatchAny, "RESET"))
2497+
COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_user_vars, "ALL");
2498+
24742499
/* ALTER USER,ROLE <name> WITH */
24752500
else if (Matches("ALTER", "USER|ROLE", MatchAny, "WITH"))
24762501
/* Similar to the above, but don't complete "WITH" again. */
@@ -4906,7 +4931,9 @@ match_previous_words(int pattern_id,
49064931

49074932
/* SET, RESET, SHOW */
49084933
/* Complete with a variable name */
4909-
else if (TailMatches("SET|RESET") && !TailMatches("UPDATE", MatchAny, "SET"))
4934+
else if (TailMatches("SET|RESET") &&
4935+
!TailMatches("UPDATE", MatchAny, "SET") &&
4936+
!TailMatches("ALTER", "DATABASE", MatchAny, "RESET"))
49104937
COMPLETE_WITH_QUERY_VERBATIM_PLUS(Query_for_list_of_set_vars,
49114938
"CONSTRAINTS",
49124939
"TRANSACTION",

0 commit comments

Comments
 (0)