Skip to content

Commit 9a9c8b9

Browse files
Remove --quiet option from pg_amcheck
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
1 parent 5b3f471 commit 9a9c8b9

File tree

5 files changed

+20
-40
lines changed

5 files changed

+20
-40
lines changed

doc/src/sgml/ref/pg_amcheck.sgml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,6 @@ PostgreSQL documentation
289289
<literal>--table</literal>, <literal>--index</literal>,
290290
or <literal>--relation</literal> matches no objects, it is a fatal
291291
error. This option downgrades that error to a warning.
292-
If this option is used with <literal>--quiet</literal>, the warning
293-
will be suppressed as well.
294292
</para>
295293
</listitem>
296294
</varlistentry>
@@ -553,16 +551,6 @@ PostgreSQL documentation
553551
</listitem>
554552
</varlistentry>
555553

556-
<varlistentry>
557-
<term><option>-q</option></term>
558-
<term><option>--quiet</option></term>
559-
<listitem>
560-
<para>
561-
Print fewer messages, and less detail regarding any server errors.
562-
</para>
563-
</listitem>
564-
</varlistentry>
565-
566554
<varlistentry>
567555
<term><option>-P</option></term>
568556
<term><option>--progress</option></term>

src/bin/pg_amcheck/pg_amcheck.c

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ typedef struct AmcheckOptions
5656
bool dbpattern;
5757
bool alldb;
5858
bool echo;
59-
bool quiet;
6059
bool verbose;
6160
bool strict_names;
6261
bool show_progress;
@@ -112,7 +111,6 @@ static AmcheckOptions opts = {
112111
.dbpattern = false,
113112
.alldb = false,
114113
.echo = false,
115-
.quiet = false,
116114
.verbose = false,
117115
.strict_names = true,
118116
.show_progress = false,
@@ -250,7 +248,6 @@ main(int argc, char *argv[])
250248
{"exclude-index", required_argument, NULL, 'I'},
251249
{"jobs", required_argument, NULL, 'j'},
252250
{"progress", no_argument, NULL, 'P'},
253-
{"quiet", no_argument, NULL, 'q'},
254251
{"relation", required_argument, NULL, 'r'},
255252
{"exclude-relation", required_argument, NULL, 'R'},
256253
{"schema", required_argument, NULL, 's'},
@@ -294,7 +291,7 @@ main(int argc, char *argv[])
294291
handle_help_version_opts(argc, argv, progname, help);
295292

296293
/* process command-line options */
297-
while ((c = getopt_long(argc, argv, "ad:D:eh:Hi:I:j:p:Pqr:R:s:S:t:T:U:wWv",
294+
while ((c = getopt_long(argc, argv, "ad:D:eh:Hi:I:j:p:Pr:R:s:S:t:T:U:wWv",
298295
long_options, &optindex)) != -1)
299296
{
300297
char *endptr;
@@ -338,9 +335,6 @@ main(int argc, char *argv[])
338335
case 'P':
339336
opts.show_progress = true;
340337
break;
341-
case 'q':
342-
opts.quiet = true;
343-
break;
344338
case 'r':
345339
opts.allrel = false;
346340
append_relation_pattern(&opts.include, optarg, encoding);
@@ -637,21 +631,18 @@ main(int argc, char *argv[])
637631
{
638632
failed = opts.strict_names;
639633

640-
if (!opts.quiet || failed)
641-
{
642-
if (pat->heap_only)
643-
log_no_match("no heap tables to check matching \"%s\"",
644-
pat->pattern);
645-
else if (pat->btree_only)
646-
log_no_match("no btree indexes to check matching \"%s\"",
647-
pat->pattern);
648-
else if (pat->rel_regex == NULL)
649-
log_no_match("no relations to check in schemas matching \"%s\"",
650-
pat->pattern);
651-
else
652-
log_no_match("no relations to check matching \"%s\"",
653-
pat->pattern);
654-
}
634+
if (pat->heap_only)
635+
log_no_match("no heap tables to check matching \"%s\"",
636+
pat->pattern);
637+
else if (pat->btree_only)
638+
log_no_match("no btree indexes to check matching \"%s\"",
639+
pat->pattern);
640+
else if (pat->rel_regex == NULL)
641+
log_no_match("no relations to check in schemas matching \"%s\"",
642+
pat->pattern);
643+
else
644+
log_no_match("no relations to check matching \"%s\"",
645+
pat->pattern);
655646
}
656647
}
657648

@@ -749,8 +740,6 @@ main(int argc, char *argv[])
749740

750741
if (opts.verbose)
751742
PQsetErrorVerbosity(free_slot->connection, PQERRORS_VERBOSE);
752-
else if (opts.quiet)
753-
PQsetErrorVerbosity(free_slot->connection, PQERRORS_TERSE);
754743

755744
/*
756745
* Execute the appropriate amcheck command for this relation using our
@@ -1192,7 +1181,6 @@ help(const char *progname)
11921181
printf(_("\nOther options:\n"));
11931182
printf(_(" -e, --echo show the commands being sent to the server\n"));
11941183
printf(_(" -j, --jobs=NUM use this many concurrent connections to the server\n"));
1195-
printf(_(" -q, --quiet don't write any messages\n"));
11961184
printf(_(" -P, --progress show progress information\n"));
11971185
printf(_(" -v, --verbose write a lot of output\n"));
11981186
printf(_(" -V, --version output version information, then exit\n"));

src/bin/pg_amcheck/t/002_nonesuch.pl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use PostgresNode;
88
use TestLib;
9-
use Test::More tests => 72;
9+
use Test::More tests => 76;
1010

1111
# Test set-up
1212
my ($node, $port);
@@ -191,6 +191,10 @@
191191
qr/pg_amcheck: warning: no relations to check matching "postgres\.long\.dotted\.string"/,
192192
qr/pg_amcheck: warning: no relations to check matching "postgres\.pg_catalog\.none"/,
193193
qr/pg_amcheck: warning: no relations to check matching "postgres\.none\.pg_class"/,
194+
qr/pg_amcheck: warning: no connectable databases to check matching "no_such_database"/,
195+
qr/pg_amcheck: warning: no connectable databases to check matching "no\*such\*database"/,
196+
qr/pg_amcheck: warning: no connectable databases to check matching "none\.none\.none"/,
197+
qr/pg_amcheck: warning: no connectable databases to check matching "this\.is\.a\.really\.long\.dotted\.string"/,
194198
],
195199
'many unmatched patterns and one matched pattern under --no-strict-names'
196200
);

src/bin/pg_amcheck/t/003_check.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ ()
317317
#
318318

319319
# Standard first arguments to TestLib functions
320-
my @cmd = ('pg_amcheck', '--quiet', '-p', $port);
320+
my @cmd = ('pg_amcheck', '-p', $port);
321321

322322
# Regular expressions to match various expected output
323323
my $no_output_re = qr/^$/;

src/bin/pg_amcheck/t/005_opclass_damage.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
# We have not yet broken the index, so we should get no corruption
3636
$node->command_like(
37-
[ 'pg_amcheck', '--quiet', '-p', $node->port, 'postgres' ],
37+
[ 'pg_amcheck', '-p', $node->port, 'postgres' ],
3838
qr/^$/,
3939
'pg_amcheck all schemas, tables and indexes reports no corruption');
4040

0 commit comments

Comments
 (0)