Re: Improve tab completion for various SET/RESET forms

Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>

From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: Shinya Kato <shinya11.kato@gmail.com>
Cc: pgsql-hackers@postgresql.org
Date: 2025-08-08T22:55:33Z
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 →
  1. Fix tab completion for ALTER ROLE|USER ... RESET

  2. Schema-qualify unnest() in ALTER DATABASE ... RESET

Attachments

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.
>
> 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