Skip to content

Commit ebc2b68

Browse files
committed
Fix pg_xlogdump's calculation of full-page image data.
The old formula was completely bogus with the new WAL record format.
1 parent 9a94629 commit ebc2b68

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

contrib/pg_xlogdump/pg_xlogdump.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,29 @@ XLogDumpCountRecord(XLogDumpConfig *config, XLogDumpStats *stats,
351351
uint8 recid;
352352
uint32 rec_len;
353353
uint32 fpi_len;
354+
int block_id;
354355

355356
stats->count++;
356357

357-
/* Update per-rmgr statistics */
358-
359358
rmid = XLogRecGetRmid(record);
360359
rec_len = XLogRecGetDataLen(record) + SizeOfXLogRecord;
361-
fpi_len = record->decoded_record->xl_tot_len - rec_len;
360+
361+
/*
362+
* Calculate the amount of FPI data in the record. Each backup block
363+
* takes up BLCKSZ bytes, minus the "hole" length.
364+
*
365+
* XXX: We peek into xlogreader's private decoded backup blocks for the
366+
* hole_length. It doesn't seem worth it to add an accessor macro for
367+
* this.
368+
*/
369+
fpi_len = 0;
370+
for (block_id = 0; block_id <= record->max_block_id; block_id++)
371+
{
372+
if (XLogRecHasBlockImage(record, block_id))
373+
fpi_len += BLCKSZ - record->blocks[block_id].hole_length;
374+
}
375+
376+
/* Update per-rmgr statistics */
362377

363378
stats->rmgr_stats[rmid].count++;
364379
stats->rmgr_stats[rmid].rec_len += rec_len;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy