From dfc1a6a848d65f64e76a4bfce66269bdc33a6227 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Mon, 1 Dec 1997 21:01:24 +0000
Subject: [PATCH] Document pg_dump -z, clean up option list.  Fix problem with
 libpq handling of field names uppercase code.

---
 src/backend/catalog/heap.c        | 20 +++++------
 src/bin/pg_dump/pg_dump.c         | 58 +++++++++++++++----------------
 src/interfaces/libpq/fe-connect.c |  4 +--
 src/interfaces/libpq/fe-exec.c    |  4 +--
 src/man/pg_dump.1                 | 58 +++++++++++++++----------------
 5 files changed, 70 insertions(+), 74 deletions(-)

diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 2af462fe6ed..215ebebdea7 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.39 1997/11/28 17:26:51 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.40 1997/12/01 21:00:35 momjian Exp $
  *
  * INTERFACE ROUTINES
  *		heap_create()			- Create an uncataloged heap relation
@@ -35,26 +35,28 @@
 #include <catalog/heap.h>
 #include <catalog/index.h>
 #include <catalog/indexing.h>
-#include <catalog/pg_ipl.h>
+#include <catalog/pg_attrdef.h>
+#include <catalog/pg_index.h>
 #include <catalog/pg_inherits.h>
+#include <catalog/pg_ipl.h>
 #include <catalog/pg_proc.h>
-#include <catalog/pg_index.h>
-#include <catalog/pg_type.h>
-#include <catalog/pg_attrdef.h>
 #include <catalog/pg_relcheck.h>
+#include <catalog/pg_type.h>
 #include <commands/trigger.h>
+#include <nodes/plannodes.h>
+#include <optimizer/tlist.h>
 #include <parser/parse_expr.h>
 #include <parser/parse_node.h>
 #include <parser/parse_type.h>
+#include <rewrite/rewriteRemove.h>
 #include <storage/bufmgr.h>
 #include <storage/lmgr.h>
 #include <storage/smgr.h>
-#include <rewrite/rewriteRemove.h>
+#include <tcop/tcopprot.h>
 #include <utils/builtins.h>
 #include <utils/mcxt.h>
 #include <utils/relcache.h>
 #include <utils/tqual.h>
-#include <nodes/plannodes.h>
 #ifndef HAVE_MEMMOVE
 #include <regex/utils.h>
 #else
@@ -1482,10 +1484,6 @@ DestroyTempRels(void)
 	tempRels = NULL;
 }
 
-extern List *flatten_tlist(List *tlist);
-extern List *
-pg_plan(char *query_string, Oid *typev, int nargs,
-		QueryTreeList **queryListP, CommandDest dest);
 
 static void
 StoreAttrDefault(Relation rel, AttrDefault *attrdef)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 8a40d82fe12..5c54ca5184d 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -21,7 +21,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.53 1997/11/21 18:11:37 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.54 1997/12/01 21:00:57 momjian Exp $
  *
  * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
  *
@@ -106,30 +106,28 @@ char		g_comment_end[10];
 static void
 usage(const char *progname)
 {
-	fprintf(stderr,
-			"%s - version 1.13.dhb.2\n\n", progname);
 	fprintf(stderr,
 			"usage:  %s [options] [dbname]\n", progname);
 	fprintf(stderr,
-			"\t -f filename \t\t script output filename\n");
+			"\t -a          \t\t dump out only the data, no schema\n");
 	fprintf(stderr,
-			"\t -h hostname \t\t server host name\n");
+			"\t -d          \t\t dump data as proper insert strings\n");
 	fprintf(stderr,
-			"\t -p port     \t\t server port number\n");
+			"\t -D          \t\t dump data as inserts with attribute names\n");
 	fprintf(stderr,
-			"\t -v          \t\t verbose\n");
+			"\t -f filename \t\t script output filename\n");
 	fprintf(stderr,
-			"\t -d          \t\t dump data as proper insert strings\n");
+			"\t -h hostname \t\t server host name\n");
 	fprintf(stderr,
-	  "\t -D          \t\t dump data as inserts with attribute names\n");
+			"\t -o          \t\t dump object id's (oids)\n");
 	fprintf(stderr,
-			"\t -S          \t\t dump out only the schema, no data\n");
+			"\t -p port     \t\t server port number\n");
 	fprintf(stderr,
-			"\t -a          \t\t dump out only the data, no schema\n");
+			"\t -s          \t\t dump out only the schema, no data\n");
 	fprintf(stderr,
 			"\t -t table    \t\t dump for this table only\n");
 	fprintf(stderr,
-			"\t -o          \t\t dump object id's (oids)\n");
+			"\t -v          \t\t verbose\n");
 	fprintf(stderr,
 			"\t -z          \t\t dump ACLs (grant/revoke)\n");
 	fprintf(stderr,
@@ -479,41 +477,41 @@ main(int argc, char **argv)
 
 	progname = *argv;
 
-	while ((c = getopt(argc, argv, "f:h:p:t:vSDdDaoz")) != EOF)
+	while ((c = getopt(argc, argv, "adDf:h:op:st:vz")) != EOF)
 	{
 		switch (c)
 		{
+			case 'a':			/* Dump data only */
+				dataOnly = 1;
+				break;
+			case 'd':			/* dump data as proper insert strings */
+				dumpData = 1;
+				break;
+			case 'D':			/* dump data as proper insert strings with
+								 * attr names */
+				dumpData = 1;
+				attrNames = 1;
+				break;
 			case 'f':			/* output file name */
 				filename = optarg;
 				break;
 			case 'h':			/* server host */
 				pghost = optarg;
 				break;
+			case 'o':			/* Dump oids */
+				oids = 1;
+				break;
 			case 'p':			/* server port */
 				pgport = optarg;
 				break;
-			case 'v':			/* verbose */
-				g_verbose = true;
-				break;
-			case 'S':			/* dump schema only */
+			case 's':			/* dump schema only */
 				schemaOnly = 1;
 				break;
-			case 'd':			/* dump data as proper insert strings */
-				dumpData = 1;
-				break;
-			case 'D':			/* dump data as proper insert strings with
-								 * attr names */
-				dumpData = 1;
-				attrNames = 1;
-				break;
 			case 't':			/* Dump data for this table only */
 				tablename = optarg;
 				break;
-			case 'a':			/* Dump data only */
-				dataOnly = 1;
-				break;
-			case 'o':			/* Dump oids */
-				oids = 1;
+			case 'v':			/* verbose */
+				g_verbose = true;
 				break;
 			case 'z':			/* Dump oids */
 				acls = 1;
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 8b6648a5eb3..b9562fd6ef8 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.47 1997/11/17 16:42:39 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.48 1997/12/01 21:01:12 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -430,7 +430,7 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha
 				*(conn->dbName + strlen(conn->dbName) - 1) = '\0';
 			}
 			else
-				for (i = 0; conn->dbName[i]; i++)
+				for (i = strlen(conn->dbName[i]); i >= 0; i--)
 					if (isupper(conn->dbName[i]))
 						conn->dbName[i] = tolower(conn->dbName[i]);
 		}
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 2f1b55fbd12..86fca431cc6 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.40 1997/11/10 05:10:50 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.41 1997/12/01 21:01:18 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1697,7 +1697,7 @@ PQfnumber(PGresult *res, const char *field_name)
 		*(field_case + strlen(field_case) - 1) = '\0';
 	}
 	else
-		for (i = 0; field_case; i++)
+		for (i = strlen(field_case[i]); i >= 0; i--)
 			if (isupper(field_case[i]))
 				field_case[i] = tolower(field_case[i]);
 
diff --git a/src/man/pg_dump.1 b/src/man/pg_dump.1
index a03a91d85a2..f2fd835b634 100644
--- a/src/man/pg_dump.1
+++ b/src/man/pg_dump.1
@@ -1,42 +1,42 @@
 .\" This is -*-nroff-*-
 .\" XXX standard disclaimer belongs here....
-.\" $Header: /cvsroot/pgsql/src/man/Attic/pg_dump.1,v 1.7 1997/10/30 03:59:59 momjian Exp $
+.\" $Header: /cvsroot/pgsql/src/man/Attic/pg_dump.1,v 1.8 1997/12/01 21:01:24 momjian Exp $
 .TH PG_DUMP UNIX 1/20/96 PostgreSQL PostgreSQL
 .SH NAME
 pg_dump \(em dumps out a Postgres database into a script file
 .SH SYNOPSIS
 .BR pg_dump
 [\c
-.BR "-f"
-filename
+.BR "-a"
 ]
 [\c
-.BR "-h"
-hostname
+.BR "-d"
 ]
 [\c
-.BR "-p"
-port]
+.BR "-D"
+]
 [\c
-.BR "-v"
+.BR "-f"
+filename
 ]
 [\c
-.BR "-d"
+.BR "-h"
+hostname
 ]
 [\c
-.BR "-D"
+.BR "-o"
 ]
 [\c
-.BR "-S"
-help]
+.BR "-p"
+port]
 [\c
-.BR "-a"
+.BR "-s"
 ]
 [\c
 .BR "-t"
 table]
 [\c
-.BR "-o"
+.BR "-v"
 ]
 dbname
 .in -5n
@@ -62,35 +62,35 @@ in light of the limitations listed below.
 .PP
 pg_dump understands the following options:
 .TP
+.BR "-a" ""
+Dump out only the data, no schema
+.TP
+.BR "-d" ""
+Dump data as proper insert strings
+.TP
+.BR "-D" ""
+Dump data as inserts with attribute names
+.TP
 .BR "-f" " filename"
 Specifies the output file
 .TP
 .BR "-h" " hostname"
 Specifies the server host name
 .TP
+.BR "-o" ""
+Dump object id's (oids)
+.TP
 .BR "-p" " port"
 Specifies the server port number
 .TP
-.BR "-v" ""
-Specifies verbose mode
-.TP
-.BR "-d" ""
-Dump data as proper insert strings
-.TP
-.BR "-D" ""
-Dump data as inserts with attribute names
-.TP
-.BR "-S" ""
+.BR "-s" ""
 Dump out only the schema, no data
 .TP
-.BR "-a" ""
-Dump out only the data, no schema
-.TP
 .BR "-t" " table"
 Dump for this table only
 .TP
-.BR "-o" ""
-Dump object id's (oids)
+.BR "-v" ""
+Specifies verbose mode
 .PP
 If dbname is not supplied, then the DATABASE environment variable value is used.
 .SH "CAVEATS AND LIMITATIONS"
-- 
GitLab