Long options for pg_ctl waiting
One thing that has been irking me ever since I came to PostgreSQL is the
fact that pg_ctl -w (and -W) don't have longhand equivalents. I like to
use the long version in scripts and such as extra documentation, and
I've never been able to with these. What's more, I keep forgetting that
--wait (and --no-wait) aren't a thing.
Trivial patch attached.
--
Vik Fearing +33 6 46 75 15 36
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
Attachments:
pg_ctl_wait-01.patchinvalid/octet-stream; name=pg_ctl_wait-01.patchDownload
diff --git a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml
index 6ceb781..5b9d08c 100644
--- a/doc/src/sgml/ref/pg_ctl-ref.sgml
+++ b/doc/src/sgml/ref/pg_ctl-ref.sgml
@@ -381,6 +381,7 @@ PostgreSQL documentation
<varlistentry>
<term><option>-w</option></term>
+ <term><option>--wait</option></term>
<listitem>
<para>
Wait for the startup or shutdown to complete.
@@ -398,6 +399,7 @@ PostgreSQL documentation
<varlistentry>
<term><option>-W</option></term>
+ <term><option>--no-wait</option></term>
<listitem>
<para>
Do not wait for startup or shutdown to complete. This is the
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index efc0729..7811e46 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -1931,8 +1931,8 @@ do_help(void)
printf(_(" -s, --silent only print errors, no informational messages\n"));
printf(_(" -t, --timeout=SECS seconds to wait when using -w option\n"));
printf(_(" -V, --version output version information, then exit\n"));
- printf(_(" -w wait until operation completes\n"));
- printf(_(" -W do not wait until operation completes\n"));
+ printf(_(" -w, --wait wait until operation completes\n"));
+ printf(_(" -W, --no-wait do not wait until operation completes\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_("(The default is to wait for shutdown, but not for start or restart.)\n\n"));
printf(_("If the -D option is omitted, the environment variable PGDATA is used.\n"));
@@ -2127,6 +2127,8 @@ main(int argc, char **argv)
{"silent", no_argument, NULL, 's'},
{"timeout", required_argument, NULL, 't'},
{"core-files", no_argument, NULL, 'c'},
+ {"wait", no_argument, NULL, 'w'},
+ {"no-wait", no_argument, NULL, 'W'},
{NULL, 0, NULL, 0}
};
On Sun, Sep 4, 2016 at 5:57 AM, Vik Fearing <vik@2ndquadrant.fr> wrote:
One thing that has been irking me ever since I came to PostgreSQL is the
fact that pg_ctl -w (and -W) don't have longhand equivalents. I like to
use the long version in scripts and such as extra documentation, and
I've never been able to with these. What's more, I keep forgetting that
--wait (and --no-wait) aren't a thing.Trivial patch attached.
Nit: Like --nosync we could use --nowait, without an hyphen.
--
Michael
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Sat, Sep 3, 2016 at 7:13 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:
On Sun, Sep 4, 2016 at 5:57 AM, Vik Fearing <vik@2ndquadrant.fr> wrote:
One thing that has been irking me ever since I came to PostgreSQL is the
fact that pg_ctl -w (and -W) don't have longhand equivalents. I like to
use the long version in scripts and such as extra documentation, and
I've never been able to with these. What's more, I keep forgetting that
--wait (and --no-wait) aren't a thing.Trivial patch attached.
Nit: Like --nosync we could use --nowait, without an hyphen.
But is that actually better? I think that the idea of omitting the
dash here is one of those things that sounds good at first, and then
later you realize that it was actually a dumb idea all along. If
somebody has an option for --body or --on or --table and has to negate
it by running --nobody or --noon or --notable, some confusion may
result, because in each case you get a word that is not really the
logical inverse of the original option. Also, if you end up with any
multi-word options, like --save-backup-files, then users wonder why
the opposite, --nosave-backup-files, has a dash between words 2 and 3
and between words 3 and 4, but not between words 1 and 2. I suggest
we'd do better to standardize on always including a dash in such
cases.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 08/09/16 07:31, Robert Haas wrote:
On Sat, Sep 3, 2016 at 7:13 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:On Sun, Sep 4, 2016 at 5:57 AM, Vik Fearing <vik@2ndquadrant.fr> wrote:
One thing that has been irking me ever since I came to PostgreSQL is the
fact that pg_ctl -w (and -W) don't have longhand equivalents. I like to
use the long version in scripts and such as extra documentation, and
I've never been able to with these. What's more, I keep forgetting that
--wait (and --no-wait) aren't a thing.Trivial patch attached.
Nit: Like --nosync we could use --nowait, without an hyphen.
But is that actually better? I think that the idea of omitting the
dash here is one of those things that sounds good at first, and then
later you realize that it was actually a dumb idea all along. If
somebody has an option for --body or --on or --table and has to negate
it by running --nobody or --noon or --notable, some confusion may
result, because in each case you get a word that is not really the
logical inverse of the original option. Also, if you end up with any
multi-word options, like --save-backup-files, then users wonder why
the opposite, --nosave-backup-files, has a dash between words 2 and 3
and between words 3 and 4, but not between words 1 and 2. I suggest
we'd do better to standardize on always including a dash in such
cases.
+1
possibly '--nosync' (& any similar) should have a '--no-sync' variation
added, with the '--nosync' variation documented as depreciated?
Cheers,
Gavin
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Gavin Flower wrote:
possibly '--nosync' (& any similar) should have a '--no-sync' variation
added, with the '--nosync' variation documented as depreciated?
I agree -- I would go as far as just documenting --no-sync only and
keeping the --nosync one working with minimal (if any) visibility in
docs.
--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 09/07/2016 10:41 PM, Alvaro Herrera wrote:
Gavin Flower wrote:
possibly '--nosync' (& any similar) should have a '--no-sync' variation
added, with the '--nosync' variation documented as depreciated?I agree -- I would go as far as just documenting --no-sync only and
keeping the --nosync one working with minimal (if any) visibility in
docs.
Okay, here's a patch to do that. I don't think it's the other patch's
job to do it.
I also changed --noclean to --no-clean, and --no-locale was already correct.
--
Vik Fearing +33 6 46 75 15 36
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
Attachments:
pg_ctl_no_opts_01.patchinvalid/octet-stream; name=pg_ctl_no_opts_01.patchDownload
diff --git a/doc/src/sgml/ref/initdb.sgml b/doc/src/sgml/ref/initdb.sgml
index 4e339ec..31f081a 100644
--- a/doc/src/sgml/ref/initdb.sgml
+++ b/doc/src/sgml/ref/initdb.sgml
@@ -235,7 +235,7 @@ PostgreSQL documentation
<varlistentry>
<term><option>-N</option></term>
- <term><option>--nosync</option></term>
+ <term><option>--no-sync</option></term>
<listitem>
<para>
By default, <command>initdb</command> will wait for all files to be
@@ -355,7 +355,7 @@ PostgreSQL documentation
<varlistentry>
<term><option>-n</option></term>
- <term><option>--noclean</option></term>
+ <term><option>--no-clean</option></term>
<listitem>
<para>
By default, when <command>initdb</command>
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 3350e13..e96d72c 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -2658,8 +2658,8 @@ usage(const char *progname)
printf(_(" -d, --debug generate lots of debugging output\n"));
printf(_(" -k, --data-checksums use data page checksums\n"));
printf(_(" -L DIRECTORY where to find the input files\n"));
- printf(_(" -n, --noclean do not clean up after errors\n"));
- printf(_(" -N, --nosync do not wait for changes to be written safely to disk\n"));
+ printf(_(" -n, --no-clean do not clean up after errors\n"));
+ printf(_(" -N, --no-sync do not wait for changes to be written safely to disk\n"));
printf(_(" -s, --show show internal settings\n"));
printf(_(" -S, --sync-only only sync data directory\n"));
printf(_("\nOther options:\n"));
@@ -3334,8 +3334,10 @@ main(int argc, char *argv[])
{"version", no_argument, NULL, 'V'},
{"debug", no_argument, NULL, 'd'},
{"show", no_argument, NULL, 's'},
- {"noclean", no_argument, NULL, 'n'},
- {"nosync", no_argument, NULL, 'N'},
+ {"noclean", no_argument, NULL, 'n'}, /* for backwards compatibility */
+ {"no-clean", no_argument, NULL, 'n'},
+ {"nosync", no_argument, NULL, 'N'}, /* for backwards compatibility */
+ {"no-sync", no_argument, NULL, 'N'},
{"sync-only", no_argument, NULL, 'S'},
{"xlogdir", required_argument, NULL, 'X'},
{"data-checksums", no_argument, NULL, 'k'},
@@ -3421,7 +3423,7 @@ main(int argc, char *argv[])
break;
case 'n':
noclean = true;
- printf(_("Running in noclean mode. Mistakes will not be cleaned up.\n"));
+ printf(_("Running in no-clean mode. Mistakes will not be cleaned up.\n"));
break;
case 'N':
do_sync = false;
On 08/09/16 09:08, Vik Fearing wrote:
On 09/07/2016 10:41 PM, Alvaro Herrera wrote:
Gavin Flower wrote:
possibly '--nosync' (& any similar) should have a '--no-sync' variation
added, with the '--nosync' variation documented as depreciated?I agree -- I would go as far as just documenting --no-sync only and
keeping the --nosync one working with minimal (if any) visibility in
docs.Okay, here's a patch to do that. I don't think it's the other patch's
job to do it.I also changed --noclean to --no-clean, and --no-locale was already correct.
Suggest a comment along the lines "Where flags of the form --xxx have a
negated form, then the preferred negated form is --no-xxx - and that any
existing use of the form --noxxx should be converted to --no-xxx, as the
non hyphenated form is now deprecated & will be removed in a future
version of Postgres."
Possibly generate warningswhen the non hyphenated form is used?
Cheers,
Gavin
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 09/07/2016 11:39 PM, Gavin Flower wrote:
On 08/09/16 09:08, Vik Fearing wrote:
On 09/07/2016 10:41 PM, Alvaro Herrera wrote:
Gavin Flower wrote:
possibly '--nosync' (& any similar) should have a '--no-sync' variation
added, with the '--nosync' variation documented as depreciated?I agree -- I would go as far as just documenting --no-sync only and
keeping the --nosync one working with minimal (if any) visibility in
docs.Okay, here's a patch to do that. I don't think it's the other patch's
job to do it.I also changed --noclean to --no-clean, and --no-locale was already
correct.Suggest a comment along the lines "Where flags of the form --xxx have a
negated form, then the preferred negated form is --no-xxx - and that any
existing use of the form --noxxx should be converted to --no-xxx, as the
non hyphenated form is now deprecated & will be removed in a future
version of Postgres."
I have verified that these are the only two options anywhere in the tree
that start with "no" and not "no-" so it should be pretty easy for
future options to conform on their own. I don't see adding a comment
like this to every long option definition block to be very helpful, and
only adding it to initdb is just weird. So I don't see the need for it.
Possibly generate warningswhen the non hyphenated form is used?
I'm not quite sure how I got volunteered to do this work, but it's easy
enough so I don't mind.
Here is a new patch that emits a warning when --noclean and/or --nosync
are used.
--
Vik Fearing +33 6 46 75 15 36
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
Attachments:
initdb_no_opts_02.patchinvalid/octet-stream; name=initdb_no_opts_02.patchDownload
diff --git a/doc/src/sgml/ref/initdb.sgml b/doc/src/sgml/ref/initdb.sgml
index 4e339ec..31f081a 100644
--- a/doc/src/sgml/ref/initdb.sgml
+++ b/doc/src/sgml/ref/initdb.sgml
@@ -235,7 +235,7 @@ PostgreSQL documentation
<varlistentry>
<term><option>-N</option></term>
- <term><option>--nosync</option></term>
+ <term><option>--no-sync</option></term>
<listitem>
<para>
By default, <command>initdb</command> will wait for all files to be
@@ -355,7 +355,7 @@ PostgreSQL documentation
<varlistentry>
<term><option>-n</option></term>
- <term><option>--noclean</option></term>
+ <term><option>--no-clean</option></term>
<listitem>
<para>
By default, when <command>initdb</command>
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 3350e13..be30543 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -2658,8 +2658,8 @@ usage(const char *progname)
printf(_(" -d, --debug generate lots of debugging output\n"));
printf(_(" -k, --data-checksums use data page checksums\n"));
printf(_(" -L DIRECTORY where to find the input files\n"));
- printf(_(" -n, --noclean do not clean up after errors\n"));
- printf(_(" -N, --nosync do not wait for changes to be written safely to disk\n"));
+ printf(_(" -n, --no-clean do not clean up after errors\n"));
+ printf(_(" -N, --no-sync do not wait for changes to be written safely to disk\n"));
printf(_(" -s, --show show internal settings\n"));
printf(_(" -S, --sync-only only sync data directory\n"));
printf(_("\nOther options:\n"));
@@ -3334,8 +3334,10 @@ main(int argc, char *argv[])
{"version", no_argument, NULL, 'V'},
{"debug", no_argument, NULL, 'd'},
{"show", no_argument, NULL, 's'},
- {"noclean", no_argument, NULL, 'n'},
- {"nosync", no_argument, NULL, 'N'},
+ {"noclean", no_argument, NULL, 12}, /* deprecated */
+ {"no-clean", no_argument, NULL, 'n'},
+ {"nosync", no_argument, NULL, 13}, /* deprecated */
+ {"no-sync", no_argument, NULL, 'N'},
{"sync-only", no_argument, NULL, 'S'},
{"xlogdir", required_argument, NULL, 'X'},
{"data-checksums", no_argument, NULL, 'k'},
@@ -3419,10 +3421,18 @@ main(int argc, char *argv[])
debug = true;
printf(_("Running in debug mode.\n"));
break;
+ case 12:
+ fprintf(stderr,
+ _("WARNING: --noclean is deprecated; use --no-clean instead\n"));
+ /* fall through */
case 'n':
noclean = true;
- printf(_("Running in noclean mode. Mistakes will not be cleaned up.\n"));
+ printf(_("Running in no-clean mode. Mistakes will not be cleaned up.\n"));
break;
+ case 13:
+ fprintf(stderr,
+ _("WARNING: --nosync is deprecated; use --no-sync instead\n"));
+ /* fall through */
case 'N':
do_sync = false;
break;
Vik Fearing <vik@2ndquadrant.fr> writes:
On 09/07/2016 11:39 PM, Gavin Flower wrote:
Possibly generate warningswhen the non hyphenated form is used?
I'm not quite sure how I got volunteered to do this work, but it's easy
enough so I don't mind.
Here is a new patch that emits a warning when --noclean and/or --nosync
are used.
I'm pretty much -1 on printing a warning. There's no ambiguity, and no
real reason for us ever to remove the old spellings. Standardizing on
"no-" going forward makes sense, but let's not slap people's wrists for
existing usage. (Or: if it ain't broke, don't break it.)
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 09/08/2016 01:05 AM, Tom Lane wrote:
Vik Fearing <vik@2ndquadrant.fr> writes:
On 09/07/2016 11:39 PM, Gavin Flower wrote:
Possibly generate warningswhen the non hyphenated form is used?
I'm not quite sure how I got volunteered to do this work, but it's easy
enough so I don't mind.
Here is a new patch that emits a warning when --noclean and/or --nosync
are used.I'm pretty much -1 on printing a warning. There's no ambiguity, and no
real reason for us ever to remove the old spellings. Standardizing on
"no-" going forward makes sense, but let's not slap people's wrists for
existing usage. (Or: if it ain't broke, don't break it.)
One could also argue that 2 out of 53 "no" options omitting the dash is
in fact broken, and a real reason to remove them.
I don't see the warning as "slapping wrists" so much as saying that
we're harmonizing our conventions and their scripts need to be updated
for the better.
That said, I'm not going to fight for this. My only goal here is to get
--wait and --no-wait added to pg_ctl.
--
Vik Fearing +33 6 46 75 15 36
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Vik Fearing <vik@2ndquadrant.fr> writes:
On 09/08/2016 01:05 AM, Tom Lane wrote:
I'm pretty much -1 on printing a warning. There's no ambiguity, and no
real reason for us ever to remove the old spellings. Standardizing on
"no-" going forward makes sense, but let's not slap people's wrists for
existing usage. (Or: if it ain't broke, don't break it.)
One could also argue that 2 out of 53 "no" options omitting the dash is
in fact broken, and a real reason to remove them.
I do not buy that. As a counter argument, consider that removing them
would make it impossible to write a script that works with both old
and new versions of PG. That's a mighty high price to pay for what
is little more than pedantry.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Thu, Sep 8, 2016 at 5:41 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
Gavin Flower wrote:
possibly '--nosync' (& any similar) should have a '--no-sync' variation
added, with the '--nosync' variation documented as depreciated?I agree -- I would go as far as just documenting --no-sync only and
keeping the --nosync one working with minimal (if any) visibility in
docs.
Keeping no visibility at all in the docs, with an alias in the
binaries sounds fine to me if we want to standardize a bit more
things.
--
Michael
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Thu, Sep 8, 2016 at 8:56 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Vik Fearing <vik@2ndquadrant.fr> writes:
On 09/08/2016 01:05 AM, Tom Lane wrote:
I'm pretty much -1 on printing a warning. There's no ambiguity, and no
real reason for us ever to remove the old spellings. Standardizing on
"no-" going forward makes sense, but let's not slap people's wrists for
existing usage. (Or: if it ain't broke, don't break it.)One could also argue that 2 out of 53 "no" options omitting the dash is
in fact broken, and a real reason to remove them.I do not buy that. As a counter argument, consider that removing them
would make it impossible to write a script that works with both old
and new versions of PG. That's a mighty high price to pay for what
is little more than pedantry.
Perhaps discussing that on another thread would be better, and I was
the one who began this thing... So I'll do it.
Vik's stuff is just to add a --no-wait and --wait long option alias on
pg_ctl. And that clearly improves the readability for users, so that's
a +1 from here. And let's just use the v1 presented at the beginning
of this thread. I agree with the feeling that standardizing things
would be better btw for such option names.
--
Michael
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 9/3/16 4:57 PM, Vik Fearing wrote:
One thing that has been irking me ever since I came to PostgreSQL is the
fact that pg_ctl -w (and -W) don't have longhand equivalents. I like to
use the long version in scripts and such as extra documentation, and
I've never been able to with these. What's more, I keep forgetting that
--wait (and --no-wait) aren't a thing.
committed
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 9/7/16 5:08 PM, Vik Fearing wrote:
On 09/07/2016 10:41 PM, Alvaro Herrera wrote:
Gavin Flower wrote:
possibly '--nosync' (& any similar) should have a '--no-sync' variation
added, with the '--nosync' variation documented as depreciated?I agree -- I would go as far as just documenting --no-sync only and
keeping the --nosync one working with minimal (if any) visibility in
docs.Okay, here's a patch to do that. I don't think it's the other patch's
job to do it.I also changed --noclean to --no-clean, and --no-locale was already correct.
committed
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers