From 7753c925d9220371970e5b4dd9498b041d41976f Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Wed, 7 Oct 2026 02:02:25 +0900 Subject: [PATCH v3] Fix pg_walsummary --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 Reviewed-by: Hayato Kuroda Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/TY5PR01MB18445D1AF87F64E9835BAD0B0FA962@TY5PR01MB18445.jpnprd01.prod.outlook.com Backpatch-through: 17 --- src/bin/pg_walsummary/pg_walsummary.c | 12 ++++++------ src/bin/pg_walsummary/t/002_blocks.pl | 12 ++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/bin/pg_walsummary/pg_walsummary.c b/src/bin/pg_walsummary/pg_walsummary.c index ad674b7646a..07195a603e9 100644 --- a/src/bin/pg_walsummary/pg_walsummary.c +++ b/src/bin/pg_walsummary/pg_walsummary.c @@ -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 diff --git a/src/bin/pg_walsummary/t/002_blocks.pl b/src/bin/pg_walsummary/t/002_blocks.pl index bebc1137c0f..70bbd3a9fac 100644 --- a/src/bin/pg_walsummary/t/002_blocks.pl +++ b/src/bin/pg_walsummary/t/002_blocks.pl @@ -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_checks_all([ 'pg_walsummary', '-q', @summaries ], + 0, [qr/\A\z/], [qr/\A\z/], "-q suppresses all output"); + # The WAL summarizer should have generated some IO statistics. $node1->poll_query_until( 'postgres', -- 2.55.0