Re: Improve tab completion for various SET/RESET forms - Mailing list pgsql-hackers
From | Shinya Kato |
---|---|
Subject | Re: Improve tab completion for various SET/RESET forms |
Date | |
Msg-id | CAOzEurTXFei36Jo7UwPLc31JHFgX+Xo-c3svc2VGQsOJj2dOCg@mail.gmail.com Whole thread Raw |
In response to | Re: Improve tab completion for various SET/RESET forms (Shinya Kato <shinya11.kato@gmail.com>) |
Responses |
Re: Improve tab completion for various SET/RESET forms
|
List | pgsql-hackers |
On Wed, Aug 13, 2025 at 5:52 PM Shinya Kato <shinya11.kato@gmail.com> wrote: > > > I also noticed that ALTER SYSTEM RESET tab completes with all variables, > > > not just ones that have been set with ALTER SYSTEM. Getting this right > > > is a bit more complicated, since the only way to distinguish them is > > > pg_settings.sourcefile = '$PGDATA/postgresql.auto.conf', but Windows > > > uses \ for the directory separator, so we'd have to use a regex. But > > > there's no function for escaping a string to use as a literal match in a > > > regex (like Perl's quotemeta()), so we have to use LIKE instead, > > > manually escaping %, _ and \, and accepting any character as the > > > directory separator. If people think this over-complicated, we could > > > just check sourcefile ~ '[\\/]postgresql\.auto\.conf$', and accept false > > > positives if somone has used an include directive with a file with the > > > same name in a different directory. > > > > > > Another complication is that both current_setting('data_directory') and > > > pg_settings.sourcefile are only available to superusers, so I added > > > another version for non-superusers that completes variables they've been > > > granted ALTER SYSTEM on, by querying pg_parameter_acl. > > > > I failed to apply these patches. > > ---- > > $ git apply v5-000* -v > > Checking patch src/bin/psql/tab-complete.in.c... > > error: while searching for: > > "STATISTICS", "STORAGE",? > > /* a subset of ALTER SEQUENCE options */? > > "INCREMENT", "MINVALUE", > > "MAXVALUE", "START", "NO", "CACHE", "CYCLE");? > > /* ALTER TABLE ALTER [COLUMN] <foo> SET ( */? > > else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", > > "COLUMN", MatchAny, "SET", "(") ||? > > Matches("ALTER", "TABLE", MatchAny, "ALTER", > > MatchAny, "SET", "("))? > > COMPLETE_WITH("n_distinct", "n_distinct_inherited");? > > /* ALTER TABLE ALTER [COLUMN] <foo> SET COMPRESSION */? > > else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", > > "COLUMN", MatchAny, "SET", "COMPRESSION") ||? > > > > error: patch failed: src/bin/psql/tab-complete.in.c:2913 > > error: src/bin/psql/tab-complete.in.c: patch does not apply > > ---- > > Oh, sorry. I can apply them with git am. While reviewing these patches, I noticed that tab completion for parameter names is missing for SET LOCAL and SET SESSION. Would it be possible to fix this at the same time? Regarding the pg_parameter_acl catalog, which was introduced in PostgreSQL 15, are there any backward-compatibility concerns? I don't think that tab completion for ALTER SYSTEM is a high priority, as the implementation would likely be overly complex. -- Best regards, Shinya Kato NTT OSS Center
pgsql-hackers by date: