Skip to content

Commit 92ce7f5

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 88cfcbb commit 92ce7f5

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
@@ -55,7 +55,6 @@ typedef struct AmcheckOptions
5555
bool dbpattern;
5656
bool alldb;
5757
bool echo;
58-
bool quiet;
5958
bool verbose;
6059
bool strict_names;
6160
bool show_progress;
@@ -111,7 +110,6 @@ static AmcheckOptions opts = {
111110
.dbpattern = false,
112111
.alldb = false,
113112
.echo = false,
114-
.quiet = false,
115113
.verbose = false,
116114
.strict_names = true,
117115
.show_progress = false,
@@ -249,7 +247,6 @@ main(int argc, char *argv[])
249247
{"exclude-index", required_argument, NULL, 'I'},
250248
{"jobs", required_argument, NULL, 'j'},
251249
{"progress", no_argument, NULL, 'P'},
252-
{"quiet", no_argument, NULL, 'q'},
253250
{"relation", required_argument, NULL, 'r'},
254251
{"exclude-relation", required_argument, NULL, 'R'},
255252
{"schema", required_argument, NULL, 's'},
@@ -293,7 +290,7 @@ main(int argc, char *argv[])
293290
handle_help_version_opts(argc, argv, progname, help);
294291

295292
/* process command-line options */
296-
while ((c = getopt_long(argc, argv, "ad:D:eh:Hi:I:j:p:Pqr:R:s:S:t:T:U:wWv",
293+
while ((c = getopt_long(argc, argv, "ad:D:eh:Hi:I:j:p:Pr:R:s:S:t:T:U:wWv",
297294
long_options, &optindex)) != -1)
298295
{
299296
char *endptr;
@@ -340,9 +337,6 @@ main(int argc, char *argv[])
340337
case 'P':
341338
opts.show_progress = true;
342339
break;
343-
case 'q':
344-
opts.quiet = true;
345-
break;
346340
case 'r':
347341
opts.allrel = false;
348342
append_relation_pattern(&opts.include, optarg, encoding);
@@ -639,21 +633,18 @@ main(int argc, char *argv[])
639633
{
640634
failed = opts.strict_names;
641635

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

@@ -751,8 +742,6 @@ main(int argc, char *argv[])
751742

752743
if (opts.verbose)
753744
PQsetErrorVerbosity(free_slot->connection, PQERRORS_VERBOSE);
754-
else if (opts.quiet)
755-
PQsetErrorVerbosity(free_slot->connection, PQERRORS_TERSE);
756745

757746
/*
758747
* Execute the appropriate amcheck command for this relation using our
@@ -1194,7 +1183,6 @@ help(const char *progname)
11941183
printf(_("\nOther options:\n"));
11951184
printf(_(" -e, --echo show the commands being sent to the server\n"));
11961185
printf(_(" -j, --jobs=NUM use this many concurrent connections to the server\n"));
1197-
printf(_(" -q, --quiet don't write any messages\n"));
11981186
printf(_(" -P, --progress show progress information\n"));
11991187
printf(_(" -v, --verbose write a lot of output\n"));
12001188
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)