Re: Improving psql autocompletion for SET LOCAL / SET SESSION

From: solai v <solai(dot)cdac(at)gmail(dot)com>
To: surya poondla <suryapoondla4(at)gmail(dot)com>
Cc: Álvaro Rodríguez <alvaro(at)datadoghq(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improving psql autocompletion for SET LOCAL / SET SESSION
Date: 2026-06-12 10:46:14
Message-ID: CAF0whufL-5A--_T+QkD71iQFkD1DEwQVFZjwZEnXxitLjRymkQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> I am thinking maybe we could split the cases as
> /* Complete "SET LOCAL" */
> else if (Matches("SET", "LOCAL"))
> COMPLETE_WITH_QUERY_VERBATIM_PLUS(Query_for_list_of_set_vars,
> "TIME ZONE",
> "SCHEMA",
> "NAMES");
> /* Complete "SET SESSION" */
> else if (Matches("SET", "SESSION"))
> COMPLETE_WITH_QUERY_VERBATIM_PLUS(Query_for_list_of_set_vars,
> "AUTHORIZATION",
> "CHARACTERISTICS AS TRANSACTION",
> "TIME ZONE",
> "SCHEMA",
> "NAMES");
>
> and remove the now-redundant later Matches("SET", "SESSION") block
>
> Worth considering whether ROLE should be in both lists too, since SET LOCAL ROLE … and SET SESSION ROLE … are both valid.
>
> Regards,
> Surya Poondla

I tested the patch and was able to reproduce the regression that Surya
pointed out.

Before applying the patch:
SET LOCAL <TAB> completed to TO.
SET SESSION <TAB> suggested AUTHORIZATION and CHARACTERISTICS AS TRANSACTION.

After applying the patch:
SET LOCAL <TAB> correctly shows configuration variable completions
along with TIME ZONE, SCHEMA, and NAMES.
SET SESSION <TAB> also shows the configuration variable list, but
no longer suggests AUTHORIZATION or CHARACTERISTICS AS TRANSACTION.

I also experimented with separating the SET LOCAL and SET SESSION
completion rules, similar to the approach suggested by Surya, and
tried a few variations while testing. However, I was not able to
restore the previous SET SESSION completion behavior in my
environment.
So I can reproduce both the original issue and the regression, but I
do not yet have a verified fix.
Are there any additional ideas or approaches that I should investigate
to preserve the existing SET SESSION completions while keeping the new
SET LOCAL behavior?

regards
Solai

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2026-06-12 10:52:52 Re: Row pattern recognition
Previous Message Alvaro Herrera 2026-06-12 10:25:29 Re: REPACK CONCURRENTLY fails on tables with generated columns