Re: Improve tab completion for various SET/RESET forms

From: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
To: Shinya Kato <shinya11(dot)kato(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for various SET/RESET forms
Date: 2025-08-11 11:40:34
Message-ID: 874iuegk7h.fsf@wibble.ilmari.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org> writes:

> Shinya Kato <shinya11(dot)kato(at)gmail(dot)com> writes:
>
>> On Fri, Aug 1, 2025 at 2:16 AM Dagfinn Ilmari Mannsåker
>> <ilmari(at)ilmari(dot)org> wrote:
>>>
>>> Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org> writes:
>>>
>>> > I just noticed that in addition to ALTER ROLE ... RESET being buggy, the
>>> > ALTER DATABASE ... RESET query doesn't schema-qualify the unnest() call.
>>> > Here's an updated patch series that fixes that too. The first two are
>>> > bug fixes to features new in 18 and should IMO be committed before
>>> > that's released. The rest can wait for 19.
>>>
>>> Now that Tomas has committed the two bugfixes, here's the rest of the
>>> patches rebased over that.

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.

- ilmari

Attachment Content-Type Size
v5-0001-Add-tab-completion-for-ALTER-TABLE-.-ALTER-COLUMN.patch text/x-diff 1.7 KB
v5-0002-Add-tab-completion-for-ALTER-FOREIGN-TABLE-.-SET.patch text/x-diff 1.1 KB
v5-0003-Improve-tab-completion-for-RESET.patch text/x-diff 2.3 KB
v5-0004-Improve-tab-completion-for-ALTER-SYSTEM-RESET.patch text/x-diff 1.9 KB
v5-0005-Improve-tab-completion-for-ALTER-SYSTEM-RESET-for.patch text/x-diff 2.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nazir Bilal Yavuz 2025-08-11 11:40:40 Re: meson: add and use stamp files for generated headers
Previous Message Etsuro Fujita 2025-08-11 11:24:48 Obsolete comments in ResultRelInfo struct