git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fc069a3)
Add tab completion for ALTER DATABASE RESET
2025年2月17日 16:49:53 +0000 (17:49 +0100)
2025年2月17日 17:12:15 +0000 (18:12 +0100)
Currently tab completion for ALTER DATABASE RESET shows a list of all
configuration parameters that may be set on a database, irrespectively
of which parameters are actually set. This patch improves tab completion
to offer only parameters that are set.

Author: Robins Tharakan
Reviewed-By: Tomas Vondra
Discussion: https://postgr.es/m/CAEP4nAzqiT6VbVC5r3nq5byLTnPzjniVGzEMpYcnAHQyNzEuaw%40mail.gmail.com


diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index a9a81ab3c1465acb2c0029f5e1a792767a78fb03..18fecd3280719fba874c92b660d93795b11055ac 100644 (file)
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -1000,6 +1000,15 @@ static const SchemaQuery Query_for_trigger_of_table = {
"SELECT datname FROM pg_catalog.pg_database "\
" WHERE datname LIKE '%s'"
+#define Query_for_list_of_database_vars \
+"SELECT conf FROM ("\
+" SELECT setdatabase, pg_catalog.split_part(unnest(setconfig),'=',1) conf"\
+" FROM pg_db_role_setting "\
+" ) s, pg_database d "\
+" WHERE s.setdatabase = d.oid "\
+" AND conf LIKE '%s'"\
+" AND d.datname LIKE '%s'"
+
#define Query_for_list_of_tablespaces \
"SELECT spcname FROM pg_catalog.pg_tablespace "\
" WHERE spcname LIKE '%s'"
@@ -2320,6 +2329,13 @@ match_previous_words(int pattern_id,
"IS_TEMPLATE", "ALLOW_CONNECTIONS",
"CONNECTION LIMIT");
+ /* ALTER DATABASE <name> RESET */
+ else if (Matches("ALTER", "DATABASE", MatchAny, "RESET"))
+ {
+ set_completion_reference(prev2_wd);
+ COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_database_vars, "ALL");
+ }
+
/* ALTER DATABASE <name> SET TABLESPACE */
else if (Matches("ALTER", "DATABASE", MatchAny, "SET", "TABLESPACE"))
COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
@@ -4906,7 +4922,9 @@ match_previous_words(int pattern_id,
/* SET, RESET, SHOW */
/* Complete with a variable name */
- else if (TailMatches("SET|RESET") && !TailMatches("UPDATE", MatchAny, "SET"))
+ else if (TailMatches("SET|RESET") &&
+ !TailMatches("UPDATE", MatchAny, "SET") &&
+ !TailMatches("ALTER", "DATABASE", MatchAny, "RESET"))
COMPLETE_WITH_QUERY_VERBATIM_PLUS(Query_for_list_of_set_vars,
"CONSTRAINTS",
"TRANSACTION",
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /