diff options
Diffstat (limited to 'src/bin/pg_dump')
-rw-r--r-- | src/bin/pg_dump/pg_dump.c | 70 | ||||
-rw-r--r-- | src/bin/pg_dump/pg_dumpall.c | 31 | ||||
-rw-r--r-- | src/bin/pg_dump/pg_restore.c | 61 |
3 files changed, 25 insertions, 137 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 6c611f22bfd..809fe0216af 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -12,7 +12,7 @@ * by PostgreSQL * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.313 2002/12/27 17:10:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.314 2003/01/06 18:53:24 petere Exp $ * *------------------------------------------------------------------------- */ @@ -40,6 +40,11 @@ #include "strdup.h" #endif +#ifndef HAVE_GETOPT_LONG +#include "getopt_long.h" +int optreset; +#endif + #include "access/attnum.h" #include "access/htup.h" #include "catalog/pg_class.h" @@ -179,7 +184,6 @@ main(int argc, char **argv) RestoreOptions *ropt; -#ifdef HAVE_GETOPT_LONG static struct option long_options[] = { {"data-only", no_argument, NULL, 'a'}, {"blobs", no_argument, NULL, 'b'}, @@ -218,7 +222,6 @@ main(int argc, char **argv) {NULL, 0, NULL, 0} }; int optindex; -#endif #ifdef ENABLE_NLS setlocale(LC_ALL, ""); @@ -260,12 +263,8 @@ main(int argc, char **argv) } } -#ifdef HAVE_GETOPT_LONG - while ((c = getopt_long(argc, argv, "abcCdDf:F:h:ioOp:RsS:t:uU:vWxX:Z:", long_options, &optindex)) != -1) -#else - while ((c = getopt(argc, argv, "abcCdDf:F:h:ioOp:RsS:t:uU:vWxX:Z:-")) != -1) -#endif - + while ((c = getopt_long(argc, argv, "abcCdDf:F:h:ioOp:RsS:t:uU:vWxX:Z:", + long_options, &optindex)) != -1) { switch (c) { @@ -415,23 +414,15 @@ main(int argc, char **argv) exit(1); } break; + case 'Z': /* Compression Level */ compressLevel = atoi(optarg); break; - -#ifndef HAVE_GETOPT_LONG - case '-': - fprintf(stderr, - _("%s was compiled without support for long options.\n" - "Use --help for help on invocation options.\n"), - progname); - exit(1); - break; -#else /* This covers the long options equivalent to -X xxx. */ + case 0: break; -#endif + default: fprintf(stderr, _("Try '%s --help' for more information.\n"), progname); exit(1); @@ -658,26 +649,16 @@ help(const char *progname) printf(_(" %s [OPTION]... [DBNAME]\n"), progname); printf(_("\nGeneral options:\n")); -#ifdef HAVE_GETOPT_LONG printf(_(" -f, --file=FILENAME output file name\n")); printf(_(" -F, --format=c|t|p output file format (custom, tar, plain text)\n")); printf(_(" -i, --ignore-version proceed even when server version mismatches\n" " pg_dump version\n")); printf(_(" -v, --verbose verbose mode\n")); printf(_(" -Z, --compress=0-9 compression level for compressed formats\n")); -#else /* not HAVE_GETOPT_LONG */ - printf(_(" -f FILENAME output file name\n")); - printf(_(" -F c|t|p output file format (custom, tar, plain text)\n")); - printf(_(" -i proceed even when server version mismatches\n" - " pg_dump version\n")); - printf(_(" -v verbose mode\n")); - printf(_(" -Z 0-9 compression level for compressed formats\n")); -#endif /* not HAVE_GETOPT_LONG */ printf(_(" --help show this help, then exit\n")); printf(_(" --version output version information, then exit\n")); printf(_("\nOptions controlling the output content:\n")); -#ifdef HAVE_GETOPT_LONG printf(_(" -a, --data-only dump only the data, not the schema\n")); printf(_(" -b, --blobs include large objects in dump\n")); printf(_(" -c, --clean clean (drop) schema prior to create\n")); @@ -699,41 +680,12 @@ help(const char *progname) " than \\connect commands\n")); printf(_(" -X disable-triggers, --disable-triggers\n" " disable triggers during data-only restore\n")); -#else /* not HAVE_GETOPT_LONG */ - printf(_(" -a dump only the data, not the schema\n")); - printf(_(" -b include large objects in dump\n")); - printf(_(" -c clean (drop) schema prior to create\n")); - printf(_(" -C include commands to create database in dump\n")); - printf(_(" -d dump data as INSERT, rather than COPY, commands\n")); - printf(_(" -D dump data as INSERT commands with column names\n")); - printf(_(" -o include OIDs in dump\n")); - printf(_(" -O do not output \\connect commands in plain\n" - " text format\n")); - printf(_(" -R disable ALL reconnections to the database in\n" - " plain text format\n")); - printf(_(" -s dump only the schema, no data\n")); - printf(_(" -S NAME specify the superuser user name to use in\n" - " plain text format\n")); - printf(_(" -t TABLE dump this table only (* for all)\n")); - printf(_(" -x do not dump privileges (grant/revoke)\n")); - printf(_(" -X use-set-session-authorization\n" - " output SET SESSION AUTHORIZATION commands rather\n" - " than \\connect commands\n")); - printf(_(" -X disable-triggers disable triggers during data-only restore\n")); -#endif /* not HAVE_GETOPT_LONG */ printf(_("\nConnection options:\n")); -#ifdef HAVE_GETOPT_LONG printf(_(" -h, --host=HOSTNAME database server host name\n")); printf(_(" -p, --port=PORT database server port number\n")); printf(_(" -U, --username=NAME connect as specified database user\n")); printf(_(" -W, --password force password prompt (should happen automatically)\n")); -#else /* not HAVE_GETOPT_LONG */ - printf(_(" -h HOSTNAME database server host name\n")); - printf(_(" -p PORT database server port number\n")); - printf(_(" -U NAME connect as specified database user\n")); - printf(_(" -W force password prompt (should happen automatically)\n")); -#endif /* not HAVE_GETOPT_LONG */ printf(_("\nIf no database name is not supplied, then the PGDATABASE environment\n" "variable value is used.\n\n")); diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index c3a76923740..ebea128a45c 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.11 2002/11/29 16:38:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.12 2003/01/06 18:53:25 petere Exp $ * *------------------------------------------------------------------------- */ @@ -25,6 +25,11 @@ #endif #include <errno.h> +#ifndef HAVE_GETOPT_LONG +#include "getopt_long.h" +int optreset; +#endif + #include "dumputils.h" #include "libpq-fe.h" #include "pg_backup.h" @@ -71,7 +76,6 @@ main(int argc, char *argv[]) PGconn *conn; int c; -#ifdef HAVE_GETOPT_LONG static struct option long_options[] = { {"clean", no_argument, NULL, 'c'}, {"inserts", no_argument, NULL, 'd'}, @@ -88,7 +92,6 @@ main(int argc, char *argv[]) }; int optindex; -#endif #ifdef ENABLE_NLS setlocale(LC_ALL, ""); @@ -118,11 +121,7 @@ main(int argc, char *argv[]) pgdumploc = findPgDump(argv[0]); pgdumpopts = createPQExpBuffer(); -#ifdef HAVE_GETOPT_LONG while ((c = getopt_long(argc, argv, "cdDgh:iop:U:vW", long_options, &optindex)) != -1) -#else - while ((c = getopt(argc, argv, "cdDgh:iop:U:vW")) != -1) -#endif { switch (c) { @@ -216,7 +215,6 @@ help(void) printf(_(" %s [OPTION]...\n"), progname); printf(_("\nOptions:\n")); -#ifdef HAVE_GETOPT_LONG printf(_(" -c, --clean clean (drop) databases prior to create\n")); printf(_(" -d, --inserts dump data as INSERT, rather than COPY, commands\n")); printf(_(" -D, --column-inserts dump data as INSERT commands with column names\n")); @@ -225,31 +223,14 @@ help(void) " pg_dumpall version\n")); printf(_(" -o, --oids include OIDs in dump\n")); printf(_(" -v, --verbose verbose mode\n")); -#else /* not HAVE_GETOPT_LONG */ - printf(_(" -c clean (drop) databases prior to create\n")); - printf(_(" -d dump data as INSERT, rather than COPY, commands\n")); - printf(_(" -D dump data as INSERT commands with column names\n")); - printf(_(" -g dump only global objects, no databases\n")); - printf(_(" -i proceed even when server version mismatches\n" - " pg_dumpall version\n")); - printf(_(" -o include OIDs in dump\n")); - printf(_(" -v verbose mode\n")); -#endif /* not HAVE_GETOPT_LONG */ printf(_(" --help show this help, then exit\n")); printf(_(" --version output version information, then exit\n")); printf(_("\nConnection options:\n")); -#ifdef HAVE_GETOPT_LONG printf(_(" -h, --host=HOSTNAME database server host name\n")); printf(_(" -p, --port=PORT database server port number\n")); printf(_(" -U, --username=NAME connect as specified database user\n")); printf(_(" -W, --password force password prompt (should happen automatically)\n")); -#else /* not HAVE_GETOPT_LONG */ - printf(_(" -h HOSTNAME database server host name\n")); - printf(_(" -p PORT database server port number\n")); - printf(_(" -U NAME connect as specified database user\n")); - printf(_(" -W force password prompt (should happen automatically)\n")); -#endif /* not HAVE_GETOPT_LONG */ printf(_("\nThe SQL script will be written to the standard output.\n\n")); printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n")); diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 46a3ee8b2e9..fe1471ff99e 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -34,7 +34,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.43 2002/10/18 22:05:36 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.44 2003/01/06 18:53:25 petere Exp $ * *------------------------------------------------------------------------- */ @@ -59,6 +59,11 @@ #include <getopt.h> #endif +#ifndef HAVE_GETOPT_LONG +#include "getopt_long.h" +int optreset; +#endif + #ifdef ENABLE_NLS #include <locale.h> #endif @@ -85,7 +90,6 @@ main(int argc, char **argv) static int use_setsessauth = 0; static int disable_triggers = 0; -#ifdef HAVE_GETOPT_LONG struct option cmdopts[] = { {"clean", 0, NULL, 'c'}, {"create", 0, NULL, 'C'}, @@ -124,8 +128,6 @@ main(int argc, char **argv) {NULL, 0, NULL, 0} }; -#endif /* HAVE_GETOPT_LONG */ - #ifdef ENABLE_NLS setlocale(LC_ALL, ""); @@ -154,11 +156,8 @@ main(int argc, char **argv) } } -#ifdef HAVE_GETOPT_LONG - while ((c = getopt_long(argc, argv, "acCd:f:F:h:iI:lL:NoOp:P:rRsS:t:T:uU:vWxX:", cmdopts, NULL)) != -1) -#else - while ((c = getopt(argc, argv, "acCd:f:F:h:iI:lL:NoOp:P:rRsS:t:T:uU:vWxX:")) != -1) -#endif + while ((c = getopt_long(argc, argv, "acCd:f:F:h:iI:lL:NoOp:P:rRsS:t:T:uU:vWxX:", + cmdopts, NULL)) != -1) { switch (c) { @@ -285,11 +284,9 @@ main(int argc, char **argv) } break; -#ifdef HAVE_GETOPT_LONG /* This covers the long options equivalent to -X xxx. */ case 0: break; -#endif default: fprintf(stderr, _("Try '%s --help' for more information.\n"), progname); @@ -378,26 +375,16 @@ usage(const char *progname) printf(_(" %s [OPTION]... [FILE]\n"), progname); printf(_("\nGeneral options:\n")); -#ifdef HAVE_GETOPT_LONG printf(_(" -d, --dbname=NAME output database name\n")); printf(_(" -f, --file=FILENAME output file name\n")); printf(_(" -F, --format=c|t specify backup file format\n")); printf(_(" -i, --ignore-version proceed even when server version mismatches\n")); printf(_(" -l, --list print summarized TOC of the archive\n")); printf(_(" -v, --verbose verbose mode\n")); -#else /* not HAVE_GETOPT_LONG */ - printf(_(" -d NAME output database name\n")); - printf(_(" -f FILENAME output file name\n")); - printf(_(" -F c|t specify backup file format\n")); - printf(_(" -i proceed even when server version mismatches\n")); - printf(_(" -l print summarized TOC of the archive\n")); - printf(_(" -v verbose mode\n")); -#endif /* not HAVE_GETOPT_LONG */ printf(_(" --help show this help, then exit\n")); printf(_(" --version output version information, then exit\n")); printf(_("\nOptions controlling the output content:\n")); -#ifdef HAVE_GETOPT_LONG printf(_(" -a, --data-only restore only the data, no schema\n")); printf(_(" -c, --clean clean (drop) schema prior to create\n")); printf(_(" -C, --create issue commands to create the database\n")); @@ -423,44 +410,12 @@ usage(const char *progname) " of reconnecting, if possible\n")); printf(_(" -X disable-triggers, --disable-triggers\n" " disable triggers during data-only restore\n")); -#else /* not HAVE_GETOPT_LONG */ - printf(_(" -a restore only the data, no schema\n")); - printf(_(" -c clean (drop) schema prior to create\n")); - printf(_(" -C issue commands to create the database\n")); - printf(_(" -I NAME restore named index\n")); - printf(_(" -L FILENAME use specified table of contents for ordering\n" - " output from this file\n")); - printf(_(" -N restore in original dump order\n")); - printf(_(" -o restore in OID order\n")); - printf(_(" -O do not reconnect to database to match\n" - " object owner\n")); - printf(_(" -P NAME(args) restore named function\n")); - printf(_(" -r rearrange output to put indexes etc. at end\n")); - printf(_(" -R disallow ALL reconnections to the database\n")); - printf(_(" -s restore only the schema, no data\n")); - printf(_(" -S NAME specify the superuser user name to use for\n" - " disabling triggers\n")); - printf(_(" -t NAME restore named table\n")); - printf(_(" -T NAME restore named trigger\n")); - printf(_(" -x skip restoration of access privileges (grant/revoke)\n")); - printf(_(" -X use-set-session-authorization\n" - " use SET SESSION AUTHORIZATION commands instead\n" - " of reconnecting, if possible\n")); - printf(_(" -X disable-triggers disable triggers during data-only restore\n")); -#endif /* not HAVE_GETOPT_LONG */ printf(_("\nConnection options:\n")); -#ifdef HAVE_GETOPT_LONG printf(_(" -h, --host=HOSTNAME database server host name\n")); printf(_(" -p, --port=PORT database server port number\n")); printf(_(" -U, --username=NAME connect as specified database user\n")); printf(_(" -W, --password force password prompt (should happen automatically)\n")); -#else /* not HAVE_GETOPT_LONG */ - printf(_(" -h HOSTNAME database server host name\n")); - printf(_(" -p PORT database server port number\n")); - printf(_(" -U NAME connect as specified database user\n")); - printf(_(" -W force password prompt (should happen automatically)\n")); -#endif /* not HAVE_GETOPT_LONG */ printf(_("\nIf no input file name is supplied, then standard input is used.\n\n")); printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n")); |