Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitac44367

Browse files
committed
pg_waldump: Add a --quiet option.
The primary motivation for this change is that it will be used by theupcoming patch to add backup manifests, but it also seems to have somepotential more general use.Andres Freund and Robert HaasDiscussion:http://postgr.es/m/20200330020814.nspra4mvby42yoa4@alap3.anarazel.de
1 parent7cb0a42 commitac44367

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

‎doc/src/sgml/ref/pg_waldump.sgml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ PostgreSQL documentation
125125
</listitem>
126126
</varlistentry>
127127

128+
<varlistentry>
129+
<term><option>-q</option></term>
130+
<term><option>--quiet</option></term>
131+
<listitem>
132+
<para>
133+
Do not print any output, except for errors. This option can be useful
134+
when you want to know whether a range of WAL records can be
135+
successfully parsed but don't care about the record contents.
136+
</para>
137+
</listitem>
138+
</varlistentry>
139+
128140
<varlistentry>
129141
<term><option>-r <replaceable>rmgr</replaceable></option></term>
130142
<term><option>--rmgr=<replaceable>rmgr</replaceable></option></term>

‎src/bin/pg_waldump/pg_waldump.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ typedef struct XLogDumpPrivate
4040
typedefstructXLogDumpConfig
4141
{
4242
/* display options */
43+
boolquiet;
4344
boolbkp_details;
4445
intstop_after_records;
4546
intalready_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
gotobad_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
inti;
@@ -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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp