@@ -489,18 +489,36 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
489
489
*/
490
490
static void
491
491
XLogDumpStatsRow (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 )
496
496
{
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
+
497
515
printf ("%-27s "
498
516
"%20" INT64_MODIFIER "u (%6.02f) "
499
517
"%20" INT64_MODIFIER "u (%6.02f) "
500
518
"%20" INT64_MODIFIER "u (%6.02f) "
501
519
"%20" INT64_MODIFIER "u (%6.02f)\n" ,
502
520
name , 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 );
504
522
}
505
523
506
524
@@ -515,6 +533,7 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
515
533
uint64 total_rec_len = 0 ;
516
534
uint64 total_fpi_len = 0 ;
517
535
uint64 total_len = 0 ;
536
+ double rec_len_pct , fpi_len_pct ;
518
537
519
538
/* ---
520
539
* Make a first pass to calculate column totals:
@@ -557,10 +576,8 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
557
576
tot_len = rec_len + fpi_len ;
558
577
559
578
XLogDumpStatsRow (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 );
564
581
}
565
582
else
566
583
{
@@ -583,10 +600,8 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
583
600
id = psprintf ("UNKNOWN (%x)" , rj << 4 );
584
601
585
602
XLogDumpStatsRow (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 );
590
605
}
591
606
}
592
607
}
@@ -601,14 +616,22 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
601
616
* them from the earlier ones, and are thus up to 9 characters long.
602
617
*/
603
618
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
+
604
627
printf ("%-27s "
605
628
"%20" INT64_MODIFIER "u %-9s"
606
629
"%20" INT64_MODIFIER "u %-9s"
607
630
"%20" INT64_MODIFIER "u %-9s"
608
631
"%20" INT64_MODIFIER "u %-6s\n" ,
609
632
"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 ),
612
635
total_len , "[100%]" );
613
636
}
614
637
0 commit comments