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-08 22:55:33
Message-ID: 87a549h196.fsf@wibble.ilmari.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.
>
> Thank you for the patches.
>
> + else if (Matches("ALTER", "FOREIGN", "TABLE", MatchAny, "SET"))
> + COMPLETE_WITH("SCHEMA");
>
> In addition to SET SCHEMA, I think you should add tab completion for
> SET WITHOUT OIDS.

As Kirill pointed out, support for WITH OIDS was removed in v12. The
SET WITHOUT OIDS syntax only remains as a no-op for backwards
compatibility with existing SQL scripts, so there's no point in offering
tab completion for it.

> +#define Query_for_list_of_session_vars \
> +"SELECT pg_catalog.lower(name) FROM pg_catalog.pg_settings "\
> +" WHERE context IN ('user', 'superuser') "\
> +" AND source = 'session' "\
> +" AND pg_catalog.lower(name) LIKE pg_catalog.lower('%s')"
>
> I think the context IN ('user', 'superuser') condition is redundant
> here. If a parameter's source is 'session', its context must be either
> 'user' or 'superuser'. Therefore, the source = 'session' check alone
> should be sufficient.

Good point, updated in the attached v4 patches.

- ilmari

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2025-08-08 23:20:14 Re: headerscheck warnings with late-model gcc
Previous Message Andres Freund 2025-08-08 22:37:51 Re: Enhance statistics reset functions to return reset timestamp