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-08T03:03:30Z
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

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.

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

-- 
Best regards,
Shinya Kato
NTT OSS Center