diff options
author | Heikki Linnakangas | 2014-12-05 09:39:40 +0000 |
---|---|---|
committer | Heikki Linnakangas | 2014-12-05 09:40:27 +0000 |
commit | ebc2b681b8ffa597137aa7a19619e6a21176e928 (patch) | |
tree | 831ea4ce4c1d4d13e04356bba0b1989b5df3c839 | |
parent | 9a946298338e4783fcc98e0896712fdf2b2bfd56 (diff) |
Fix pg_xlogdump's calculation of full-page image data.
The old formula was completely bogus with the new WAL record format.
-rw-r--r-- | contrib/pg_xlogdump/pg_xlogdump.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/contrib/pg_xlogdump/pg_xlogdump.c b/contrib/pg_xlogdump/pg_xlogdump.c index 26556dc82d..9f05e254a8 100644 --- a/contrib/pg_xlogdump/pg_xlogdump.c +++ b/contrib/pg_xlogdump/pg_xlogdump.c @@ -351,14 +351,29 @@ XLogDumpCountRecord(XLogDumpConfig *config, XLogDumpStats *stats, uint8 recid; uint32 rec_len; uint32 fpi_len; + int block_id; stats->count++; - /* Update per-rmgr statistics */ - rmid = XLogRecGetRmid(record); rec_len = XLogRecGetDataLen(record) + SizeOfXLogRecord; - fpi_len = record->decoded_record->xl_tot_len - rec_len; + + /* + * Calculate the amount of FPI data in the record. Each backup block + * takes up BLCKSZ bytes, minus the "hole" length. + * + * XXX: We peek into xlogreader's private decoded backup blocks for the + * hole_length. It doesn't seem worth it to add an accessor macro for + * this. + */ + fpi_len = 0; + for (block_id = 0; block_id <= record->max_block_id; block_id++) + { + if (XLogRecHasBlockImage(record, block_id)) + fpi_len += BLCKSZ - record->blocks[block_id].hole_length; + } + + /* Update per-rmgr statistics */ stats->rmgr_stats[rmid].count++; stats->rmgr_stats[rmid].rec_len += rec_len; |