From 12fc33077b9443e24304bdebcec528c08fae4036 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Sun, 16 Nov 1997 04:36:52 +0000
Subject: [PATCH] New \dS psql command.  initdb cleanup.

---
 src/bin/initdb/initdb.sh             | 10 +++++++---
 src/bin/psql/psql.c                  | 29 ++++++++++++++++++----------
 src/include/catalog/pg_attribute.h   | 15 +-------------
 src/include/catalog/pg_class.h       |  5 +----
 src/include/catalog/pg_description.h |  4 ++--
 src/include/catalog/pg_type.h        |  4 +---
 src/man/psql.1                       |  4 +++-
 7 files changed, 34 insertions(+), 37 deletions(-)

diff --git a/src/bin/initdb/initdb.sh b/src/bin/initdb/initdb.sh
index 82744d93d12..6d6456f957d 100644
--- a/src/bin/initdb/initdb.sh
+++ b/src/bin/initdb/initdb.sh
@@ -26,7 +26,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.28 1997/11/15 20:57:30 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.29 1997/11/16 04:36:14 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -346,10 +346,14 @@ fi
 
 echo
 
+# If the COPY is first, the VACUUM generates an error, so we vacuum first
+echo "vacuuming template1"
+echo "vacuum" | postgres -F -Q -D$PGDATA template1 2>&1 > /dev/null |\
+	grep -v "^DEBUG:"
+
 echo "loading pg_description"
 echo "copy pg_description from '$TEMPLATE_DESCR'" | postgres -F -Q -D$PGDATA template1 > /dev/null
 echo "copy pg_description from '$GLOBAL_DESCR'" | postgres -F -Q -D$PGDATA template1 > /dev/null
-
-echo "vacuuming template1"
 echo "vacuum analyze" | postgres -F -Q -D$PGDATA template1 2>&1 > /dev/null |\
 	grep -v "^DEBUG:"
+
diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c
index e214428811a..089213b6783 100644
--- a/src/bin/psql/psql.c
+++ b/src/bin/psql/psql.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.106 1997/11/15 16:32:03 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.107 1997/11/16 04:36:20 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -114,7 +114,8 @@ static void handleCopyOut(PGresult *res, bool quiet, FILE *copystream);
 static void
 handleCopyIn(PGresult *res, const bool mustprompt,
 			 FILE *copystream);
-static int	tableList(PsqlSettings *pset, bool deep_tablelist, char info_type);
+static int	tableList(PsqlSettings *pset, bool deep_tablelist,
+				char info_type, bool system_tables);
 static int	tableDesc(PsqlSettings *pset, char *table, FILE *fout);
 static int	objectDescription(PsqlSettings *pset, char *object, FILE *fout);
 static int	rightsList(PsqlSettings *pset);
@@ -223,6 +224,7 @@ slashUsage(PsqlSettings *pset)
 	fprintf(fout, " \\di          -- list only indices\n");
 	fprintf(fout, " \\do          -- list operators\n");
 	fprintf(fout, " \\ds          -- list only sequences\n");
+	fprintf(fout, " \\dS          -- list system tables and indexes\n");
 	fprintf(fout, " \\dt          -- list only tables\n");
 	fprintf(fout, " \\dT          -- list types\n");
 	fprintf(fout, " \\e [<fname>] -- edit the current query buffer or <fname>\n");
@@ -303,7 +305,8 @@ listAllDbs(PsqlSettings *pset)
  *
  */
 int
-tableList(PsqlSettings *pset, bool deep_tablelist, char info_type)
+tableList(PsqlSettings *pset, bool deep_tablelist, char info_type,
+	bool system_tables)
 {
 	char		listbuf[256];
 	int			nColumns;
@@ -347,7 +350,10 @@ tableList(PsqlSettings *pset, bool deep_tablelist, char info_type)
 			strcat(listbuf, "WHERE ( relkind = 'r' OR relkind = 'i' OR relkind = 'S') ");
 			break;
 	}
-	strcat(listbuf, "  and relname !~ '^pg_'");
+	if (!system_tables)
+		strcat(listbuf, "  and relname !~ '^pg_'");
+	else
+		strcat(listbuf, "  and relname ~ '^pg_'");
 	strcat(listbuf, "  and relname !~ '^xin[vx][0-9]+'");
 
 	/*
@@ -1708,7 +1714,7 @@ HandleSlashCmds(PsqlSettings *pset,
 					false, false, 0);
 			else if (strncmp(cmd, "di", 2) == 0)
 								/* only indices */
-				tableList(pset, false, 'i');
+				tableList(pset, false, 'i', false);
 			else if (strncmp(cmd, "do", 2) == 0)
 			{
 								/* operators */
@@ -1754,10 +1760,13 @@ HandleSlashCmds(PsqlSettings *pset,
 			}
 			else if (strncmp(cmd, "ds", 2) == 0)
 								/* only sequences */
-				tableList(pset, false, 'S');
+				tableList(pset, false, 'S', false);
+			else if (strncmp(cmd, "dS", 2) == 0)
+								/* system tables */
+				tableList(pset, false, 'b', true);
 			else if (strncmp(cmd, "dt", 2) == 0)
 								/* only tables */
-				tableList(pset, false, 't');
+				tableList(pset, false, 't', false);
 			else if (strncmp(cmd, "dT", 2) == 0)
 								/* types */
 				SendQuery(&success, pset,"\
@@ -1770,11 +1779,11 @@ HandleSlashCmds(PsqlSettings *pset,
 					false, false, 0);
 			else if (!optarg)
 								/* show tables, sequences and indices */
-				tableList(pset, false, 'b');
+				tableList(pset, false, 'b', false);
 			else if (strcmp(optarg, "*") == 0)
 			{					/* show everything */
-				if (tableList(pset, false, 'b') == 0)
-					tableList(pset, true, 'b');
+				if (tableList(pset, false, 'b', false) == 0)
+					tableList(pset, true, 'b', false);
 			}
 			else if (strncmp(cmd, "d ", 2) == 0)
 								/* describe the specified table */
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index a3e92bf8d83..b5249adbd31 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_attribute.h,v 1.18 1997/11/15 20:57:40 momjian Exp $
+ * $Id: pg_attribute.h,v 1.19 1997/11/16 04:36:32 momjian Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -226,19 +226,6 @@ DATA(insert OID = 0 ( 1262 cmin				29 0  4  -4 0 -1 t f i f f));
 DATA(insert OID = 0 ( 1262 xmax				28 0  4  -5 0 -1 f f i f f));
 DATA(insert OID = 0 ( 1262 cmax				29 0  4  -6 0 -1 t f i f f));
 
-/* ----------------
- *		pg_description
- * ----------------
- */
-DATA(insert OID = 0 ( 1251 objoid			26 0  4   1 0 -1 t f i f f));
-DATA(insert OID = 0 ( 1251 description		25 0 -1   2 0 -1 f f i f f));
-DATA(insert OID = 0 ( 1251 ctid				27 0  6  -1 0 -1 f f i f f));
-DATA(insert OID = 0 ( 1251 oid				26 0  4  -2 0 -1 t f i f f));
-DATA(insert OID = 0 ( 1251 xmin				28 0  4  -3 0 -1 f f i f f));
-DATA(insert OID = 0 ( 1251 cmin				29 0  4  -4 0 -1 t f i f f));
-DATA(insert OID = 0 ( 1251 xmax				28 0  4  -5 0 -1 f f i f f));
-DATA(insert OID = 0 ( 1251 cmax				29 0  4  -6 0 -1 t f i f f));
-
 /* ----------------
  *		pg_proc
  * ----------------
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index 7354b1c4c84..bcc8b86d4d0 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_class.h,v 1.14 1997/11/15 20:57:41 momjian Exp $
+ * $Id: pg_class.h,v 1.15 1997/11/16 04:36:38 momjian Exp $
  *
  * NOTES
  *	  ``pg_relation'' is being replaced by ``pg_class''.  currently
@@ -132,8 +132,6 @@ DATA(insert OID = 1247 (  pg_type 71		  PGUID 0 0 0 0 0 f f r n 16 0 0 0 f _null
 DESCR("");
 DATA(insert OID = 1249 (  pg_attribute 75	  PGUID 0 0 0 0 0 f f r n 16 0 0 0 f _null_ ));
 DESCR("");
-DATA(insert OID = 1251 (  pg_description 76	  PGUID 0 0 0 0 0 f t r n 2 0 0 0 f _null_ ));
-DESCR("");
 DATA(insert OID = 1255 (  pg_proc 81		  PGUID 0 0 0 0 0 f f r n 16 0 0 0 f _null_ ));
 DESCR("");
 DATA(insert OID = 1259 (  pg_class 83		  PGUID 0 0 0 0 0 f f r n 18 0 0 0 f _null_ ));
@@ -156,7 +154,6 @@ DATA(insert OID = 1219 (  pg_trigger 111	  PGUID 0 0 0 0 0 t t r n 7 0 0 0 f _nu
 DESCR("");
 
 #define RelOid_pg_type			1247
-#define RelOid_pg_description	1251
 #define RelOid_pg_attribute		1249
 #define RelOid_pg_proc			1255
 #define RelOid_pg_class			1259
diff --git a/src/include/catalog/pg_description.h b/src/include/catalog/pg_description.h
index bc8df53048f..5882eeb9b35 100644
--- a/src/include/catalog/pg_description.h
+++ b/src/include/catalog/pg_description.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_description.h,v 1.3 1997/11/15 20:57:48 momjian Exp $
+ * $Id: pg_description.h,v 1.4 1997/11/16 04:36:41 momjian Exp $
  *
  * NOTES
  *		the genbki.sh script reads this file and generates .bki
@@ -32,7 +32,7 @@
  *		typedef struct FormData_pg_description
  * ----------------
  */
-CATALOG(pg_description) BOOTSTRAP
+CATALOG(pg_description)
 {
 	Oid			objoid;
 	text		description;
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index c7d8a659622..57763cdce3a 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_type.h,v 1.22 1997/11/15 20:58:05 momjian Exp $
+ * $Id: pg_type.h,v 1.23 1997/11/16 04:36:43 momjian Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -210,8 +210,6 @@ DATA(insert OID = 71 (	pg_type		 PGUID 1 1 t b t \054 1247 0 foo bar foo bar c _
 DESCR("");
 DATA(insert OID = 75 (	pg_attribute PGUID 1 1 t b t \054 1249 0 foo bar foo bar c _null_));
 DESCR("");
-DATA(insert OID = 76 (	pg_description	 PGUID 1 1 t b t \054 1251 0 foo bar foo bar c _null_));
-DESCR("");
 DATA(insert OID = 81 (	pg_proc		 PGUID 1 1 t b t \054 1255 0 foo bar foo bar c _null_));
 DESCR("");
 DATA(insert OID = 83 (	pg_class	 PGUID 1 1 t b t \054 1259 0 foo bar foo bar c _null_));
diff --git a/src/man/psql.1 b/src/man/psql.1
index e104512c24a..8569f5da04c 100644
--- a/src/man/psql.1
+++ b/src/man/psql.1
@@ -1,6 +1,6 @@
 .\" This is -*-nroff-*-
 .\" XXX standard disclaimer belongs here....
-.\" $Header: /cvsroot/pgsql/src/man/Attic/psql.1,v 1.17 1997/11/15 16:32:25 momjian Exp $
+.\" $Header: /cvsroot/pgsql/src/man/Attic/psql.1,v 1.18 1997/11/16 04:36:52 momjian Exp $
 .TH PSQL UNIX 1/20/96 PostgreSQL PostgreSQL
 .SH NAME
 psql \(em run the interactive query front-end
@@ -304,6 +304,8 @@ List only indexes.
 List operators.
 .IP "\eds"
 List only sequences.
+.IP "\edS"
+List system tables and indexes.
 .IP "\edt"
 List only tables.
 .IP "\edT"
-- 
GitLab