1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

pg_walsummary: Fix --quiet to suppress limit block output

Previously, pg_walsummary printed limit block lines even with --quiet
because the output was generated before checking the quiet flag.

Fix this by moving the output after the quiet check.

Backpatch to v17, where pg_walsummary was introduced.

Author: Koshi Shibagaki <shibagaki.koshi@fujitsu.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/TY5PR01MB18445D1AF87F64E9835BAD0B0FA962@TY5PR01MB18445.jpnprd01.prod.outlook.com
Backpatch-through: 17
This commit is contained in:
Fujii Masao
2026-10-07 14:57:41 +09:00
parent 738d19d4ea
commit 2a8ce0f684
2 changed files with 18 additions and 6 deletions

View File

@@ -134,12 +134,6 @@ dump_one_relation(ws_options *opt, RelFileLocator *rlocator,
BlockNumber startblock = InvalidBlockNumber;
BlockNumber endblock = InvalidBlockNumber;
/* Dump limit block, if any. */
if (limit_block != InvalidBlockNumber)
printf("TS %u, DB %u, REL %u, FORK %s: limit %u\n",
rlocator->spcOid, rlocator->dbOid, rlocator->relNumber,
forkNames[forknum], limit_block);
/* If we haven't allocated a block buffer yet, do that now. */
if (block_buffer == NULL)
block_buffer = palloc_array(BlockNumber, block_buffer_size);
@@ -174,6 +168,12 @@ dump_one_relation(ws_options *opt, RelFileLocator *rlocator,
if (opt->quiet)
return;
/* Dump limit block, if any. */
if (limit_block != InvalidBlockNumber)
printf("TS %u, DB %u, REL %u, FORK %s: limit %u\n",
rlocator->spcOid, rlocator->dbOid, rlocator->relNumber,
forkNames[forknum], limit_block);
/*
* Sort the returned block numbers. If the block reference table was using
* the bitmap representation for a given chunk, the block numbers in that

View File

@@ -46,6 +46,18 @@ SELECT EXISTS (
EOM
ok($result, "WAL summarization caught up after insert");
# --quiet must also suppress limit blocks caused by relation creation.
my $summary_dir = $node1->data_dir . '/pg_wal/summaries';
my @summaries = map { "$summary_dir/$_" }
sort grep { /^[0-9A-F]{40}\.summary$/ } slurp_dir($summary_dir);
command_like(
[ 'pg_walsummary', @summaries ],
qr/: limit 0$/m,
'relation creation produces limit blocks');
command_like([ 'pg_walsummary', '-q', @summaries ],
qr/\A\z/, "-q suppresses all output");
# The WAL summarizer should have generated some IO statistics.
$node1->poll_query_until(
'postgres',