| 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 |
| Subject: | Re: [PATCH] psql: tab completion for ALTER ROLE ... IN DATABASE ... |
| Date: | 2025-11-27 09:20:07 |
| Message-ID: | CAE2r8H79Auaji=HA8K20LQRJp6rXrpvzxnS-bkkk6kd9n9UHUg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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 |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Miłosz Bieniek | 2025-11-27 09:28:17 | [PATCH] Add `headerscheck` run_target to meson |
| Previous Message | Mahendra Singh Thalor | 2025-11-27 09:19:14 | Re: Non-text mode for pg_dumpall |