@@ -351,14 +351,29 @@ XLogDumpCountRecord(XLogDumpConfig *config, XLogDumpStats *stats,
351
351
uint8 recid ;
352
352
uint32 rec_len ;
353
353
uint32 fpi_len ;
354
+ int block_id ;
354
355
355
356
stats -> count ++ ;
356
357
357
- /* Update per-rmgr statistics */
358
-
359
358
rmid = XLogRecGetRmid (record );
360
359
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 */
362
377
363
378
stats -> rmgr_stats [rmid ].count ++ ;
364
379
stats -> rmgr_stats [rmid ].rec_len += rec_len ;