Hi,

I found that the following tab-completions for SET/RESET which
worked properly before doesn't work properly now in the master.

1. ALTER SYSTEM SET|RESET <tab> lists nothing.
2. ALTER DATABASE xxx SET <tab> lists nothing.
3. ALTER DATABASE xxx SET yyy <tab> lists nothing.
4. ALTER DATABASE xxx SET datestyle TO <tab> lists nothing.

Attached patch fixes those problems.

Regards,

-- 
Fujii Masao
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
***************
*** 1553,1559 **** psql_completion(const char *text, int start, int end)
  	else if (Matches2("ALTER", "SYSTEM"))
  		COMPLETE_WITH_LIST2("SET", "RESET");
  	/* ALTER SYSTEM SET|RESET <name> */
! 	else if (Matches4("ALTER", "SYSTEM", "SET|RESET", MatchAny))
  		COMPLETE_WITH_QUERY(Query_for_list_of_alter_system_set_vars);
  	/* ALTER VIEW <name> */
  	else if (Matches3("ALTER", "VIEW", MatchAny))
--- 1553,1559 ----
  	else if (Matches2("ALTER", "SYSTEM"))
  		COMPLETE_WITH_LIST2("SET", "RESET");
  	/* ALTER SYSTEM SET|RESET <name> */
! 	else if (Matches3("ALTER", "SYSTEM", "SET|RESET"))
  		COMPLETE_WITH_QUERY(Query_for_list_of_alter_system_set_vars);
  	/* ALTER VIEW <name> */
  	else if (Matches3("ALTER", "VIEW", MatchAny))
***************
*** 2702,2708 **** psql_completion(const char *text, int start, int end)
  
  /* SET, RESET, SHOW */
  	/* Complete with a variable name */
! 	else if (Matches1("SET|RESET"))
  		COMPLETE_WITH_QUERY(Query_for_list_of_set_vars);
  	else if (Matches1("SHOW"))
  		COMPLETE_WITH_QUERY(Query_for_list_of_show_vars);
--- 2702,2708 ----
  
  /* SET, RESET, SHOW */
  	/* Complete with a variable name */
! 	else if (TailMatches1("SET|RESET") && !TailMatches3("UPDATE", MatchAny, "SET"))
  		COMPLETE_WITH_QUERY(Query_for_list_of_set_vars);
  	else if (Matches1("SHOW"))
  		COMPLETE_WITH_QUERY(Query_for_list_of_show_vars);
***************
*** 2741,2750 **** psql_completion(const char *text, int start, int end)
  	else if (Matches2("RESET", "SESSION"))
  		COMPLETE_WITH_CONST("AUTHORIZATION");
  	/* Complete SET <var> with "TO" */
! 	else if (Matches2("SET", MatchAny))
  		COMPLETE_WITH_CONST("TO");
  	/* Suggest possible variable values */
! 	else if (Matches3("SET", MatchAny, "TO|="))
  	{
  		/* special cased code for individual GUCs */
  		if (TailMatches2("DateStyle", "TO|="))
--- 2741,2754 ----
  	else if (Matches2("RESET", "SESSION"))
  		COMPLETE_WITH_CONST("AUTHORIZATION");
  	/* Complete SET <var> with "TO" */
! 	else if (TailMatches2("SET", MatchAny) &&
! 			 !TailMatches4("UPDATE|DOMAIN", MatchAny, MatchAny, MatchAny) &&
! 			 !TailMatches1("TABLESPACE|SCHEMA") &&
! 			 !ends_with(prev_wd, ')') &&
! 			 !ends_with(prev_wd, '='))
  		COMPLETE_WITH_CONST("TO");
  	/* Suggest possible variable values */
! 	else if (TailMatches3("SET", MatchAny, "TO|="))
  	{
  		/* special cased code for individual GUCs */
  		if (TailMatches2("DateStyle", "TO|="))
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to