@@ -351,14 +351,29 @@ XLogDumpCountRecord(XLogDumpConfig *config, XLogDumpStats *stats,
351351uint8 recid ;
352352uint32 rec_len ;
353353uint32 fpi_len ;
354+ int block_id ;
354355
355356stats -> count ++ ;
356357
357- /* Update per-rmgr statistics */
358-
359358rmid = XLogRecGetRmid (record );
360359rec_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
363378stats -> rmgr_stats [rmid ].count ++ ;
364379stats -> rmgr_stats [rmid ].rec_len += rec_len ;