@@ -40,6 +40,7 @@ typedef struct XLogDumpPrivate
4040typedef struct XLogDumpConfig
4141{
4242 /* display options */
43+ bool quiet ;
4344 bool bkp_details ;
4445 int stop_after_records ;
4546 int already_displayed_records ;
@@ -720,6 +721,7 @@ usage(void)
720721 printf (_ (" -p, --path=PATH directory in which to find log segment files or a\n"
721722 " directory with a ./pg_wal that contains such files\n"
722723 " (default: current directory, ./pg_wal, $PGDATA/pg_wal)\n" ));
724+ printf (_ (" -q, --quiet do not print any output, except for errors\n" ));
723725 printf (_ (" -r, --rmgr=RMGR only show records generated by resource manager RMGR;\n"
724726 " use --rmgr=list to list valid resource manager names\n" ));
725727 printf (_ (" -s, --start=RECPTR start reading at WAL location RECPTR\n" ));
@@ -755,6 +757,7 @@ main(int argc, char **argv)
755757 {"help" , no_argument , NULL , '?' },
756758 {"limit" , required_argument , NULL , 'n' },
757759 {"path" , required_argument , NULL , 'p' },
760+ {"quiet" , no_argument , NULL , 'q' },
758761 {"rmgr" , required_argument , NULL , 'r' },
759762 {"start" , required_argument , NULL , 's' },
760763 {"timeline" , required_argument , NULL , 't' },
@@ -794,6 +797,7 @@ main(int argc, char **argv)
794797 private .endptr = InvalidXLogRecPtr ;
795798 private .endptr_reached = false;
796799
800+ config .quiet = false;
797801 config .bkp_details = false;
798802 config .stop_after_records = -1 ;
799803 config .already_displayed_records = 0 ;
@@ -810,7 +814,7 @@ main(int argc, char **argv)
810814 goto bad_argument ;
811815 }
812816
813- while ((option = getopt_long (argc , argv , "be:fn:p:r :s:t:x:z" ,
817+ while ((option = getopt_long (argc , argv , "be:fn:p:qr :s:t:x:z" ,
814818 long_options , & optindex )) != -1 )
815819 {
816820 switch (option )
@@ -840,6 +844,9 @@ main(int argc, char **argv)
840844 case 'p' :
841845 waldir = pg_strdup (optarg );
842846 break ;
847+ case 'q' :
848+ config .quiet = true;
849+ break ;
843850 case 'r' :
844851 {
845852 int i ;
@@ -1075,11 +1082,14 @@ main(int argc, char **argv)
10751082 config .filter_by_xid != record -> xl_xid )
10761083 continue ;
10771084
1078- /* process the record */
1079- if (config .stats == true)
1080- XLogDumpCountRecord (& config , & stats , xlogreader_state );
1081- else
1082- XLogDumpDisplayRecord (& config , xlogreader_state );
1085+ /* perform any per-record work */
1086+ if (!config .quiet )
1087+ {
1088+ if (config .stats == true)
1089+ XLogDumpCountRecord (& config , & stats , xlogreader_state );
1090+ else
1091+ XLogDumpDisplayRecord (& config , xlogreader_state );
1092+ }
10831093
10841094 /* check whether we printed enough */
10851095 config .already_displayed_records ++ ;
0 commit comments