Index: dumputils.h =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_dump/dumputils.h,v retrieving revision 1.4 diff -c -r1.4 dumputils.h *** dumputils.h 2002/09/07 16:14:33 1.4 --- dumputils.h 2003/01/02 22:41:20 *************** *** 24,27 **** --- 24,46 ---- extern void appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll); extern int parse_version(const char *versionString); + /* + * A way to avoid duplicate option descritions for + * both, short and long versions. E.g. of usage in a tool: + * + * xo(_(" -f, --file=FILENAME "), + * _(" -f FILENAME "), + * _("output file name\n" + * " more description")); + * + * ('xo' stands for eXplain Option) + * + * Used by pg_dump, pg_dumpall, and pg_restore + */ + #if defined(HAVE_GETOPT_LONG) + # define xo(longOption,shortOption,desc) printf("%s %s\n", longOption, desc) + #else + # define xo(longOption,shortOption,desc) printf("%s %s\n", shortOption, desc) + #endif + #endif /* DUMPUTILS_H */ Index: pg_dump.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_dump/pg_dump.c,v retrieving revision 1.313 diff -c -r1.313 pg_dump.c *** pg_dump.c 2002/12/27 17:10:45 1.313 --- pg_dump.c 2003/01/02 22:41:27 *************** *** 650,655 **** --- 650,659 ---- } + /* + * help: displays pg_dump's usage instructions + * NOTE: xo macro defined in dumputils.h + */ static void help(const char *progname) { *************** *** 657,745 **** printf(_("Usage:\n")); 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")); ! printf(_(" -C, --create include commands to create database in dump\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")); ! printf(_(" -o, --oids include OIDs in dump\n")); ! printf(_(" -O, --no-owner do not output \\connect commands in plain\n" ! " text format\n")); ! printf(_(" -R, --no-reconnect disable ALL reconnections to the database in\n" ! " plain text format\n")); ! printf(_(" -s, --schema-only dump only the schema, no data\n")); ! printf(_(" -S, --superuser=NAME specify the superuser user name to use in\n" ! " plain text format\n")); ! printf(_(" -t, --table=TABLE dump this table only (* for all)\n")); ! printf(_(" -x, --no-privileges do not dump privileges (grant/revoke)\n")); ! printf(_(" -X use-set-session-authorization, --use-set-session-authorization\n" ! " output SET SESSION AUTHORIZATION commands rather\n" ! " 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")); printf(_("Report bugs to .\n")); } void exit_nicely(void) { --- 661,800 ---- printf(_("Usage:\n")); printf(_(" %s [OPTION]... [DBNAME]\n"), progname); + /* General Options */ + printf(_("\nGeneral options:\n")); + xo(_(" -f, --file=FILENAME "), + _(" -f FILENAME "), + _("output file name")); + + xo(_(" -F, --format=c|t|p "), + _(" -F c|t|p "), + _("output file format (custom, tar, plain text)")); + + xo(_(" -i, --ignore-version "), + _(" -i "), + _("proceed even when server version mismatches\n" + " pg_dump version")); + + xo(_(" -v, --verbose "), + _(" -v "), + _("verbose mode")); + + xo(_(" -Z, --compress=0-9 "), + _(" -Z 0-9 "), + _("compression level for compressed formats")); + + xo(_(" --help "), + _(" --help "), + _("show this help, then exit")); + + xo(_(" --version "), + _(" --version "), + _("output version information, then exit")); + + + /* Output Options */ + printf(_("\nOptions controlling the output content:\n")); ! ! xo(_(" -a, --data-only "), ! _(" -a "), ! _("dump only the data, not the schema")); ! ! xo(_(" -b, --blobs "), ! _(" -b "), ! _("include large objects in dump")); ! ! xo(_(" -c, --clean "), ! _(" -c "), ! _("clean (drop) schema prior to create")); ! ! xo(_(" -C, --create "), ! _(" -C "), ! _("include commands to create database in dump")); ! ! xo(_(" -d, --inserts "), ! _(" -d "), ! _("dump data as INSERT, rather than COPY, commands")); ! ! xo(_(" -D, --column-inserts "), ! _(" -D "), ! _("dump data as INSERT commands with column names")); ! ! xo(_(" -o, --oids "), ! _(" -o "), ! _("include OIDs in dump")); ! ! xo(_(" -O, --no-owner "), ! _(" -O "), ! _("do not output \\connect commands in plain\n" ! " text format")); ! ! xo(_(" -R, --no-reconnect "), ! _(" -R "), ! _("disable ALL reconnections to the database in\n" ! " plain text format")); ! ! xo(_(" -s, --schema-only "), ! _(" -s "), ! _("dump only the schema, no data")); ! ! xo(_(" -S, --superuser=NAME "), ! _(" -S NAME "), ! _("specify the superuser user name to use in\n" ! " plain text format")); ! ! xo(_(" -t, --table=TABLE "), ! _(" -t TABLE "), ! _("dump this table only (* for all)")); ! ! xo(_(" -x, --no-privileges "), ! _(" -x "), ! _("do not dump privileges (grant/revoke)")); ! ! xo(_(" -X use-set-session-authorization, --use-set-session-authorization"), ! _(" -X use-set-session-authorization"), ! _("\n" ! " output SET SESSION AUTHORIZATION commands rather\n" ! " than \\connect commands")); ! ! xo(_(" -X disable-triggers, --disable-triggers"), ! _(" -X disable-triggers "), ! _("\n" ! " disable triggers during data-only restore")); ! ! ! /* Connection Options */ printf(_("\nConnection options:\n")); + xo(_(" -h, --host=HOSTNAME "), + _(" -h HOSTNAME "), + _("database server host name")); + + xo(_(" -p, --port=PORT "), + _(" -p PORT "), + _("database server port number")); + + xo(_(" -U, --username=NAME "), + _(" -U NAME "), + _("connect as specified database user")); + + xo(_(" -W, --password "), + _(" -W "), + _("force password prompt (should happen automatically)")); + + printf(_("\nIf no database name is not supplied, then the PGDATABASE environment\n" "variable value is used.\n\n")); printf(_("Report bugs to .\n")); } + /* + * exit_nicely: graceful exit in case of error + */ void exit_nicely(void) { *************** *** 3267,3273 **** appendPQExpBuffer(q, "\n\tCONSTRAINT %s CHECK %s", fmtId(conname), consrc); } ! appendPQExpBuffer(q, ";\n"); (*deps)[depIdx++] = NULL; /* End of List */ --- 3322,3328 ---- appendPQExpBuffer(q, "\n\tCONSTRAINT %s CHECK %s", fmtId(conname), consrc); } ! appendPQExpBuffer(q, ";\n"); (*deps)[depIdx++] = NULL; /* End of List */ Index: pg_dumpall.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_dump/pg_dumpall.c,v retrieving revision 1.11 diff -c -r1.11 pg_dumpall.c *** pg_dumpall.c 2002/11/29 16:38:42 1.11 --- pg_dumpall.c 2003/01/02 22:41:27 *************** *** 207,213 **** } ! static void help(void) { --- 207,216 ---- } ! /* ! * help: displays pg_dumpall's usage instructions ! * NOTE: xo macro defined in dumputils.h ! */ static void help(void) { *************** *** 216,255 **** 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")); - printf(_(" -g, --globals-only dump only global objects, no databases\n")); - printf(_(" -i, --ignore-version proceed even when server version mismatches\n" - " 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 .\n")); --- 219,279 ---- printf(_(" %s [OPTION]...\n"), progname); printf(_("\nOptions:\n")); + xo(_(" -c, --clean "), + _(" -c "), + _("clean (drop) databases prior to create\n")); + + xo(_(" -d, --inserts "), + _(" -d "), + _("dump data as INSERT, rather than COPY, commands")); + + xo(_(" -D, --column-inserts "), + _(" -D "), + _("dump data as INSERT commands with column names")); + + xo(_(" -g, --globals-only "), + _(" -g "), + _("dump only global objects, no databases")); + + xo(_(" -i, --ignore-version "), + _(" -i "), + _("proceed even when server version mismatches\n" + " pg_dumpall version")); + + xo(_(" -o, --oids "), + _(" -o "), + _("include OIDs in dump")); + + xo(_(" -v, --verbose "), + _(" -v "), + _("verbose mode")); + + xo(_(" --help "), + _(" --help "), + _("show this help, then exit")); + + xo(_(" --version "), + _(" --version "), + _("output version information, then exit")); + printf(_("\nConnection options:\n")); ! ! xo(_(" -h, --host=HOSTNAME "), ! _(" -h HOSTNAME "), ! _("database server host name")); ! ! xo(_(" -p, --port=PORT "), ! _(" -p PORT "), ! _("database server port number")); ! ! xo(_(" -U, --username=NAME "), ! _(" -U NAME "), ! _("connect as specified database user")); ! ! xo(_(" -W, --password "), ! _(" -W "), ! _("force password prompt (should happen automatically)")); printf(_("\nThe SQL script will be written to the standard output.\n\n")); printf(_("Report bugs to .\n")); Index: pg_restore.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_dump/pg_restore.c,v retrieving revision 1.43 diff -c -r1.43 pg_restore.c *** pg_restore.c 2002/10/18 22:05:36 1.43 --- pg_restore.c 2003/01/02 22:41:28 *************** *** 370,375 **** --- 370,380 ---- return 0; } + + /* + * usage: displays pg_restore's usage instructions + * NOTE: xo macro defined in dumputils.h + */ static void usage(const char *progname) { *************** *** 378,466 **** 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")); - printf(_(" -I, --index=NAME restore named index\n")); - printf(_(" -L, --use-list=FILENAME use specified table of contents for ordering\n" - " output from this file\n")); - printf(_(" -N, --orig-order restore in original dump order\n")); - printf(_(" -o, --oid-order restore in OID order\n")); - printf(_(" -O, --no-owner do not reconnect to database to match\n" - " object owner\n")); - printf(_(" -P, --function=NAME(args)\n" - " restore named function\n")); - printf(_(" -r, --rearrange rearrange output to put indexes etc. at end\n")); - printf(_(" -R, --no-reconnect disallow ALL reconnections to the database\n")); - printf(_(" -s, --schema-only restore only the schema, no data\n")); - printf(_(" -S, --superuser=NAME specify the superuser user name to use for\n" - " disabling triggers\n")); - printf(_(" -t, --table=NAME restore named table\n")); - printf(_(" -T, --trigger=NAME restore named trigger\n")); - printf(_(" -x, --no-privileges skip restoration of access privileges (grant/revoke)\n")); - printf(_(" -X use-set-session-authorization, --use-set-session-authorization\n" - " use SET SESSION AUTHORIZATION commands instead\n" - " 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 .\n")); --- 383,521 ---- printf(_(" %s [OPTION]... [FILE]\n"), progname); printf(_("\nGeneral options:\n")); ! ! xo(_(" -d, --dbname=NAME "), ! _(" -d NAME "), ! _("output database name")); ! ! xo(_(" -f, --file=FILENAME "), ! _(" -f FILENAME "), ! _("output file name")); ! ! xo(_(" -F, --format=c|t "), ! _(" -F c|t "), ! _("specify backup file format")); ! ! xo(_(" -i, --ignore-version "), ! _(" -i "), ! _("proceed even when server version mismatches")); ! ! xo(_(" -l, --list "), ! _(" -l "), ! _("print summarized TOC of the archive")); ! ! xo(_(" -v, --verbose "), ! _(" -v "), ! _("verbose mode")); ! ! xo(_(" --help "), ! _(" --help "), ! _("show this help, then exit")); ! ! xo(_(" --version "), ! _(" --version "), ! _("output version information, then exit")); printf(_("\nOptions controlling the output content:\n")); + xo(_(" -a, --data-only "), + _(" -a "), + _("restore only the data, no schema")); + + xo(_(" -c, --clean "), + _(" -c "), + _("clean (drop) schema prior to create")); + + xo(_(" -C, --create "), + _(" -C "), + _("issue commands to create the database")); + + xo(_(" -I, --index=NAME "), + _(" -I NAME "), + _("restore named index")); + + xo(_(" -L, --use-list=FILENAME "), + _(" -L FILENAME "), + _("use specified table of contents for ordering\n" + " output from this file")); + xo(_(" -N, --orig-order "), + _(" -N "), + _("restore in original dump order\n")); + + xo(_(" -o, --oid-order "), + _(" -o "), + _("restore in OID order")); + + xo(_(" -O, --no-owner "), + _(" -O "), + _("do not reconnect to database to match\n" + " object owner")); + + xo(_(" -P, --function=NAME(args)\n "), + _(" -P NAME(args) "), + _("restore named function")); + + xo(_(" -r, --rearrange "), + _(" -r "), + _("rearrange output to put indexes etc. at end")); + + + xo(_(" -R, --no-reconnect "), + _(" -R "), + _("disallow ALL reconnections to the database")); + + xo(_(" -s, --schema-only "), + _(" -s "), + _("restore only the schema, no data")); + + xo(_(" -S, --superuser=NAME "), + _(" -S NAME "), + _("specify the superuser user name to use for\n" + " disabling triggers")); + + xo(_(" -t, --table=TABLE "), + _(" -t TABLE "), + _("restore named table")); + + xo(_(" -T, --trigger=NAME "), + _(" -T NAME "), + _("restore named trigger")); + + xo(_(" -x, --no-privileges "), + _(" -x "), + _("skip restoration of access privileges (grant/revoke)")); + + xo(_(" -X use-set-session-authorization, --use-set-session-authorization"), + _(" -X use-set-session-authorization"), + _("\n" + " use SET SESSION AUTHORIZATION commands instead\n" + " of reconnecting, if possible")); + + xo(_(" -X disable-triggers, --disable-triggers"), + _(" -X disable-triggers "), + _("\n" + " disable triggers during data-only restore")); + + printf(_("\nConnection options:\n")); ! ! ! xo(_(" -h, --host=HOSTNAME "), ! _(" -h HOSTNAME "), ! _("database server host name")); ! ! xo(_(" -U, --username=NAME "), ! _(" -U NAME "), ! _("connect as specified database user")); ! ! xo(_(" -p, --port=PORT "), ! _(" -p PORT "), ! _("database server port number")); ! ! xo(_(" -W, --password "), ! _(" -W "), ! _("force password prompt (should happen automatically)")); ! printf(_("\nIf no input file name is supplied, then standard input is used.\n\n")); printf(_("Report bugs to .\n"));