Re: [PATCH] psql: tab completion for ALTER ROLE ... IN DATABASE ...

From: VASUKI M <vasukianand0119(at)gmail(dot)com>
To: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, carpenter(dot)nail(dot)cz(at)gmail(dot)com, ilmari(at)ilmari(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us, michael(at)paquier(dot)xyz, daniel(at)yesql(dot)se, byavuz81(at)gmail(dot)com, VASUKI M <vasukim1992002(at)gmail(dot)com>
Subject: Re: [PATCH] psql: tab completion for ALTER ROLE ... IN DATABASE ...
Date: 2025-12-04 09:10:59
Message-ID: CAE2r8H7EFVb2Pdo7PENq3NJ1VFdz96z7_fgnXs0Q4=k7V8UcXA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Kindly review the attached patch ,
As i saw the proposed patch by Ian failed with CI
https://commitfest.postgresql.org/patch/6244/
Guide me with the patch

Regards,
Vasuki M

On Thu, Nov 27, 2025 at 2:50 PM VASUKI M <vasukianand0119(at)gmail(dot)com> wrote:

> Hello all,
>
> Based on the discussion, I have updated the patch to handle the RESET form
> correctly without modifying psql’s tab-completion APIs.
>
> Both the current database connection and the parsed input tokens are
> already available via pset.db and the word tokens.The new patch extracts:
>
> -
>
> the role name from the parsed tokens (prev5_wd), and
> -
>
> the database name from the parsed tokens (prev2_wd),
>
> and uses these to query pg_db_role_setting for variables that are actually
> set for the specific (role, database) pair.
>
> Literal quoting is now done with PQescapeLiteral(pset.db, …), per libpq
> conventions, so no new helper functions were needed.
>
> SET
> After
>
> ALTER ROLE <role> IN DATABASE <dbname> SET <TAB>
>
> psql completes from Query_for_list_of_set_vars (same behavior as plain
> ALTER ROLE … SET).
>
> RESET
> After
>
> ALTER ROLE <role> IN DATABASE <dbname> RESET <TAB>
>
> psql now completes with the GUC names recorded in pg_db_role_setting for
> that specific (role,database), plus ALL.
> When no settings exist, only ALL is suggested.
> This mirrors the existing behavior of ALTER DATABASE … RESET.
>
> I have attached the patch.
>
> Regards,
>
> Vasuki
>
> On Thu, Nov 27, 2025 at 2:27 PM Ian Lawrence Barwick <barwick(at)gmail(dot)com>
> wrote:
>
>> Hi
>>
>> I found myself needing to work with ALTER ROLE ... IN DATABASE ...
>> recently
>> and was annoyed by the lack of tab completion for this, so patch attached.
>>
>>
>> Regards
>>
>> Ian Barwick
>>
>>

Attachment Content-Type Size
0001-psql-Add-tab-completion-support-for.patch text/x-patch 5.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2025-12-04 09:17:24 Re: [PATCH] Add enable_copy_program GUC to control COPY PROGRAM
Previous Message Chao Li 2025-12-04 09:10:42 Re: Cleanup shadows variable warnings, round 1