Re: How about a psql backslash command to show GUCs?

Pavel Luzanov <p.luzanov@postgrespro.ru>

From: Pavel Luzanov <p.luzanov@postgrespro.ru>
To: Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers@lists.postgresql.org
Cc: Mark Dilger <mark.dilger@enterprisedb.com>
Date: 2022-04-07T08:34:00Z
Lists: pgsql-hackers
On 06.04.2022 20:48, Tom Lane wrote:
> However, I very often
> find myself resorting to the much more tedious
>
> select * from pg_settings where name like '%foo%';

> In the discussion about adding privileges for GUCs [1], there
> was a proposal to add a new psql backslash command to show GUCs,
> which could reduce this problem to something like
>
> \dcp *foo*

+1, great idea.

Right now I use the psql :show variable in my .psqlrc for this purpose:

=# \echo :show
SELECT name, current_setting(name) AS value, context FROM pg_settings\g 
(format=wrapped columns=100) | grep

=# :show autovacuum
  autovacuum                             | 
on                                    | sighup
  autovacuum_analyze_scale_factor        | 
0.1                                   | sighup
  autovacuum_analyze_threshold           | 
50                                    | sighup
  autovacuum_freeze_max_age              | 
200000000                             | postmaster
  autovacuum_max_workers                 | 
3                                     | postmaster
  autovacuum_multixact_freeze_max_age    | 
400000000                             | postmaster
  autovacuum_naptime                     | 
1min                                  | sighup
  autovacuum_vacuum_cost_delay           | 
2ms                                   | sighup
  autovacuum_vacuum_cost_limit           | 
-1                                    | sighup
  autovacuum_vacuum_scale_factor         | 
0.2                                   | sighup
  autovacuum_vacuum_threshold            | 
50                                    | sighup
  autovacuum_work_mem                    | 
-1                                    | sighup
  log_autovacuum_min_duration            | 
-1                                    | sighup

As for the name, I can't think of a better candidate. Any of the 
previously suggested list of \dconf, \dguc, \dG, \dcp is fine.

-- 
Pavel Luzanov
Postgres Professional: https://postgrespro.com
The Russian Postgres Company




Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Be more careful about GucSource for internally-driven GUC settings.

  2. Fix case sensitivity in psql's tab completion for GUC names.

  3. Further tweak the default behavior of psql's \dconfig.

  4. Tweak the default behavior of psql's \dconfig.

  5. psql: add \dconfig command to show server's configuration parameters.

  6. Allow granting SET and ALTER SYSTEM privileges on GUC parameters.