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

Commit 89611c4

Browse files
committed
Various fixes to "ALTER ... SET/RESET" tab completions
Add - ALTER SYSTEM SET/RESET ... -> GUC variables - ALTER TABLE ... SET WITH -> OIDS - ALTER DATABASE/FUNCTION/ROLE/USER ... SET/RESET -> GUC variables - ALTER DATABASE/FUNCTION/ROLE/USER ... SET ... -> FROM CURRENT/TO - ALTER DATABASE/FUNCTION/ROLE/USER ... SET ... TO/= -> possible values Author: Fujii Masao Reviewed-by: Michael Paquier, Masahiko Sawada
1 parent 7a58d19 commit 89611c4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/bin/psql/tab-complete.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ psql_completion(const char *text, int start, int end)
15531553
else if (Matches2("ALTER", "SYSTEM"))
15541554
COMPLETE_WITH_LIST2("SET", "RESET");
15551555
/* ALTER SYSTEM SET|RESET <name> */
1556-
else if (Matches4("ALTER", "SYSTEM", "SET|RESET", MatchAny))
1556+
else if (Matches3("ALTER", "SYSTEM", "SET|RESET"))
15571557
COMPLETE_WITH_QUERY(Query_for_list_of_alter_system_set_vars);
15581558
/* ALTER VIEW <name> */
15591559
else if (Matches3("ALTER", "VIEW", MatchAny))
@@ -1754,6 +1754,9 @@ psql_completion(const char *text, int start, int end)
17541754
*/
17551755
else if (Matches5("ALTER", "TABLE", MatchAny, "SET", "TABLESPACE"))
17561756
COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
1757+
/* If we have ALTER TABLE <sth> SET WITH provide OIDS */
1758+
else if (Matches5("ALTER", "TABLE", MatchAny, "SET", "WITH"))
1759+
COMPLETE_WITH_CONST("OIDS");
17571760
/* If we have ALTER TABLE <sth> SET WITHOUT provide CLUSTER or OIDS */
17581761
else if (Matches5("ALTER", "TABLE", MatchAny, "SET", "WITHOUT"))
17591762
COMPLETE_WITH_LIST2("CLUSTER", "OIDS");
@@ -2702,7 +2705,7 @@ psql_completion(const char *text, int start, int end)
27022705

27032706
/* SET, RESET, SHOW */
27042707
/* Complete with a variable name */
2705-
else if (Matches1("SET|RESET"))
2708+
else if (TailMatches1("SET|RESET") && !TailMatches3("UPDATE", MatchAny, "SET"))
27062709
COMPLETE_WITH_QUERY(Query_for_list_of_set_vars);
27072710
else if (Matches1("SHOW"))
27082711
COMPLETE_WITH_QUERY(Query_for_list_of_show_vars);
@@ -2743,8 +2746,12 @@ psql_completion(const char *text, int start, int end)
27432746
/* Complete SET <var> with "TO" */
27442747
else if (Matches2("SET", MatchAny))
27452748
COMPLETE_WITH_CONST("TO");
2749+
/* Complete ALTER DATABASE|FUNCTION|ROLE|USER ... SET <name> */
2750+
else if (HeadMatches2("ALTER", "DATABASE|FUNCTION|ROLE|USER") &&
2751+
TailMatches2("SET", MatchAny))
2752+
COMPLETE_WITH_LIST2("FROM CURRENT", "TO");
27462753
/* Suggest possible variable values */
2747-
else if (Matches3("SET", MatchAny, "TO|="))
2754+
else if (TailMatches3("SET", MatchAny, "TO|="))
27482755
{
27492756
/* special cased code for individual GUCs */
27502757
if (TailMatches2("DateStyle", "TO|="))

0 commit comments

Comments
 (0)