pg_dump.options.diff
Hello,
Happy New Year everyone,
Attached is an attempt to eliminate duplicate pg_dump
option descriptions, and have a single description for both
short and long options. For me, as for a translator, this
eliminates the need to maintain the two, exactly same, sets of
24 sentences.
If this is accepted, using the same approach I'll go through pg_dumpall
and other tools, which suffer from the same exact problem.
If it's rejected, please advise of a better way to approach
the problem.
Needless to say, it is a pain for a translator to
properly maintain the two sets of messages for every tool PG got.
After all that is settled, I'll send translation patches in.
Thank you,
-s
pg_dump.options.diff
Attachments:
pg_dump.options.diffapplication/octet-stream; name=pg_dump.options.diffDownload
? pg_dump.options.diff
? po/cs.mo
? po/de.mo
? po/ru.mo
? po/sv.mo
? po/zh_CN.mo
? po/zh_TW.mo
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 05:42:30
***************
*** 650,745 ****
}
static void
help(const char *progname)
{
printf(_("%s dumps a database as a text file or to other formats.\n\n"), progname);
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 <pgsql-bugs@postgresql.org>.\n"));
}
void
exit_nicely(void)
{
--- 650,798 ----
}
+ /*
+ * help: displays pg_dump's usage options
+ */
static void
help(const char *progname)
{
+ char* SPACES = " ";
+
printf(_("%s dumps a database as a text file or to other formats.\n\n"), progname);
printf(_("Usage:\n"));
printf(_(" %s [OPTION]... [DBNAME]\n"), progname);
+ /* General Options */
+
printf(_("\nGeneral options:\n"));
+
#ifdef HAVE_GETOPT_LONG
!
! char* f_LONG = _(", --file=FILENAME ");
! char* F_LONG = _(", --format=c|t|p ");
! char* i_LONG = _(", --ignore-version ");
! char* v_LONG = _(", --verbose ");
! char* Z_LONG = _(", --compress=0-9 ");
!
#else /* not HAVE_GETOPT_LONG */
!
! char* f_LONG = _(" FILENAME ");
! char* F_LONG = _(" c|t|p ");
! char* i_LONG = SPACES;
! char* v_LONG = SPACES;
! char* Z_LONG = _(" 0-9 ");
!
#endif /* not HAVE_GETOPT_LONG */
+
+ printf(_(" -f%s output file name\n"), f_LONG);
+ printf(_(" -F%s output file format (custom, tar, plain text)\n"), F_LONG);
+ printf(_(" -i%s proceed even when server version mismatches\n"
+ " %s pg_dump version\n"), i_LONG, SPACES);
+ printf(_(" -v%s verbose mode\n"), v_LONG);
+ printf(_(" -Z%s compression level for compressed formats\n"), Z_LONG);
+
+
printf(_(" --help show this help, then exit\n"));
printf(_(" --version output version information, then exit\n"));
+
+ /* Output Options */
+
printf(_("\nOptions controlling the output content:\n"));
+
#ifdef HAVE_GETOPT_LONG
!
! char* a_LONG = _(", --data-only ");
! char* b_LONG = _(", --blobs ");
! char* c_LONG = _(", --clean ");
! char* C_LONG = _(", --create ");
! char* d_LONG = _(", --inserts ");
! char* D_LONG = _(", --column-inserts ");
! char* o_LONG = _(", --oids ");
! char* O_LONG = _(", --no-owner ");
! char* R_LONG = _(", --no-reconnect ");
! char* s_LONG = _(", --schema-only ");
! char* S_LONG = _(", --superuser=NAME ");
! char* t_LONG = _(", --table=TABLE ");
! char* x_LONG = _(", --no-privileges ");
! char* X1_LONG = _(" use-set-session-authorization, --use-set-session-authorization");
! char* X2_LONG = _(" disable-triggers, --disable-triggers");
!
#else /* not HAVE_GETOPT_LONG */
!
! char* a_LONG = SPACES;
! char* b_LONG = SPACES;
! char* c_LONG = SPACES;
! char* C_LONG = SPACES;
! char* d_LONG = SPACES;
! char* D_LONG = SPACES;
! char* o_LONG = SPACES;
! char* O_LONG = SPACES;
! char* R_LONG = SPACES;
! char* s_LONG = SPACES;
! char* S_LONG = _(" NAME ");
! char* t_LONG = _(" TABLE ");
! char* x_LONG = SPACES;
! char* X1_LONG = _(" use-set-session-authorization");
! char* X2_LONG = _(" disable-triggers");
!
#endif /* not HAVE_GETOPT_LONG */
+ printf(_(" -a%s dump only the data, not the schema\n"), a_LONG);
+ printf(_(" -b%s include large objects in dump\n"), b_LONG);
+ printf(_(" -c%s clean (drop) schema prior to create\n"), c_LONG);
+ printf(_(" -C%s include commands to create database in dump\n"), C_LONG);
+ printf(_(" -d%s dump data as INSERT, rather than COPY, commands\n"), d_LONG);
+ printf(_(" -D%s dump data as INSERT commands with column names\n"), D_LONG);
+ printf(_(" -o%s include OIDs in dump\n"), o_LONG);
+ printf(_(" -O%s do not output \\connect commands in plain\n"
+ " %s text format\n"), O_LONG, SPACES);
+ printf(_(" -R%s disable ALL reconnections to the database in\n"
+ " %s plain text format\n"), R_LONG, SPACES);
+ printf(_(" -s%s dump only the schema, no data\n"), s_LONG);
+ printf(_(" -S%s specify the superuser user name to use in\n"
+ " %s plain text format\n"), S_LONG, SPACES);
+ printf(_(" -t%s dump this table only (* for all)\n"), t_LONG);
+ printf(_(" -x%s do not dump privileges (grant/revoke)\n"), x_LONG);
+ printf(_(" -X%s \n"
+ " %s output SET SESSION AUTHORIZATION commands rather\n"
+ " %s than \\connect commands\n"), X1_LONG, SPACES, SPACES);
+ printf(_(" -X%s \n"
+ " %s disable triggers during data-only restore\n"), X2_LONG, SPACES);
+
+ /* Connection Options */
+
printf(_("\nConnection options:\n"));
+
#ifdef HAVE_GETOPT_LONG
!
! char* h_LONG = _(", --host=HOSTNAME ");
! char* p_LONG = _(", --port=PORT ");
! char* U_LONG = _(", --username=NAME ");
! char* W_LONG = _(", --password ");
!
#else /* not HAVE_GETOPT_LONG */
!
! char* h_LONG = _(" HOSTNAME ");
! char* p_LONG = _(" PORT ");
! char* U_LONG = _(" NAME ");
! char* W_LONG = SPACES;
!
#endif /* not HAVE_GETOPT_LONG */
+ printf(_(" -h%s database server host name\n"), h_LONG);
+ printf(_(" -p%s database server port number\n"), p_LONG);
+ printf(_(" -U%s connect as specified database user\n"), U_LONG);
+ printf(_(" -W%s force password prompt (should happen automatically)\n"), W_LONG);
+
printf(_("\nIf no database name is not supplied, then the PGDATABASE environment\n"
"variable value is used.\n\n"));
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\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 */
--- 3320,3326 ----
appendPQExpBuffer(q, "\n\tCONSTRAINT %s CHECK %s",
fmtId(conname), consrc);
}
!
appendPQExpBuffer(q, ";\n");
(*deps)[depIdx++] = NULL; /* End of List */
"Serguei Mokhov" <mokhov@cs.concordia.ca> writes:
Attached is an attempt to eliminate duplicate pg_dump
option descriptions, and have a single description for both
short and long options. For me, as for a translator, this
eliminates the need to maintain the two, exactly same, sets of
24 sentences.
Offhand, this cure strikes me as much worse than the disease. You've
converted code which was understandable, if somewhat repetitious, into
code that can be understood by neither programmers nor translators.
The text strings have been broken into fragments that don't make any
sense individually --- which probably creates translating problems,
as well as opportunities for programmer error.
I see your complaint, but this doesn't seem like a good way to fix it.
Perhaps it would work better to do something like
#ifdef HAVE_GETOPT_LONG
char* f_option = _("-f, --file=FILENAME ");
... etc ...
#else /* not HAVE_GETOPT_LONG */
char* f_option = _("-f FILENAME ");
... etc ...
#endif /* not HAVE_GETOPT_LONG */
printf(_(" %s output file name\n"), f_option);
... etc ...
That seems to reduce the amount of duplication without breaking things
up into chunks that aren't independent concepts.
However, I'm not convinced that the above is better than what we have
--- it's really not obvious that the above is more maintainable than
#ifdef HAVE_GETOPT_LONG
printf(_(" -f, --file=FILENAME output file name\n"));
#else /* not HAVE_GETOPT_LONG */
printf(_(" -f FILENAME output file name\n"));
#endif /* not HAVE_GETOPT_LONG */
There are worse things than a little repetitiveness, and creating
the opportunity to mismatch a flag with its description may well
be one of them.
Comments? Can anyone do better?
regards, tom lane
----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
Sent: January 02, 2003 1:34 AM
Perhaps it would work better to do something like
#ifdef HAVE_GETOPT_LONG
char* f_option = _("-f, --file=FILENAME ");
... etc ...
#else /* not HAVE_GETOPT_LONG */
char* f_option = _("-f FILENAME ");
... etc ...
#endif /* not HAVE_GETOPT_LONG */printf(_(" %s output file name\n"), f_option);
... etc ...That seems to reduce the amount of duplication without breaking things
up into chunks that aren't independent concepts.
Thank you for your comment, Tom.
A slightly more readable version of the above could be:
#ifdef HAVE_GETOPT_LONG
char* data_only_option = _("-f, --file=FILENAME ");
char* blobs_option = _("-b, --blobs ");
... etc ...
#else /* not HAVE_GETOPT_LONG */
char* data_only_option = _("-f FILENAME ");
char* blobs_option = _("-b ");
... etc ...
#endif /* not HAVE_GETOPT_LONG */printf(_(" %s output file name\n"), data_only_option);
printf(_(" %s include large objects in dump\n"), blobs_option);
... etc ...
It loos like better than the current setup.
Either way, something has to be donw about this...
-s
On Thu, 2 Jan 2003 01:44:21 -0500, "Serguei Mokhov" <mokhov@cs.concordia.ca> wrote:
Either way, something has to be donw about this...
Just another way to do it:
#if defined(HAVE_GETOPT_LONG)
#define PARMPREFIX '='
#else
#define PARMPREFIX ' '
#endif
static void
explain_option(char *shortform, char *longform, char *parm, char *desc)
{
int pos = 0;
printf(" -%s", shortform);
pos += 3 + strlen(shortform);
#if defined(HAVE_GETOPT_LONG)
printf(", --%s", longform);
pos += 4 + strlen(longform);
#endif
if (parm) {
printf("%c%s", PARMPREFIX, parm);
pos += 1 + strlen(parm);
}/*if*/
printf("%*c", 27 - pos, ' ');
printf("%s\n", desc);
}/*explain_option*/
#define xo explain_option
xo("f", "file", "FILENAME", "output file name");
xo("F", "format", "c|t|p", "output file format (custom, tar, plain text)");
xo("i", "ignore-version", NULL, "proceed even when server version mismatches\n"
" pg_dump version");
xo("v", "verbose", NULL, "verbose mode");
xo("Z", "compress", "0-9", "compression level for compressed formats");
This is only a quick hack, I didn't care for _() and
explain_option() could be smarter about multi line descriptions,
but you get the idea ...
Servus
Manfred
Hi all,
I have come across some weird behavior in postgres concerning autocommit=off
and setting the transaction isolation level. I have no explanation why
things should work as they do, so I consider this a bug, no?
With autocommit=on and normal begin; ... commit; block setting the
transaction isolation level works fine:
billing=# begin;
BEGIN
billing=# set transaction isolation level serializable;
SET
billing=# show transaction isolation level;
TRANSACTION ISOLATION LEVEL
-----------------------------
SERIALIZABLE
(1 row)
billing=# commit;
COMMIT
Now setting autocommit=off the set transaction isolation level command does
not show any effect:
billing=# set autocommit to off;
SET
billing=# set transaction isolation level serializable;
SET
billing=# select current_date;
date
------------
2003-01-02
(1 row)
billing=# show transaction isolation level;
TRANSACTION ISOLATION LEVEL
-----------------------------
READ COMMITTED <---- this should be SERIALIZABLE, no??
(1 row)
billing=# commit;
COMMIT
Is it a bug?
Regards,
Michael Paesold
Manfred Koizar <mkoi-pg@aon.at> writes:
Just another way to do it:
#define xo explain_option
xo("f", "file", "FILENAME", "output file name");
Perhaps better would be:
#if defined(HAVE_GETOPT_LONG)
#define xo(long,short,desc) printf("%-27s %s\n", long, desc)
#else
#define xo(long,short,desc) printf("%-27s %s\n", short, desc)
#endif
xo(_("-f, --file=FILENAME"),
_("-f FILENAME"),
_("output file name"));
which avoids putting a lot of "smarts" (read: restrictions) into the
subroutine, but still keeps most of the other benefits, including:
* keeping the segments of the description together in the source code,
and rationally organized from a translation standpoint;
* only one place to change to adjust the column width.
Although it occurs to me that with the existing setup, it's possible
for the translator to unilaterally alter the column width for the
switches, which is something he'd definitely like to be able to do.
Maybe we should not try to be cute, but just do
#if defined(HAVE_GETOPT_LONG)
#define xo(long,short,desc) printf("%s %s\n", long, desc)
#else
#define xo(long,short,desc) printf("%s %s\n", short, desc)
#endif
xo(_("-f, --file=FILENAME "),
_("-f FILENAME "),
_("output file name"));
so that the column spacing remains under control of the translator.
regards, tom lane
"Michael Paesold" <mpaesold@gmx.at> writes:
Now setting autocommit=off the set transaction isolation level command does
not show any effect:
billing=# set autocommit to off;
SET
billing=# set transaction isolation level serializable;
SET
SET does not start a transaction block, so this will not work. You must
use an explicit BEGIN before setting TRANSACTION ISOLATION LEVEL.
You might instead set default_transaction_isolation to get the behavior
I think you are looking for.
regards, tom lane
On Thu, 2 Jan 2003, Tom Lane wrote:
"Michael Paesold" <mpaesold@gmx.at> writes:
Now setting autocommit=off the set transaction isolation level command does
not show any effect:billing=# set autocommit to off;
SET
billing=# set transaction isolation level serializable;
SETSET does not start a transaction block, so this will not work. You must
use an explicit BEGIN before setting TRANSACTION ISOLATION LEVEL.You might instead set default_transaction_isolation to get the behavior
I think you are looking for.
The overall behavior appears to be against spec, but I figure this was
discussed at the time the set transation was added.
----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
Sent: January 02, 2003 9:29 AM
Maybe we should not try to be cute, but just do
#if defined(HAVE_GETOPT_LONG)
#define xo(long,short,desc) printf("%s %s\n", long, desc)
#else
#define xo(long,short,desc) printf("%s %s\n", short, desc)
#endifxo(_("-f, --file=FILENAME "),
_("-f FILENAME "),
_("output file name"));so that the column spacing remains under control of the translator.
Looks good to me, but there is still a little inconvenience
of multiline option descriptions, and the above won't handle
it nicely.
If people agree with the above, can I go ahead and make corresponding
changes?
OR
may be a whole generic option-formatting routine
should be created; one for all the tools? ;-)
Similar to explain_option() of Manfred,
which will handle the mulitline, padding, and other stuff?
(am being half serious here, but it could be an "option")
-s
"Serguei Mokhov" <mokhov@cs.concordia.ca> writes:
Looks good to me, but there is still a little inconvenience
of multiline option descriptions, and the above won't handle
it nicely.
True, a multiline description would have to look like
xo(_("-f, --file=FILENAME "),
_("-f FILENAME "),
_("output file name\n"
" more description"));
Which is not great, but it doesn't seem completely unworkable either.
And the translator can still adjust the column spacing without any
code changes.
may be a whole generic option-formatting routine
should be created; one for all the tools? ;-)
Similar to explain_option() of Manfred,
which will handle the mulitline, padding, and other stuff?
(am being half serious here, but it could be an "option")
The trouble I see there is that the layout --- in particular the column
width --- would be embedded in such a routine and not alterable by
simply replacing message texts.
regards, tom lane
----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
Sent: January 02, 2003 1:58 PM
"Serguei Mokhov" <mokhov@cs.concordia.ca> writes:
Looks good to me, but there is still a little inconvenience
of multiline option descriptions, and the above won't handle
it nicely.True, a multiline description would have to look like
xo(_("-f, --file=FILENAME "),
_("-f FILENAME "),
_("output file name\n"
" more description"));Which is not great, but it doesn't seem completely unworkable either.
And the translator can still adjust the column spacing without any
code changes.
Well, it's better than before and solves *my* (and other translators')
problem.
Now, this:
#if defined(HAVE_GETOPT_LONG)
#define xo(long,short,desc) printf("%s %s\n", long, desc)
#else
#define xo(long,short,desc) printf("%s %s\n", short, desc)
#endif
seems relatively generic, so it could be used by more than one tool.
I searched for 'util' the source tree to see a more or less
logical place to put it. I got a whole bunch of .*util.* files,
but none of them seems appropriate enough because they all specific
to some other tool or smth else. Is pushing it up to c.h an option,
or it'll become too polluted? Where should I place it?
may be a whole generic option-formatting routine
should be created; one for all the tools? ;-)
Similar to explain_option() of Manfred,
which will handle the mulitline, padding, and other stuff?
(am being half serious here, but it could be an "option")The trouble I see there is that the layout --- in particular the column
width --- would be embedded in such a routine and not alterable by
simply replacing message texts.
True, but what would be wrong by having an argument for the column width?
-s
"Serguei Mokhov" <mokhov@cs.concordia.ca> writes:
Now, this:
#if defined(HAVE_GETOPT_LONG)
#define xo(long,short,desc) printf("%s %s\n", long, desc)
#else
#define xo(long,short,desc) printf("%s %s\n", short, desc)
#endif
seems relatively generic, so it could be used by more than one tool.
But there's no good place to put it. I'd say just stick it into each
tool; it's no worse than repeating the existence of a "usage()"
subroutine in each tool.
Is pushing it up to c.h an option,
I'd vote against that.
The trouble I see there is that the layout --- in particular the column
width --- would be embedded in such a routine and not alterable by
simply replacing message texts.
True, but what would be wrong by having an argument for the column width?
The translator would have no control over such an argument --- at least
not without some mechanism outside the .po files.
regards, tom lane
----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
Sent: January 02, 2003 3:20 PM
#if defined(HAVE_GETOPT_LONG)
#define xo(long,short,desc) printf("%s %s\n", long, desc)
#else
#define xo(long,short,desc) printf("%s %s\n", short, desc)
#endifseems relatively generic, so it could be used by more than one tool.
But there's no good place to put it. I'd say just stick it into each
tool; it's no worse than repeating the existence of a "usage()"
subroutine in each tool.
It ended up being in dumputils.h
Attached a patch for pg_dump(all) and pg_restore eliminating dupes
in option descriptions as per above xo "technology".
Please review and apply if there are no too many objections.
thank you,
-s
Attachments:
pg_dump.options2.diffapplication/octet-stream; name=pg_dump.options2.diffDownload
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 <pgsql-bugs@postgresql.org>.\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 <pgsql-bugs@postgresql.org>.\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 <pgsql-bugs@postgresql.org>.\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 <pgsql-bugs@postgresql.org>.\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 <pgsql-bugs@postgresql.org>.\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 <pgsql-bugs@postgresql.org>.\n"));
"Serguei Mokhov" <mokhov@cs.concordia.ca> writes:
But there's no good place to put it. I'd say just stick it into each
tool; it's no worse than repeating the existence of a "usage()"
subroutine in each tool.
It ended up being in dumputils.h
I really don't like putting a macro with a name as short as "xo" into a
header file, even one of relatively narrow scope. It's too likely to
create weird conflicts. My inclination is to make the coding be more
like
static void
usage(void)
{
#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
... lots of xo() calls ...
#undef xo
}
This gives us the convenience of a very short name within the usage()
subroutines, while not polluting the namespace for everyplace else in
these utilities.
As I said before, duplicating the definition of xo() in each file that
uses it doesn't bother me a bit; it's too simple for that to be a
significant objection.
regards, tom lane
Serguei Mokhov writes:
#if defined(HAVE_GETOPT_LONG)
#define xo(long,short,desc) printf("%s %s\n", long, desc)
#else
#define xo(long,short,desc) printf("%s %s\n", short, desc)
#endifseems relatively generic, so it could be used by more than one tool.
As long as we're spending time on this, why not just write our own version
of getopt_long()?
--
Peter Eisentraut peter_e@gmx.net
Peter Eisentraut <peter_e@gmx.net> writes:
As long as we're spending time on this, why not just write our own version
of getopt_long()?
Seems like a fine idea to me ... who's volunteering?
regards, tom lane