Make \dS work more like it used to, viz, show only system objects.

This commit is contained in:
Tom Lane 2002-09-22 20:44:22 +00:00
parent fce573ae16
commit 286fb25243
2 changed files with 15 additions and 12 deletions

View 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 PostgreSQL documentation
--> -->
@ -884,7 +884,9 @@ testdb=>
This is not the actual command name: the letters i, s, t, v, S This is not the actual command name: the letters i, s, t, v, S
stand for index, sequence, table, view, and system table, stand for index, sequence, table, view, and system table,
respectively. You can specify any or all of these letters, in any 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 If <quote>+</quote> is appended to the command name, each object is
listed with its associated description, if any. listed with its associated description, if any.
</para> </para>

View File

@ -3,7 +3,7 @@
* *
* Copyright 2000-2002 by PostgreSQL Global Development Group * 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 "postgres_fe.h"
#include "describe.h" #include "describe.h"
@ -1231,7 +1231,7 @@ describeUsers(const char *pattern)
* i - indexes * i - indexes
* v - views * v - views
* s - sequences * s - sequences
* S - system tables (~ '^pg_') * S - system tables (pg_catalog)
* (any order of the above is fine) * (any order of the above is fine)
*/ */
bool bool
@ -1247,7 +1247,7 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
PGresult *res; PGresult *res;
printQueryOpt myopt = pset.popt; printQueryOpt myopt = pset.popt;
if (showSystem && !(showSeq || showIndexes || showViews || showTables)) if (!(showTables || showIndexes || showViews || showSeq))
showTables = showViews = showSeq = true; showTables = showViews = showSeq = true;
initPQExpBuffer(&buf); initPQExpBuffer(&buf);
@ -1296,18 +1296,19 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
appendPQExpBuffer(&buf, ")\n"); 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 * those in pg_catalog and pg_toast. (We don't want to hide temp
* tables though.) * tables though.)
*/ */
if (showSystem) if (showSystem)
processNamePattern(&buf, pattern, true, false, appendPQExpBuffer(&buf, " AND n.nspname = 'pg_catalog'\n");
"n.nspname", "c.relname", NULL,
"pg_catalog.pg_table_is_visible(c.oid)");
else else
processNamePattern(&buf, pattern, true, false, appendPQExpBuffer(&buf, " AND n.nspname NOT IN ('pg_catalog', 'pg_toast')\n");
"n.nspname", "c.relname", NULL,
"pg_catalog.pg_table_is_visible(c.oid) AND n.nspname <> 'pg_catalog' AND n.nspname <> 'pg_toast'"); processNamePattern(&buf, pattern, true, false,
"n.nspname", "c.relname", NULL,
"pg_catalog.pg_table_is_visible(c.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1,2;"); appendPQExpBuffer(&buf, "ORDER BY 1,2;");