Skip to content

Commit 5e70d8b

Browse files
committed
Tweak the default behavior of psql's \dconfig.
\dconfig without an argument originally printed all parameters, but it seems more useful to print only those parameters with non-default settings. You can easily get the show-everything behavior with "\dconfig *", but that output is unwieldy and seems unlikely to be wanted very often. Per suggestion from Christoph Berg. Discussion: https://postgr.es/m/YlFQLzlPi4QD0wSi@msg.df7cb.de
1 parent 3c702b3 commit 5e70d8b

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

doc/src/sgml/ref/psql-ref.sgml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ echo '\x \\ SELECT * FROM foo;' | psql
129129
for more details about how the server handles multi-query strings.)
130130
</para>
131131
<para>
132-
If having several commands executed in one transaction is not desired,
132+
If having several commands executed in one transaction is not desired,
133133
use repeated <option>-c</option> commands or feed multiple commands to
134134
<application>psql</application>'s standard input,
135135
either using <application>echo</application> as illustrated above, or
@@ -1385,9 +1385,11 @@ testdb=&gt;
13851385
<listitem>
13861386
<para>
13871387
Lists server configuration parameters and their values.
1388-
If <replaceable class="parameter">pattern</replaceable>
1389-
is specified, only parameters whose names match the pattern are
1390-
listed.
1388+
If <replaceable class="parameter">pattern</replaceable> is specified,
1389+
only parameters whose names match the pattern are listed. Without
1390+
a <replaceable class="parameter">pattern</replaceable>, only
1391+
parameters that are set to non-default values are listed.
1392+
(Use <literal>\dconfig *</literal> to see all parameters.)
13911393
If <literal>+</literal> is appended to the command name, each
13921394
parameter is listed with its data type, context in which the
13931395
parameter can be set, and access privileges (if non-default access

src/bin/psql/describe.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4404,10 +4404,13 @@ describeConfigurationParameters(const char *pattern, bool verbose,
44044404
" LEFT JOIN pg_catalog.pg_parameter_acl p\n"
44054405
" ON pg_catalog.lower(s.name) = p.parname\n");
44064406

4407-
processSQLNamePattern(pset.db, &buf, pattern,
4408-
false, false,
4409-
NULL, "pg_catalog.lower(s.name)", NULL,
4410-
NULL);
4407+
if (pattern)
4408+
processSQLNamePattern(pset.db, &buf, pattern,
4409+
false, false,
4410+
NULL, "pg_catalog.lower(s.name)", NULL,
4411+
NULL);
4412+
else
4413+
appendPQExpBufferStr(&buf, "WHERE s.source <> 'default'\n");
44114414

44124415
appendPQExpBufferStr(&buf, "ORDER BY 1;");
44134416

@@ -4417,7 +4420,10 @@ describeConfigurationParameters(const char *pattern, bool verbose,
44174420
return false;
44184421

44194422
myopt.nullPrint = NULL;
4420-
myopt.title = _("List of configuration parameters");
4423+
if (pattern)
4424+
myopt.title = _("List of configuration parameters");
4425+
else
4426+
myopt.title = _("List of non-default configuration parameters");
44214427
myopt.translate_header = true;
44224428

44234429
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);

0 commit comments

Comments
 (0)