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

Lines changed: 10 additions & 3 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy