]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Remove --quiet option from pg_amcheck
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Fri, 20 Aug 2021 10:44:54 +0000 (12:44 +0200)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Fri, 20 Aug 2021 10:44:54 +0000 (12:44 +0200)
Using --quiet in combination with --no-strict-names didn't work as
documented, a warning message was still emitted. Since the --quiet
flag was working in an unconventional way to other utilities, fix
by removing the functionality instead.

Backpatch through 14 where pg_amcheck was introduced.

Bug: 17148
Reported-by: Chen Jiaoqian <chenjq.jy@fujitsu.com>
Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Discussion: https://postgr.es/m/17148-b5087318e2b04fc6@postgresql.org
Backpatch-through: 14

doc/src/sgml/ref/pg_amcheck.sgml
src/bin/pg_amcheck/pg_amcheck.c
src/bin/pg_amcheck/t/002_nonesuch.pl
src/bin/pg_amcheck/t/003_check.pl
src/bin/pg_amcheck/t/005_opclass_damage.pl

index 46d12110b19ff52809ae88c4d36bfc37ab481de2..d00c48d0e7911c141bf69bea536b59eaf1d05bfe 100644 (file)
@@ -289,8 +289,6 @@ PostgreSQL documentation
        <literal>--table</literal>, <literal>--index</literal>,
        or <literal>--relation</literal> matches no objects, it is a fatal
        error. This option downgrades that error to a warning.
-       If this option is used with <literal>--quiet</literal>, the warning
-       will be suppressed as well.
       </para>
      </listitem>
     </varlistentry>
@@ -553,16 +551,6 @@ PostgreSQL documentation
      </listitem>
     </varlistentry>
 
-    <varlistentry>
-     <term><option>-q</option></term>
-     <term><option>--quiet</option></term>
-     <listitem>
-      <para>
-       Print fewer messages, and less detail regarding any server errors.
-      </para>
-     </listitem>
-    </varlistentry>
-
     <varlistentry>
      <term><option>-P</option></term>
      <term><option>--progress</option></term>
index af83d600abe745342cea7cf9bf63f4bcad6c2408..f4b1ef95e9edc44d6048d6d26849bd61442a2d80 100644 (file)
@@ -56,7 +56,6 @@ typedef struct AmcheckOptions
        bool            dbpattern;
        bool            alldb;
        bool            echo;
-       bool            quiet;
        bool            verbose;
        bool            strict_names;
        bool            show_progress;
@@ -112,7 +111,6 @@ static AmcheckOptions opts = {
        .dbpattern = false,
        .alldb = false,
        .echo = false,
-       .quiet = false,
        .verbose = false,
        .strict_names = true,
        .show_progress = false,
@@ -250,7 +248,6 @@ main(int argc, char *argv[])
                {"exclude-index", required_argument, NULL, 'I'},
                {"jobs", required_argument, NULL, 'j'},
                {"progress", no_argument, NULL, 'P'},
-               {"quiet", no_argument, NULL, 'q'},
                {"relation", required_argument, NULL, 'r'},
                {"exclude-relation", required_argument, NULL, 'R'},
                {"schema", required_argument, NULL, 's'},
@@ -294,7 +291,7 @@ main(int argc, char *argv[])
        handle_help_version_opts(argc, argv, progname, help);
 
        /* process command-line options */
-       while ((c = getopt_long(argc, argv, "ad:D:eh:Hi:I:j:p:Pqr:R:s:S:t:T:U:wWv",
+       while ((c = getopt_long(argc, argv, "ad:D:eh:Hi:I:j:p:Pr:R:s:S:t:T:U:wWv",
                                                        long_options, &optindex)) != -1)
        {
                char       *endptr;
@@ -338,9 +335,6 @@ main(int argc, char *argv[])
                        case 'P':
                                opts.show_progress = true;
                                break;
-                       case 'q':
-                               opts.quiet = true;
-                               break;
                        case 'r':
                                opts.allrel = false;
                                append_relation_pattern(&opts.include, optarg, encoding);
@@ -637,21 +631,18 @@ main(int argc, char *argv[])
                {
                        failed = opts.strict_names;
 
-                       if (!opts.quiet || failed)
-                       {
-                               if (pat->heap_only)
-                                       log_no_match("no heap tables to check matching \"%s\"",
-                                                                pat->pattern);
-                               else if (pat->btree_only)
-                                       log_no_match("no btree indexes to check matching \"%s\"",
-                                                                pat->pattern);
-                               else if (pat->rel_regex == NULL)
-                                       log_no_match("no relations to check in schemas matching \"%s\"",
-                                                                pat->pattern);
-                               else
-                                       log_no_match("no relations to check matching \"%s\"",
-                                                                pat->pattern);
-                       }
+                       if (pat->heap_only)
+                               log_no_match("no heap tables to check matching \"%s\"",
+                                                        pat->pattern);
+                       else if (pat->btree_only)
+                               log_no_match("no btree indexes to check matching \"%s\"",
+                                                        pat->pattern);
+                       else if (pat->rel_regex == NULL)
+                               log_no_match("no relations to check in schemas matching \"%s\"",
+                                                        pat->pattern);
+                       else
+                               log_no_match("no relations to check matching \"%s\"",
+                                                        pat->pattern);
                }
        }
 
@@ -749,8 +740,6 @@ main(int argc, char *argv[])
 
                if (opts.verbose)
                        PQsetErrorVerbosity(free_slot->connection, PQERRORS_VERBOSE);
-               else if (opts.quiet)
-                       PQsetErrorVerbosity(free_slot->connection, PQERRORS_TERSE);
 
                /*
                 * Execute the appropriate amcheck command for this relation using our
@@ -1192,7 +1181,6 @@ help(const char *progname)
        printf(_("\nOther options:\n"));
        printf(_("  -e, --echo                      show the commands being sent to the server\n"));
        printf(_("  -j, --jobs=NUM                  use this many concurrent connections to the server\n"));
-       printf(_("  -q, --quiet                     don't write any messages\n"));
        printf(_("  -P, --progress                  show progress information\n"));
        printf(_("  -v, --verbose                   write a lot of output\n"));
        printf(_("  -V, --version                   output version information, then exit\n"));
index 5417959553e59d445657f5cbdcbef1da8bad2d7a..e30c1cc5464b5652454f17ed4a67d12983bbbe85 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgresNode;
 use TestLib;
-use Test::More tests => 72;
+use Test::More tests => 76;
 
 # Test set-up
 my ($node, $port);
@@ -191,6 +191,10 @@ $node->command_checks_all(
                qr/pg_amcheck: warning: no relations to check matching "postgres\.long\.dotted\.string"/,
                qr/pg_amcheck: warning: no relations to check matching "postgres\.pg_catalog\.none"/,
                qr/pg_amcheck: warning: no relations to check matching "postgres\.none\.pg_class"/,
+               qr/pg_amcheck: warning: no connectable databases to check matching "no_such_database"/,
+               qr/pg_amcheck: warning: no connectable databases to check matching "no\*such\*database"/,
+               qr/pg_amcheck: warning: no connectable databases to check matching "none\.none\.none"/,
+               qr/pg_amcheck: warning: no connectable databases to check matching "this\.is\.a\.really\.long\.dotted\.string"/,
        ],
        'many unmatched patterns and one matched pattern under --no-strict-names'
 );
index f3eb41ce3adb4ad7daed73cf3bb9610e7c074b0a..c26e5eda676961a74fd41de55c6561f57d61c2b0 100644 (file)
@@ -317,7 +317,7 @@ plan_to_remove_relation_file('db2', 's1.t1_btree');
 #
 
 # Standard first arguments to TestLib functions
-my @cmd = ('pg_amcheck', '--quiet', '-p', $port);
+my @cmd = ('pg_amcheck', '-p', $port);
 
 # Regular expressions to match various expected output
 my $no_output_re               = qr/^$/;
index 806335375d5894a19ed1cbad960ebf5b35740e81..e87d81d7d42ac51c4fca74610f46858a11a871db 100644 (file)
@@ -34,7 +34,7 @@ $node->safe_psql(
 
 # We have not yet broken the index, so we should get no corruption
 $node->command_like(
-       [ 'pg_amcheck', '--quiet', '-p', $node->port, 'postgres' ],
+       [ 'pg_amcheck', '-p', $node->port, 'postgres' ],
        qr/^$/,
        'pg_amcheck all schemas, tables and indexes reports no corruption');