]> granicus.if.org Git - postgresql/commitdiff
Make \dS work more like it used to, viz, show only system objects.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 22 Sep 2002 20:44:22 +0000 (20:44 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 22 Sep 2002 20:44:22 +0000 (20:44 +0000)
doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/describe.c

index e10cdd9aa1683649e770fc86606d0c668c0e2ba7..e2cec12ad29ec11d327b6b57efd3c5633bb0e8b9 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.76 2002/09/21 18:32:54 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.77 2002/09/22 20:44:22 tgl Exp $
 PostgreSQL documentation
 -->
 
@@ -884,7 +884,9 @@ testdb=>
        This is not the actual command name: the letters i, s, t, v, S
        stand for index, sequence, table, view, and system table,
        respectively. You can specify any or all of these letters, in any
-       order, to obtain a listing of all the matching objects.
+       order, to obtain a listing of all the matching objects.  The letter
+       S restricts the listing to system objects; without S, only non-system
+       objects are shown.
        If <quote>+</quote> is appended to the command name, each object is
        listed with its associated description, if any.
        </para>
index 239d984a08eba91332aba68a67387cd82673194b..9c4c93c0df41ed245f2262dd35e8f5c75cdb89a8 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000-2002 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.68 2002/09/04 20:31:35 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.69 2002/09/22 20:44:22 tgl Exp $
  */
 #include "postgres_fe.h"
 #include "describe.h"
@@ -1231,7 +1231,7 @@ describeUsers(const char *pattern)
  * i - indexes
  * v - views
  * s - sequences
- * S - system tables (~ '^pg_')
+ * S - system tables (pg_catalog)
  * (any order of the above is fine)
  */
 bool
@@ -1247,7 +1247,7 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
        PGresult   *res;
        printQueryOpt myopt = pset.popt;
 
-       if (showSystem && !(showSeq || showIndexes || showViews || showTables))
+       if (!(showTables || showIndexes || showViews || showSeq))
                showTables = showViews = showSeq = true;
 
        initPQExpBuffer(&buf);
@@ -1296,18 +1296,19 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
        appendPQExpBuffer(&buf, ")\n");
 
        /*
-        * Unless showSystem is specified, we suppress system tables, ie,
+        * If showSystem is specified, show only system objects (those in
+        * pg_catalog).  Otherwise, suppress system objects, including
         * those in pg_catalog and pg_toast.  (We don't want to hide temp
         * tables though.)
         */
        if (showSystem)
-               processNamePattern(&buf, pattern, true, false,
-                                                  "n.nspname", "c.relname", NULL,
-                                                  "pg_catalog.pg_table_is_visible(c.oid)");
+               appendPQExpBuffer(&buf, "      AND n.nspname = 'pg_catalog'\n");
        else
-               processNamePattern(&buf, pattern, true, false,
-                                                  "n.nspname", "c.relname", NULL,
-                                                  "pg_catalog.pg_table_is_visible(c.oid) AND n.nspname <> 'pg_catalog' AND n.nspname <> 'pg_toast'");
+               appendPQExpBuffer(&buf, "      AND n.nspname NOT IN ('pg_catalog', 'pg_toast')\n");
+
+       processNamePattern(&buf, pattern, true, false,
+                                          "n.nspname", "c.relname", NULL,
+                                          "pg_catalog.pg_table_is_visible(c.oid)");
 
        appendPQExpBuffer(&buf, "ORDER BY 1,2;");