Re: Improve tab completion for various SET/RESET forms
Shinya Kato <shinya11.kato@gmail.com>
From: Shinya Kato <shinya11.kato@gmail.com>
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Cc: pgsql-hackers@postgresql.org
Date: 2025-08-13T09:53:59Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix tab completion for ALTER ROLE|USER ... RESET
- 88914332eaed 18.0 landed
- ca09ef3a6aa6 19 (unreleased) landed
-
Schema-qualify unnest() in ALTER DATABASE ... RESET
- 72c437f6e464 18.0 landed
- dbf5a83d4650 19 (unreleased) landed
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