Tweak the default behavior of psql's \dconfig.
authorTom Lane <[email protected]>
Mon, 11 Apr 2022 19:11:46 +0000 (15:11 -0400)
committerTom Lane <[email protected]>
Mon, 11 Apr 2022 19:11:46 +0000 (15:11 -0400)
\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/[email protected]

doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/describe.c

index 92e5c5030030084cd4a871b0cf094c4ef5c9eb8e..592356019b5a4f14f9d1bd7d1440a45fdc69aeb9 100644 (file)
@@ -129,7 +129,7 @@ echo '\x \\ SELECT * FROM foo;' | psql
        for more details about how the server handles multi-query strings.)
       </para>
       <para>
-       If having several commands executed in one transaction is not desired, 
+       If having several commands executed in one transaction is not desired,
        use repeated <option>-c</option> commands or feed multiple commands to
        <application>psql</application>'s standard input,
        either using <application>echo</application> as illustrated above, or
@@ -1385,9 +1385,11 @@ testdb=&gt;
         <listitem>
         <para>
         Lists server configuration parameters and their values.
-        If <replaceable class="parameter">pattern</replaceable>
-        is specified, only parameters whose names match the pattern are
-        listed.
+        If <replaceable class="parameter">pattern</replaceable> is specified,
+        only parameters whose names match the pattern are listed.  Without
+        a <replaceable class="parameter">pattern</replaceable>, only
+        parameters that are set to non-default values are listed.
+        (Use <literal>\dconfig *</literal> to see all parameters.)
         If <literal>+</literal> is appended to the command name, each
         parameter is listed with its data type, context in which the
         parameter can be set, and access privileges (if non-default access
index d04ba2b0290f617a76fa94777401445ed8d7ea20..e7377d4583f9cccd4f7899360a223eb24e0ab4a4 100644 (file)
@@ -4404,10 +4404,13 @@ describeConfigurationParameters(const char *pattern, bool verbose,
                                                         "  LEFT JOIN pg_catalog.pg_parameter_acl p\n"
                                                         "  ON pg_catalog.lower(s.name) = p.parname\n");
 
-       processSQLNamePattern(pset.db, &buf, pattern,
-                                                 false, false,
-                                                 NULL, "pg_catalog.lower(s.name)", NULL,
-                                                 NULL);
+       if (pattern)
+               processSQLNamePattern(pset.db, &buf, pattern,
+                                                         false, false,
+                                                         NULL, "pg_catalog.lower(s.name)", NULL,
+                                                         NULL);
+       else
+               appendPQExpBufferStr(&buf, "WHERE s.source <> 'default'\n");
 
        appendPQExpBufferStr(&buf, "ORDER BY 1;");
 
@@ -4417,7 +4420,10 @@ describeConfigurationParameters(const char *pattern, bool verbose,
                return false;
 
        myopt.nullPrint = NULL;
-       myopt.title = _("List of configuration parameters");
+       if (pattern)
+               myopt.title = _("List of configuration parameters");
+       else
+               myopt.title = _("List of non-default configuration parameters");
        myopt.translate_header = true;
 
        printQuery(res, &myopt, pset.queryFout, false, pset.logfile);