Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c8d5d6c

Browse files
committed
Fix limit block handling in pg_wal_summary_contents().
Previously, pg_wal_summary_contents() had two issues, causing discrepancies between pg_wal_summary_contents() and the pg_walsummary command on the same WAL summary file: (1) It did not emit the limit block when that's the only data for a particular relation fork. (2) It emitted the same limit block multiple times if the list of block numbers was long enough. This commit fixes these issues. Backpatch to v17 where pg_wal_summary_contents() was added. Author: Fujii Masao Reviewed-by: Robert Haas Discussion: https://postgr.es/m/90980ee6-2da6-42f6-a7b0-b7bae62ae279@oss.nttdata.com
1 parent 5a1e6df commit c8d5d6c

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/backend/backup/walsummaryfuncs.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,23 @@ pg_wal_summary_contents(PG_FUNCTION_ARGS)
118118
values[2] = ObjectIdGetDatum(rlocator.dbOid);
119119
values[3] = Int16GetDatum((int16) forknum);
120120

121+
/*
122+
* If the limit block is not InvalidBlockNumber, emit an extra row
123+
* with that block number and limit_block = true.
124+
*
125+
* There is no point in doing this when the limit_block is
126+
* InvalidBlockNumber, because no block with that number or any higher
127+
* number can ever exist.
128+
*/
129+
if (BlockNumberIsValid(limit_block))
130+
{
131+
values[4] = Int64GetDatum((int64) limit_block);
132+
values[5] = BoolGetDatum(true);
133+
134+
tuple = heap_form_tuple(rsi->setDesc, values, nulls);
135+
tuplestore_puttuple(rsi->setResult, tuple);
136+
}
137+
121138
/* Loop over blocks within the current relation fork. */
122139
while (1)
123140
{
@@ -143,23 +160,6 @@ pg_wal_summary_contents(PG_FUNCTION_ARGS)
143160
tuple = heap_form_tuple(rsi->setDesc, values, nulls);
144161
tuplestore_puttuple(rsi->setResult, tuple);
145162
}
146-
147-
/*
148-
* If the limit block is not InvalidBlockNumber, emit an extra row
149-
* with that block number and limit_block = true.
150-
*
151-
* There is no point in doing this when the limit_block is
152-
* InvalidBlockNumber, because no block with that number or any
153-
* higher number can ever exist.
154-
*/
155-
if (BlockNumberIsValid(limit_block))
156-
{
157-
values[4] = Int64GetDatum((int64) limit_block);
158-
values[5] = BoolGetDatum(true);
159-
160-
tuple = heap_form_tuple(rsi->setDesc, values, nulls);
161-
tuplestore_puttuple(rsi->setResult, tuple);
162-
}
163163
}
164164
}
165165

0 commit comments

Comments
 (0)