@@ -489,18 +489,36 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
489489 */
490490static void
491491XLogDumpStatsRow (const char * name ,
492- uint64 n ,double n_pct ,
493- uint64 rec_len ,double rec_len_pct ,
494- uint64 fpi_len ,double fpi_len_pct ,
495- uint64 total_len , double total_len_pct )
492+ uint64 n ,uint64 total_count ,
493+ uint64 rec_len ,uint64 total_rec_len ,
494+ uint64 fpi_len ,uint64 total_fpi_len ,
495+ uint64 tot_len , uint64 total_len )
496496{
497+ double n_pct ,rec_len_pct ,fpi_len_pct ,tot_len_pct ;
498+
499+ n_pct = 0 ;
500+ if (total_count != 0 )
501+ n_pct = 100 * (double )n /total_count ;
502+
503+ rec_len_pct = 0 ;
504+ if (total_rec_len != 0 )
505+ rec_len_pct = 100 * (double )rec_len /total_rec_len ;
506+
507+ fpi_len_pct = 0 ;
508+ if (total_fpi_len != 0 )
509+ fpi_len_pct = 100 * (double )fpi_len /total_fpi_len ;
510+
511+ tot_len_pct = 0 ;
512+ if (total_len != 0 )
513+ tot_len_pct = 100 * (double )tot_len /total_len ;
514+
497515printf ("%-27s "
498516"%20" INT64_MODIFIER "u (%6.02f) "
499517"%20" INT64_MODIFIER "u (%6.02f) "
500518"%20" INT64_MODIFIER "u (%6.02f) "
501519"%20" INT64_MODIFIER "u (%6.02f)\n" ,
502520name ,n ,n_pct ,rec_len ,rec_len_pct ,fpi_len ,fpi_len_pct ,
503- total_len , total_len_pct );
521+ tot_len , tot_len_pct );
504522}
505523
506524
@@ -515,6 +533,7 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
515533uint64 total_rec_len = 0 ;
516534uint64 total_fpi_len = 0 ;
517535uint64 total_len = 0 ;
536+ double rec_len_pct ,fpi_len_pct ;
518537
519538/* ---
520539 * Make a first pass to calculate column totals:
@@ -557,10 +576,8 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
557576tot_len = rec_len + fpi_len ;
558577
559578XLogDumpStatsRow (desc -> rm_name ,
560- count ,100 * (double )count /total_count ,
561- rec_len ,100 * (double )rec_len /total_rec_len ,
562- fpi_len ,100 * (double )fpi_len /total_fpi_len ,
563- tot_len ,100 * (double )tot_len /total_len );
579+ count ,total_count ,rec_len ,total_rec_len ,
580+ fpi_len ,total_fpi_len ,tot_len ,total_len );
564581}
565582else
566583{
@@ -583,10 +600,8 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
583600id = psprintf ("UNKNOWN (%x)" ,rj <<4 );
584601
585602XLogDumpStatsRow (psprintf ("%s/%s" ,desc -> rm_name ,id ),
586- count ,100 * (double )count /total_count ,
587- rec_len ,100 * (double )rec_len /total_rec_len ,
588- fpi_len ,100 * (double )fpi_len /total_fpi_len ,
589- tot_len ,100 * (double )tot_len /total_len );
603+ count ,total_count ,rec_len ,total_rec_len ,
604+ fpi_len ,total_fpi_len ,tot_len ,total_len );
590605}
591606}
592607}
@@ -601,14 +616,22 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
601616 * them from the earlier ones, and are thus up to 9 characters long.
602617 */
603618
619+ rec_len_pct = 0 ;
620+ if (total_len != 0 )
621+ rec_len_pct = 100 * (double )total_rec_len /total_len ;
622+
623+ fpi_len_pct = 0 ;
624+ if (total_len != 0 )
625+ fpi_len_pct = 100 * (double )total_fpi_len /total_len ;
626+
604627printf ("%-27s "
605628"%20" INT64_MODIFIER "u %-9s"
606629"%20" INT64_MODIFIER "u %-9s"
607630"%20" INT64_MODIFIER "u %-9s"
608631"%20" INT64_MODIFIER "u %-6s\n" ,
609632"Total" ,stats -> count ,"" ,
610- total_rec_len ,psprintf ("[%.02f%%]" ,100 * ( double ) total_rec_len / total_len ),
611- total_fpi_len ,psprintf ("[%.02f%%]" ,100 * ( double ) total_fpi_len / total_len ),
633+ total_rec_len ,psprintf ("[%.02f%%]" ,rec_len_pct ),
634+ total_fpi_len ,psprintf ("[%.02f%%]" ,fpi_len_pct ),
612635total_len ,"[100%]" );
613636}
614637