Re: Improve tab completion for various SET/RESET forms - Mailing list pgsql-hackers

From Dagfinn Ilmari Mannsåker
Subject Re: Improve tab completion for various SET/RESET forms
Date
Msg-id 874iuegk7h.fsf@wibble.ilmari.org
Whole thread Raw
In response to Re: Improve tab completion for various SET/RESET forms  (Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>)
Responses Re: Improve tab completion for various SET/RESET forms
List pgsql-hackers
Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> writes:

> Shinya Kato <shinya11.kato@gmail.com> writes:
>
>> On Fri, Aug 1, 2025 at 2:16 AM Dagfinn Ilmari Mannsåker
>> <ilmari@ilmari.org> wrote:
>>>
>>> Dagfinn Ilmari Mannsåker <ilmari@ilmari.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

pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: Obsolete comments in ResultRelInfo struct
Next
From: Nazir Bilal Yavuz
Date:
Subject: Re: meson: add and use stamp files for generated headers