1212 *by PostgreSQL
1313 *
1414 * IDENTIFICATION
15- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.313 2002/12/27 17:10:45 tgl Exp $
15+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.314 2003/01/06 18:53:24 petere Exp $
1616 *
1717 *-------------------------------------------------------------------------
1818 */
4040#include "strdup.h"
4141#endif
4242
43+ #ifndef HAVE_GETOPT_LONG
44+ #include "getopt_long.h"
45+ int optreset ;
46+ #endif
47+
4348#include "access/attnum.h"
4449#include "access/htup.h"
4550#include "catalog/pg_class.h"
@@ -179,7 +184,6 @@ main(int argc, char **argv)
179184
180185RestoreOptions * ropt ;
181186
182- #ifdef HAVE_GETOPT_LONG
183187static struct option long_options []= {
184188{"data-only" ,no_argument ,NULL ,'a' },
185189{"blobs" ,no_argument ,NULL ,'b' },
@@ -218,7 +222,6 @@ main(int argc, char **argv)
218222{NULL ,0 ,NULL ,0 }
219223};
220224int optindex ;
221- #endif
222225
223226#ifdef ENABLE_NLS
224227setlocale (LC_ALL ,"" );
@@ -260,12 +263,8 @@ main(int argc, char **argv)
260263}
261264}
262265
263- #ifdef HAVE_GETOPT_LONG
264- while ((c = getopt_long (argc ,argv ,"abcCdDf:F:h:ioOp:RsS:t:uU:vWxX:Z:" ,long_options ,& optindex ))!= -1 )
265- #else
266- while ((c = getopt (argc ,argv ,"abcCdDf:F:h:ioOp:RsS:t:uU:vWxX:Z:-" ))!= -1 )
267- #endif
268-
266+ while ((c = getopt_long (argc ,argv ,"abcCdDf:F:h:ioOp:RsS:t:uU:vWxX:Z:" ,
267+ long_options ,& optindex ))!= -1 )
269268{
270269switch (c )
271270{
@@ -415,23 +414,15 @@ main(int argc, char **argv)
415414exit (1 );
416415}
417416break ;
417+
418418case 'Z' :/* Compression Level */
419419compressLevel = atoi (optarg );
420420break ;
421-
422- #ifndef HAVE_GETOPT_LONG
423- case '-' :
424- fprintf (stderr ,
425- _ ("%s was compiled without support for long options.\n"
426- "Use --help for help on invocation options.\n" ),
427- progname );
428- exit (1 );
429- break ;
430- #else
431421/* This covers the long options equivalent to -X xxx. */
422+
432423case 0 :
433424break ;
434- #endif
425+
435426default :
436427fprintf (stderr ,_ ("Try '%s --help' for more information.\n" ),progname );
437428exit (1 );
@@ -658,26 +649,16 @@ help(const char *progname)
658649printf (_ (" %s [OPTION]... [DBNAME]\n" ),progname );
659650
660651printf (_ ("\nGeneral options:\n" ));
661- #ifdef HAVE_GETOPT_LONG
662652printf (_ (" -f, --file=FILENAME output file name\n" ));
663653printf (_ (" -F, --format=c|t|p output file format (custom, tar, plain text)\n" ));
664654printf (_ (" -i, --ignore-version proceed even when server version mismatches\n"
665655" pg_dump version\n" ));
666656printf (_ (" -v, --verbose verbose mode\n" ));
667657printf (_ (" -Z, --compress=0-9 compression level for compressed formats\n" ));
668- #else /* not HAVE_GETOPT_LONG */
669- printf (_ (" -f FILENAME output file name\n" ));
670- printf (_ (" -F c|t|p output file format (custom, tar, plain text)\n" ));
671- printf (_ (" -i proceed even when server version mismatches\n"
672- " pg_dump version\n" ));
673- printf (_ (" -v verbose mode\n" ));
674- printf (_ (" -Z 0-9 compression level for compressed formats\n" ));
675- #endif /* not HAVE_GETOPT_LONG */
676658printf (_ (" --help show this help, then exit\n" ));
677659printf (_ (" --version output version information, then exit\n" ));
678660
679661printf (_ ("\nOptions controlling the output content:\n" ));
680- #ifdef HAVE_GETOPT_LONG
681662printf (_ (" -a, --data-only dump only the data, not the schema\n" ));
682663printf (_ (" -b, --blobs include large objects in dump\n" ));
683664printf (_ (" -c, --clean clean (drop) schema prior to create\n" ));
@@ -699,41 +680,12 @@ help(const char *progname)
699680" than \\connect commands\n" ));
700681printf (_ (" -X disable-triggers, --disable-triggers\n"
701682" disable triggers during data-only restore\n" ));
702- #else /* not HAVE_GETOPT_LONG */
703- printf (_ (" -a dump only the data, not the schema\n" ));
704- printf (_ (" -b include large objects in dump\n" ));
705- printf (_ (" -c clean (drop) schema prior to create\n" ));
706- printf (_ (" -C include commands to create database in dump\n" ));
707- printf (_ (" -d dump data as INSERT, rather than COPY, commands\n" ));
708- printf (_ (" -D dump data as INSERT commands with column names\n" ));
709- printf (_ (" -o include OIDs in dump\n" ));
710- printf (_ (" -O do not output \\connect commands in plain\n"
711- " text format\n" ));
712- printf (_ (" -R disable ALL reconnections to the database in\n"
713- " plain text format\n" ));
714- printf (_ (" -s dump only the schema, no data\n" ));
715- printf (_ (" -S NAME specify the superuser user name to use in\n"
716- " plain text format\n" ));
717- printf (_ (" -t TABLE dump this table only (* for all)\n" ));
718- printf (_ (" -x do not dump privileges (grant/revoke)\n" ));
719- printf (_ (" -X use-set-session-authorization\n"
720- " output SET SESSION AUTHORIZATION commands rather\n"
721- " than \\connect commands\n" ));
722- printf (_ (" -X disable-triggers disable triggers during data-only restore\n" ));
723- #endif /* not HAVE_GETOPT_LONG */
724683
725684printf (_ ("\nConnection options:\n" ));
726- #ifdef HAVE_GETOPT_LONG
727685printf (_ (" -h, --host=HOSTNAME database server host name\n" ));
728686printf (_ (" -p, --port=PORT database server port number\n" ));
729687printf (_ (" -U, --username=NAME connect as specified database user\n" ));
730688printf (_ (" -W, --password force password prompt (should happen automatically)\n" ));
731- #else /* not HAVE_GETOPT_LONG */
732- printf (_ (" -h HOSTNAME database server host name\n" ));
733- printf (_ (" -p PORT database server port number\n" ));
734- printf (_ (" -U NAME connect as specified database user\n" ));
735- printf (_ (" -W force password prompt (should happen automatically)\n" ));
736- #endif /* not HAVE_GETOPT_LONG */
737689
738690printf (_ ("\nIf no database name is not supplied, then the PGDATABASE environment\n"
739691"variable value is used.\n\n" ));