psql: Add tab completion for ALTER USER RESET

Robins Tharakan <tharakan@gmail.com>

From: Robins Tharakan <tharakan@gmail.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-11-29T08:42:29Z
Lists: pgsql-hackers

Attachments

Hi,

Please find attached a patch to help tab completion show only currently set
vars
during ALTER USER RESET.

Currently tab completion provides a list of all vars which is only
partially helpful.
This patch allows tab completion to see which vars are currently set for
the role
and only show those options during tab completion.


For example:
postgres=# \drds
                     List of settings
   Role   | Database |              Settings
----------+----------+-------------------------------------
 postgres |          | max_parallel_workers_per_gather=100+
          |          | max_parallel_workers=100
(1 row)

postgres=# alter user postgres reset
ALL                              max_parallel_workers
max_parallel_workers_per_gather

postgres=# alter user postgres reset max_parallel_workers;
ALTER ROLE

postgres=# \drds
                     List of settings
   Role   | Database |              Settings
----------+----------+-------------------------------------
 postgres |          | max_parallel_workers_per_gather=100
(1 row)

postgres=# alter user postgres reset
ALL                              max_parallel_workers_per_gather

postgres=# alter user postgres reset all;
ALTER ROLE

postgres=# \drds
Did not find any settings.

Applies on master (b6612aedc53a6) / make check successful.
-
Robins Tharakan
Amazon Web Services

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add tab completion for ALTER DATABASE RESET

  2. Add tab completion for ALTER USER/ROLE RESET