pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Why does pg_checksums -r not have a long option?
15+ messages / 6 participants
[nested] [flat]

Commits from this thread:
  2019-05-30 fc115d0f9f  Rework options of pg_checksums options for filenode handling
* Why does pg_checksums -r not have a long option?
@ 2019-05-26 06:12  Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  0 siblings, 1 reply; 15+ messages in thread

From: Peter Eisentraut @ 2019-05-26 06:12 UTC (permalink / raw)
  To: pgsql-hackers

Was this just forgotten?

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-05-26 06:35  Fabien COELHO <coelho@cri.ensmp.fr>
  parent: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  0 siblings, 1 reply; 15+ messages in thread

From: Fabien COELHO @ 2019-05-26 06:35 UTC (permalink / raw)
  To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: pgsql-hackers


> Subject: Why does pg_checksums -r not have a long option?
> 
> Was this just forgotten?

Probably? Attached a patch.

-- 
Fabien.

Attachments:

checksums-long-option-1.patch (text/x-diff, 1.7K) download diff --git a/doc/src/sgml/ref/pg_checksums.sgml b/doc/src/sgml/ref/pg_checksums.sgml index a0ffeb0ab0..5549ea679a 100644 --- a/doc/src/sgml/ref/pg_checksums.sgml +++ b/doc/src/sgml/ref/pg_checksums.sgml @@ -128,6 +128,7 @@ PostgreSQL documentation <varlistentry> <term><option>-r <replaceable>relfilenode</replaceable></option></term> + <term><option>--relfilenode=<replaceable>relfilenode</replaceable></option></term> <listitem> <para> Only validate checksums in the relation with specified relfilenode. diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 37fe20bb75..a994c51515 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -83,7 +83,7 @@ usage(void) printf(_(" -N, --no-sync do not wait for changes to be written safely to disk\n")); printf(_(" -P, --progress show progress information\n")); printf(_(" -v, --verbose output verbose messages\n")); - printf(_(" -r RELFILENODE check only relation with specified relfilenode\n")); + printf(_(" [-r,--relfilenode]=NODE check only relation with specified relation file node\n")); printf(_(" -V, --version output version information, then exit\n")); printf(_(" -?, --help show this help, then exit\n")); printf(_("\nIf no data directory (DATADIR) is specified, " @@ -373,6 +373,7 @@ main(int argc, char *argv[]) {"enable", no_argument, NULL, 'e'}, {"no-sync", no_argument, NULL, 'N'}, {"progress", no_argument, NULL, 'P'}, + {"relfilenode", required_argument, NULL, 'r'}, {"verbose", no_argument, NULL, 'v'}, {NULL, 0, NULL, 0} };
^ permalink raw reply [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-05-27 01:52  Michael Paquier <michael@paquier.xyz>
  parent: Fabien COELHO <coelho@cri.ensmp.fr>
  0 siblings, 2 replies; 15+ messages in thread

From: Michael Paquier @ 2019-05-27 01:52 UTC (permalink / raw)
  To: Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-hackers

On Sun, May 26, 2019 at 08:35:30AM +0200, Fabien COELHO wrote:
> Probably? Attached a patch.

No objections with adding a long option for that stuff.  But I do have
an objection with the naming because we have another tool able to work
on relfilenodes:
$ oid2name --help | grep FILE
  -f, --filenode=FILENODE    show info for table with given file node

In this case, long options are new as of 1aaf532 which is recent, but
-f is around for a much longer time.

Perhaps we should use the same mapping for consistency?
pg_verify_checksums has been using -r for whatever reason, but as we
do a renaming of the binary for v12 we could just fix that
inconsistency as well.  Hence I would suggest that for the option
description:
"-f, --filenode=FILENODE"

I would also switch to the long option name in the tests at the same
time, this makes the perl scripts easier to follow.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-05-27 06:32  Fabien COELHO <coelho@cri.ensmp.fr>
  parent: Michael Paquier <michael@paquier.xyz>
  1 sibling, 1 reply; 15+ messages in thread

From: Fabien COELHO @ 2019-05-27 06:32 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-hackers


Hello Michael-san,

> No objections with adding a long option for that stuff.  But I do have
> an objection with the naming because we have another tool able to work
> on relfilenodes:
> $ oid2name --help | grep FILE
>  -f, --filenode=FILENODE    show info for table with given file node
>
> In this case, long options are new as of 1aaf532 which is recent, but
> -f is around for a much longer time.
>
> Perhaps we should use the same mapping for consistency?
>
> pg_verify_checksums has been using -r for whatever reason, but as we
> do a renaming of the binary for v12 we could just fix that
> inconsistency as well.  Hence I would suggest that for the option
> description:
> "-f, --filenode=FILENODE"

Fine with me, I was not particularly happy with "relfilenode", but just 
picked it up for consistency with -r.

> I would also switch to the long option name in the tests at the same
> time, this makes the perl scripts easier to follow.

Ok. Attached.

I've used both -f & --filenode in the test to check that the renaming was 
ok. I have reordered the options in the documentation so that they appear 
in alphabetical order, as for some reason --progress was out of it.

-- 
Fabien.

Attachments:

checksums-long-option-2.patch (text/x-diff, 6.7K) download diff --git a/doc/src/sgml/ref/pg_checksums.sgml b/doc/src/sgml/ref/pg_checksums.sgml index a0ffeb0ab0..6d8dd6be29 100644 --- a/doc/src/sgml/ref/pg_checksums.sgml +++ b/doc/src/sgml/ref/pg_checksums.sgml @@ -100,6 +100,16 @@ PostgreSQL documentation </listitem> </varlistentry> + <varlistentry> + <term><option>-f <replaceable>filenode</replaceable></option></term> + <term><option>--filenode=<replaceable>filenode</replaceable></option></term> + <listitem> + <para> + Only validate checksums in the relation with specified relation file node. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>-N</option></term> <term><option>--no-sync</option></term> @@ -116,25 +126,6 @@ PostgreSQL documentation </listitem> </varlistentry> - <varlistentry> - <term><option>-v</option></term> - <term><option>--verbose</option></term> - <listitem> - <para> - Enable verbose output. Lists all checked files. - </para> - </listitem> - </varlistentry> - - <varlistentry> - <term><option>-r <replaceable>relfilenode</replaceable></option></term> - <listitem> - <para> - Only validate checksums in the relation with specified relfilenode. - </para> - </listitem> - </varlistentry> - <varlistentry> <term><option>-P</option></term> <term><option>--progress</option></term> @@ -146,6 +137,16 @@ PostgreSQL documentation </listitem> </varlistentry> + <varlistentry> + <term><option>-v</option></term> + <term><option>--verbose</option></term> + <listitem> + <para> + Enable verbose output. Lists all checked files. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>-V</option></term> <term><option>--version</option></term> diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 37fe20bb75..cd621e5417 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -36,7 +36,7 @@ static int64 blocks = 0; static int64 badblocks = 0; static ControlFileData *ControlFile; -static char *only_relfilenode = NULL; +static char *only_filenode = NULL; static bool do_sync = true; static bool verbose = false; static bool showprogress = false; @@ -83,7 +83,7 @@ usage(void) printf(_(" -N, --no-sync do not wait for changes to be written safely to disk\n")); printf(_(" -P, --progress show progress information\n")); printf(_(" -v, --verbose output verbose messages\n")); - printf(_(" -r RELFILENODE check only relation with specified relfilenode\n")); + printf(_(" [-f, --filenode]=NODE check only relation with specified file node\n")); printf(_(" -V, --version output version information, then exit\n")); printf(_(" -?, --help show this help, then exit\n")); printf(_("\nIf no data directory (DATADIR) is specified, " @@ -318,7 +318,7 @@ scan_directory(const char *basedir, const char *subdir, bool sizeonly) /* * Cut off at the segment boundary (".") to get the segment number * in order to mix it into the checksum. Then also cut off at the - * fork boundary, to get the relfilenode the file belongs to for + * fork boundary, to get the relation file node the file belongs to for * filtering. */ strlcpy(fnonly, de->d_name, sizeof(fnonly)); @@ -339,7 +339,7 @@ scan_directory(const char *basedir, const char *subdir, bool sizeonly) if (forkpath != NULL) *forkpath++ = '\0'; - if (only_relfilenode && strcmp(only_relfilenode, fnonly) != 0) + if (only_filenode && strcmp(only_filenode, fnonly) != 0) /* Relfilenode not to be included */ continue; @@ -373,6 +373,7 @@ main(int argc, char *argv[]) {"enable", no_argument, NULL, 'e'}, {"no-sync", no_argument, NULL, 'N'}, {"progress", no_argument, NULL, 'P'}, + {"filenode", required_argument, NULL, 'f'}, {"verbose", no_argument, NULL, 'v'}, {NULL, 0, NULL, 0} }; @@ -400,7 +401,7 @@ main(int argc, char *argv[]) } } - while ((c = getopt_long(argc, argv, "cD:deNPr:v", long_options, &option_index)) != -1) + while ((c = getopt_long(argc, argv, "cD:deNPf:v", long_options, &option_index)) != -1) { switch (c) { @@ -422,13 +423,13 @@ main(int argc, char *argv[]) case 'D': DataDir = optarg; break; - case 'r': + case 'f': if (atoi(optarg) == 0) { - pg_log_error("invalid relfilenode specification, must be numeric: %s", optarg); + pg_log_error("invalid file node specification, must be numeric: %s", optarg); exit(1); } - only_relfilenode = pstrdup(optarg); + only_filenode = pstrdup(optarg); break; case 'P': showprogress = true; @@ -466,9 +467,9 @@ main(int argc, char *argv[]) } /* Relfilenode checking only works in --check mode */ - if (mode != PG_MODE_CHECK && only_relfilenode) + if (mode != PG_MODE_CHECK && only_filenode) { - pg_log_error("relfilenode option only possible with --check"); + pg_log_error("--filenode option only possible with --check"); fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); diff --git a/src/bin/pg_checksums/t/002_actions.pl b/src/bin/pg_checksums/t/002_actions.pl index a8f45a268a..be05ee6e66 100644 --- a/src/bin/pg_checksums/t/002_actions.pl +++ b/src/bin/pg_checksums/t/002_actions.pl @@ -43,7 +43,7 @@ sub check_relation_corruption [ 'pg_checksums', '--check', '-D', $pgdata, - '-r', $relfilenode_corrupted + '-f', $relfilenode_corrupted ], "succeeds for single relfilenode on tablespace $tablespace with offline cluster" ); @@ -59,7 +59,7 @@ sub check_relation_corruption [ 'pg_checksums', '--check', '-D', $pgdata, - '-r', $relfilenode_corrupted + '-f', $relfilenode_corrupted ], 1, [qr/Bad checksums:.*1/], @@ -165,10 +165,10 @@ command_ok( # Specific relation files cannot be requested when action is --disable # or --enable. command_fails( - [ 'pg_checksums', '--disable', '-r', '1234', '-D', $pgdata ], + [ 'pg_checksums', '--disable', '--filenode', '1234', '-D', $pgdata ], "fails when relfilenodes are requested and action is --disable"); command_fails( - [ 'pg_checksums', '--enable', '-r', '1234', '-D', $pgdata ], + [ 'pg_checksums', '--enable', '-filenode', '1234', '-D', $pgdata ], "fails when relfilenodes are requested and action is --enable"); # Checks cannot happen with an online cluster
^ permalink raw reply [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-05-27 07:22  Daniel Gustafsson <daniel@yesql.se>
  parent: Michael Paquier <michael@paquier.xyz>
  1 sibling, 2 replies; 15+ messages in thread

From: Daniel Gustafsson @ 2019-05-27 07:22 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: Fabien COELHO <coelho@cri.ensmp.fr>; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-hackers

> On 27 May 2019, at 03:52, Michael Paquier <michael@paquier.xyz> wrote:

> pg_verify_checksums has been using -r for whatever reason, but as we
> do a renaming of the binary for v12 we could just fix that
> inconsistency as well.

The original patch used -o in pg_verify_checksums, the discussion of which
started in the below mail:

https://postgr.es/m/20180228194242.qbjasdtwm2yj5rqg%40alvherre.pgsql

Since -f was already used for “force check”, -r ended up being used.  Now that
there no longer is a -f flag in pg_checksums, it can be renamed.

cheers ./daniel




^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-05-27 08:05  Michael Paquier <michael@paquier.xyz>
  parent: Daniel Gustafsson <daniel@yesql.se>
  1 sibling, 0 replies; 15+ messages in thread

From: Michael Paquier @ 2019-05-27 08:05 UTC (permalink / raw)
  To: Daniel Gustafsson <daniel@yesql.se>; +Cc: Fabien COELHO <coelho@cri.ensmp.fr>; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-hackers

On Mon, May 27, 2019 at 09:22:42AM +0200, Daniel Gustafsson wrote:
> The original patch used -o in pg_verify_checksums, the discussion of which
> started in the below mail:
> 
> https://postgr.es/m/20180228194242.qbjasdtwm2yj5rqg%40alvherre.pgsql
> 
> Since -f was already used for “force check”, -r ended up being used.  Now that
> there no longer is a -f flag in pg_checksums, it can be renamed.

Interesting point.  Thanks for sharing.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-05-27 08:17  Michael Banck <michael.banck@credativ.de>
  parent: Daniel Gustafsson <daniel@yesql.se>
  1 sibling, 1 reply; 15+ messages in thread

From: Michael Banck @ 2019-05-27 08:17 UTC (permalink / raw)
  To: Daniel Gustafsson <daniel@yesql.se>; +Cc: Michael Paquier <michael@paquier.xyz>; Fabien COELHO <coelho@cri.ensmp.fr>; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-hackers

Hi,

On Mon, May 27, 2019 at 09:22:42AM +0200, Daniel Gustafsson wrote:
> > On 27 May 2019, at 03:52, Michael Paquier <michael@paquier.xyz> wrote:
> > pg_verify_checksums has been using -r for whatever reason, but as we
> > do a renaming of the binary for v12 we could just fix that
> > inconsistency as well.
> 
> The original patch used -o in pg_verify_checksums, the discussion of which
> started in the below mail:
> 
> https://postgr.es/m/20180228194242.qbjasdtwm2yj5rqg%40alvherre.pgsql
> 
> Since -f was already used for “force check”, -r ended up being used.  Now that
> there no longer is a -f flag in pg_checksums, it can be renamed.

Before we switch to -f out of consistency with oid2name, we should
consider Magnus' argument from
CABUevEzoeXaxbcYmMZsNF1aqdCwovys7-ChqCuGRY5+nsQZFew@mail.gmail.com IMO:

|I have no problem with changing it to -r. -f seems a bit wrong to me,
|as it might read as a file. And in the future we might want to implement
|the ability to take full filename (with path), in which case it would
|make sense to use -f for that.


Cheers,

Michael

-- 
Michael Banck
Projektleiter / Senior Berater
Tel.: +49 2166 9901-171
Fax:  +49 2166 9901-100
Email: michael.banck@credativ.de

credativ GmbH, HRB Mönchengladbach 12080
USt-ID-Nummer: DE204566209
Trompeterallee 108, 41189 Mönchengladbach
Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer

Unser Umgang mit personenbezogenen Daten unterliegt
folgenden Bestimmungen: https://www.credativ.de/datenschutz





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-05-27 08:33  Michael Paquier <michael@paquier.xyz>
  parent: Fabien COELHO <coelho@cri.ensmp.fr>
  0 siblings, 1 reply; 15+ messages in thread

From: Michael Paquier @ 2019-05-27 08:33 UTC (permalink / raw)
  To: Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-hackers

On Mon, May 27, 2019 at 08:32:21AM +0200, Fabien COELHO wrote:
> I've used both -f & --filenode in the test to check that the renaming was
> ok. I have reordered the options in the documentation so that they appear in
> alphabetical order, as for some reason --progress was out of it.

No objection to clean up this at the same time.

+     <varlistentry>
+      <term><option>-f <replaceable>filenode</replaceable></option></term>
+      <term><option>--filenode=<replaceable>filenode</replaceable></option></term>
+      <listitem>
+       <para>
+        Only validate checksums in the relation with specified relation file node.
+       </para>
Two nits.  I would just have been careful about the number of
characters in the line within the <para> markup.  And we use
extensively "filenode" in the docs.  So the description would become
as follows:
Only validate checksums in the relation with filenode
<replaceable>filenode</replaceable>.

+       [ 'pg_checksums', '--enable', '-filenode', '1234', '-D', $pgdata ],
This fails, but not for the reason it is written for.

It looks strange to not order --filenode alphabetically in --help.

With all these issues cleaned up, I got the attached.  Does that look
fine?  (I ran pgperltidy and pgindent on top of it.)
--
Michael

Attachments:

checksums-long-option-3.patch (text/x-diff, 7.8K) download diff --git a/doc/src/sgml/ref/pg_checksums.sgml b/doc/src/sgml/ref/pg_checksums.sgml index a0ffeb0ab0..33706d1d97 100644 --- a/doc/src/sgml/ref/pg_checksums.sgml +++ b/doc/src/sgml/ref/pg_checksums.sgml @@ -100,6 +100,17 @@ PostgreSQL documentation </listitem> </varlistentry> + <varlistentry> + <term><option>-f <replaceable>filenode</replaceable></option></term> + <term><option>--filenode=<replaceable>filenode</replaceable></option></term> + <listitem> + <para> + Only validate checksums in the relation with filenode + <replaceable>filenode</replaceable>. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>-N</option></term> <term><option>--no-sync</option></term> @@ -116,25 +127,6 @@ PostgreSQL documentation </listitem> </varlistentry> - <varlistentry> - <term><option>-v</option></term> - <term><option>--verbose</option></term> - <listitem> - <para> - Enable verbose output. Lists all checked files. - </para> - </listitem> - </varlistentry> - - <varlistentry> - <term><option>-r <replaceable>relfilenode</replaceable></option></term> - <listitem> - <para> - Only validate checksums in the relation with specified relfilenode. - </para> - </listitem> - </varlistentry> - <varlistentry> <term><option>-P</option></term> <term><option>--progress</option></term> @@ -146,6 +138,16 @@ PostgreSQL documentation </listitem> </varlistentry> + <varlistentry> + <term><option>-v</option></term> + <term><option>--verbose</option></term> + <listitem> + <para> + Enable verbose output. Lists all checked files. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>-V</option></term> <term><option>--version</option></term> diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 37fe20bb75..a7f8d1d613 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -36,7 +36,7 @@ static int64 blocks = 0; static int64 badblocks = 0; static ControlFileData *ControlFile; -static char *only_relfilenode = NULL; +static char *only_filenode = NULL; static bool do_sync = true; static bool verbose = false; static bool showprogress = false; @@ -76,16 +76,16 @@ usage(void) printf(_("Usage:\n")); printf(_(" %s [OPTION]... [DATADIR]\n"), progname); printf(_("\nOptions:\n")); - printf(_(" [-D, --pgdata=]DATADIR data directory\n")); - printf(_(" -c, --check check data checksums (default)\n")); - printf(_(" -d, --disable disable data checksums\n")); - printf(_(" -e, --enable enable data checksums\n")); - printf(_(" -N, --no-sync do not wait for changes to be written safely to disk\n")); - printf(_(" -P, --progress show progress information\n")); - printf(_(" -v, --verbose output verbose messages\n")); - printf(_(" -r RELFILENODE check only relation with specified relfilenode\n")); - printf(_(" -V, --version output version information, then exit\n")); - printf(_(" -?, --help show this help, then exit\n")); + printf(_(" [-D, --pgdata=]DATADIR data directory\n")); + printf(_(" -c, --check check data checksums (default)\n")); + printf(_(" -d, --disable disable data checksums\n")); + printf(_(" -e, --enable enable data checksums\n")); + printf(_(" -f, --filenode=FILENODE check only relation with specified filenode\n")); + printf(_(" -N, --no-sync do not wait for changes to be written safely to disk\n")); + printf(_(" -P, --progress show progress information\n")); + printf(_(" -v, --verbose output verbose messages\n")); + printf(_(" -V, --version output version information, then exit\n")); + printf(_(" -?, --help show this help, then exit\n")); printf(_("\nIf no data directory (DATADIR) is specified, " "the environment variable PGDATA\nis used.\n\n")); printf(_("Report bugs to <pgsql-bugs@lists.postgresql.org>.\n")); @@ -318,7 +318,7 @@ scan_directory(const char *basedir, const char *subdir, bool sizeonly) /* * Cut off at the segment boundary (".") to get the segment number * in order to mix it into the checksum. Then also cut off at the - * fork boundary, to get the relfilenode the file belongs to for + * fork boundary, to get the filenode the file belongs to for * filtering. */ strlcpy(fnonly, de->d_name, sizeof(fnonly)); @@ -339,8 +339,8 @@ scan_directory(const char *basedir, const char *subdir, bool sizeonly) if (forkpath != NULL) *forkpath++ = '\0'; - if (only_relfilenode && strcmp(only_relfilenode, fnonly) != 0) - /* Relfilenode not to be included */ + if (only_filenode && strcmp(only_filenode, fnonly) != 0) + /* filenode not to be included */ continue; dirsize += st.st_size; @@ -373,6 +373,7 @@ main(int argc, char *argv[]) {"enable", no_argument, NULL, 'e'}, {"no-sync", no_argument, NULL, 'N'}, {"progress", no_argument, NULL, 'P'}, + {"filenode", required_argument, NULL, 'f'}, {"verbose", no_argument, NULL, 'v'}, {NULL, 0, NULL, 0} }; @@ -400,7 +401,7 @@ main(int argc, char *argv[]) } } - while ((c = getopt_long(argc, argv, "cD:deNPr:v", long_options, &option_index)) != -1) + while ((c = getopt_long(argc, argv, "cD:deNPf:v", long_options, &option_index)) != -1) { switch (c) { @@ -422,13 +423,13 @@ main(int argc, char *argv[]) case 'D': DataDir = optarg; break; - case 'r': + case 'f': if (atoi(optarg) == 0) { - pg_log_error("invalid relfilenode specification, must be numeric: %s", optarg); + pg_log_error("invalid filenode specification, must be numeric: %s", optarg); exit(1); } - only_relfilenode = pstrdup(optarg); + only_filenode = pstrdup(optarg); break; case 'P': showprogress = true; @@ -465,10 +466,10 @@ main(int argc, char *argv[]) exit(1); } - /* Relfilenode checking only works in --check mode */ - if (mode != PG_MODE_CHECK && only_relfilenode) + /* filenode checking only works in --check mode */ + if (mode != PG_MODE_CHECK && only_filenode) { - pg_log_error("relfilenode option only possible with --check"); + pg_log_error("--filenode option only possible with --check"); fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); diff --git a/src/bin/pg_checksums/t/002_actions.pl b/src/bin/pg_checksums/t/002_actions.pl index a8f45a268a..ce24d06a10 100644 --- a/src/bin/pg_checksums/t/002_actions.pl +++ b/src/bin/pg_checksums/t/002_actions.pl @@ -43,7 +43,7 @@ sub check_relation_corruption [ 'pg_checksums', '--check', '-D', $pgdata, - '-r', $relfilenode_corrupted + '--filenode', $relfilenode_corrupted ], "succeeds for single relfilenode on tablespace $tablespace with offline cluster" ); @@ -59,7 +59,7 @@ sub check_relation_corruption [ 'pg_checksums', '--check', '-D', $pgdata, - '-r', $relfilenode_corrupted + '--filenode', $relfilenode_corrupted ], 1, [qr/Bad checksums:.*1/], @@ -165,10 +165,10 @@ command_ok( # Specific relation files cannot be requested when action is --disable # or --enable. command_fails( - [ 'pg_checksums', '--disable', '-r', '1234', '-D', $pgdata ], + [ 'pg_checksums', '--disable', '--filenode', '1234', '-D', $pgdata ], "fails when relfilenodes are requested and action is --disable"); command_fails( - [ 'pg_checksums', '--enable', '-r', '1234', '-D', $pgdata ], + [ 'pg_checksums', '--enable', '--filenode', '1234', '-D', $pgdata ], "fails when relfilenodes are requested and action is --enable"); # Checks cannot happen with an online cluster
signature.asc (application/pgp-signature, 832B) download ^ permalink raw reply [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-05-27 14:22  Fabien COELHO <coelho@cri.ensmp.fr>
  parent: Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 15+ messages in thread

From: Fabien COELHO @ 2019-05-27 14:22 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-hackers


Bonjour Michael,

> +     <varlistentry>
> +      <term><option>-f <replaceable>filenode</replaceable></option></term>
> +      <term><option>--filenode=<replaceable>filenode</replaceable></option></term>
> +      <listitem>
> +       <para>
> +        Only validate checksums in the relation with specified relation file node.
> +       </para>
> Two nits.  I would just have been careful about the number of
> characters in the line within the <para> markup.  And we use
> extensively "filenode" in the docs.

Ok.

> +       [ 'pg_checksums', '--enable', '-filenode', '1234', '-D', $pgdata ],
> This fails, but not for the reason it is written for.

Indeed. command_fails() is a little too simplistic, it should really check 
that the error message is there.

> It looks strange to not order --filenode alphabetically in --help.

Forgot, it stayed at the r position for no good reason.

> With all these issues cleaned up, I got the attached.  Does that look
> fine?  (I ran pgperltidy and pgindent on top of it.)

Works for me. Doc build is ok as well.

-- 
Fabien.





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-05-28 02:56  Michael Paquier <michael@paquier.xyz>
  parent: Michael Banck <michael.banck@credativ.de>
  0 siblings, 2 replies; 15+ messages in thread

From: Michael Paquier @ 2019-05-28 02:56 UTC (permalink / raw)
  To: Michael Banck <michael.banck@credativ.de>; +Cc: Daniel Gustafsson <daniel@yesql.se>; Fabien COELHO <coelho@cri.ensmp.fr>; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-hackers

On Mon, May 27, 2019 at 10:17:43AM +0200, Michael Banck wrote:
> Before we switch to -f out of consistency with oid2name, we should
> consider Magnus' argument from
> CABUevEzoeXaxbcYmMZsNF1aqdCwovys7-ChqCuGRY5+nsQZFew@mail.gmail.com IMO:
> 
> |I have no problem with changing it to -r. -f seems a bit wrong to me,
> |as it might read as a file. And in the future we might want to implement
> |the ability to take full filename (with path), in which case it would
> |make sense to use -f for that.

You could also use a long option for that without a one-letter option,
like --file-path or such, so reserving a one-letter option for a
future, hypothetical use is not really a stopper in my opinion.  In
consequence, I think that that it is fine to just use -f/--filenode.
Any objections or better suggestions from other folks here?
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-05-28 07:59  Fabien COELHO <coelho@cri.ensmp.fr>
  parent: Michael Paquier <michael@paquier.xyz>
  1 sibling, 0 replies; 15+ messages in thread

From: Fabien COELHO @ 2019-05-28 07:59 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: Michael Banck <michael.banck@credativ.de>; Daniel Gustafsson <daniel@yesql.se>; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-hackers


>> |I have no problem with changing it to -r. -f seems a bit wrong to me,
>> |as it might read as a file. And in the future we might want to implement
>> |the ability to take full filename (with path), in which case it would
>> |make sense to use -f for that.
>
> You could also use a long option for that without a one-letter option, 
> like --file-path or such, so reserving a one-letter option for a future, 
> hypothetical use is not really a stopper in my opinion.  In consequence, 
> I think that that it is fine to just use -f/--filenode.

Yep. Also, the -f option could be overloaded by guessing whether is 
associated argument is a number or a path…

> Any objections or better suggestions from other folks here?

-- 
Fabien.

^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-05-30 21:55  Michael Paquier <michael@paquier.xyz>
  parent: Fabien COELHO <coelho@cri.ensmp.fr>
  0 siblings, 0 replies; 15+ messages in thread

From: Michael Paquier @ 2019-05-30 21:55 UTC (permalink / raw)
  To: Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-hackers

On Mon, May 27, 2019 at 04:22:37PM +0200, Fabien COELHO wrote:
> Works for me. Doc build is ok as well.

Thanks, committed.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-06-05 20:31  Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  parent: Michael Paquier <michael@paquier.xyz>
  1 sibling, 1 reply; 15+ messages in thread

From: Peter Eisentraut @ 2019-06-05 20:31 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; Michael Banck <michael.banck@credativ.de>; +Cc: Daniel Gustafsson <daniel@yesql.se>; Fabien COELHO <coelho@cri.ensmp.fr>; pgsql-hackers

On 2019-05-28 04:56, Michael Paquier wrote:
> You could also use a long option for that without a one-letter option,
> like --file-path or such, so reserving a one-letter option for a
> future, hypothetical use is not really a stopper in my opinion.  In
> consequence, I think that that it is fine to just use -f/--filenode.
> Any objections or better suggestions from other folks here?

I think -r/--relfilenode was actually a good suggestion.  Because it
doesn't actually check a *file* but potentially several files (forks,
segments).  The -f naming makes it sound like it operates on a specific
file.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-06-06 09:01  Michael Paquier <michael@paquier.xyz>
  parent: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  0 siblings, 1 reply; 15+ messages in thread

From: Michael Paquier @ 2019-06-06 09:01 UTC (permalink / raw)
  To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: Michael Banck <michael.banck@credativ.de>; Daniel Gustafsson <daniel@yesql.se>; Fabien COELHO <coelho@cri.ensmp.fr>; pgsql-hackers

On Wed, Jun 05, 2019 at 10:31:54PM +0200, Peter Eisentraut wrote:
> I think -r/--relfilenode was actually a good suggestion.  Because it
> doesn't actually check a *file* but potentially several files (forks,
> segments).  The -f naming makes it sound like it operates on a specific
> file.

Hmm.  I still tend to prefer the -f/--filenode interface as that's
more consistent with what we have in the documentation, where
relfilenode gets only used when referring to the pg_class attribute.
You have a point about the fork types and extra segments, but I am not
sure that --relfilenode defines that in a better way than --filenode.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Why does pg_checksums -r not have a long option?
@ 2019-06-09 11:02  Tomas Vondra <tomas.vondra@2ndquadrant.com>
  parent: Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 15+ messages in thread

From: Tomas Vondra @ 2019-06-09 11:02 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; Michael Banck <michael.banck@credativ.de>; Daniel Gustafsson <daniel@yesql.se>; Fabien COELHO <coelho@cri.ensmp.fr>; pgsql-hackers

On Thu, Jun 06, 2019 at 06:01:21PM +0900, Michael Paquier wrote:
>On Wed, Jun 05, 2019 at 10:31:54PM +0200, Peter Eisentraut wrote:
>> I think -r/--relfilenode was actually a good suggestion.  Because it
>> doesn't actually check a *file* but potentially several files (forks,
>> segments).  The -f naming makes it sound like it operates on a specific
>> file.
>
>Hmm.  I still tend to prefer the -f/--filenode interface as that's
>more consistent with what we have in the documentation, where
>relfilenode gets only used when referring to the pg_class attribute.
>You have a point about the fork types and extra segments, but I am not
>sure that --relfilenode defines that in a better way than --filenode.
>--

I agree. The "rel" prefix is there mostly because the other pg_class
attributes have it too (reltablespace, reltuples, ...) and we use
"filenode" elsewhere. For example we have pg_relation_filenode() function,
operating with exactly this piece of information.

So +1 to keep the "-f/--filenode" options.


regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services






^ permalink  raw  reply  [nested|flat] 15+ messages in thread


end of thread, other threads:[~2019-06-09 11:02 UTC | newest]

Thread overview: 15+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-05-26 06:12 Why does pg_checksums -r not have a long option? Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2019-05-26 06:35 ` Fabien COELHO <coelho@cri.ensmp.fr>
2019-05-27 01:52   ` Michael Paquier <michael@paquier.xyz>
2019-05-27 06:32     ` Fabien COELHO <coelho@cri.ensmp.fr>
2019-05-27 08:33       ` Michael Paquier <michael@paquier.xyz>
2019-05-27 14:22         ` Fabien COELHO <coelho@cri.ensmp.fr>
2019-05-30 21:55           ` Michael Paquier <michael@paquier.xyz>
2019-05-27 07:22     ` Daniel Gustafsson <daniel@yesql.se>
2019-05-27 08:05       ` Michael Paquier <michael@paquier.xyz>
2019-05-27 08:17       ` Michael Banck <michael.banck@credativ.de>
2019-05-28 02:56         ` Michael Paquier <michael@paquier.xyz>
2019-05-28 07:59           ` Fabien COELHO <coelho@cri.ensmp.fr>
2019-06-05 20:31           ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2019-06-06 09:01             ` Michael Paquier <michael@paquier.xyz>
2019-06-09 11:02               ` Tomas Vondra <tomas.vondra@2ndquadrant.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox