Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c8bf509

Browse files
committed
Allow specifying pg_waldump --rmgr option multiple times.
Before, if you specified multiple --rmgr options, only the last one took effect. It seems more sensible to select all the specified resource managers. Reviewed-By: Daniel Gustafsson, Julien Rouhaud Discussion: https://www.postgresql.org/message-id/98344bc2-e222-02ad-a75b-81ffc614c155%40iki.fi
1 parent 71ba45a commit c8bf509

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

doc/src/sgml/ref/pg_waldump.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ PostgreSQL documentation
142142
<term><option>--rmgr=<replaceable>rmgr</replaceable></option></term>
143143
<listitem>
144144
<para>
145-
Only display records generated by the specified resource manager.
145+
Only display records generated by the specified resource manager. You can
146+
specify the option multiple times to select multiple resource managers.
146147
If <literal>list</literal> is passed as name, print a list of valid resource manager
147148
names, and exit.
148149
</para>

src/bin/pg_waldump/pg_waldump.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ typedef struct XLogDumpConfig
4949
bool stats_per_record;
5050

5151
/* filter options */
52-
int filter_by_rmgr;
52+
bool filter_by_rmgr[RM_MAX_ID + 1];
53+
bool filter_by_rmgr_enabled;
5354
TransactionId filter_by_xid;
5455
bool filter_by_xid_enabled;
5556
} XLogDumpConfig;
@@ -825,7 +826,8 @@ main(int argc, char **argv)
825826
config.stop_after_records = -1;
826827
config.already_displayed_records = 0;
827828
config.follow = false;
828-
config.filter_by_rmgr = -1;
829+
/* filter_by_rmgr array was zeroed by memset above */
830+
config.filter_by_rmgr_enabled = false;
829831
config.filter_by_xid = InvalidTransactionId;
830832
config.filter_by_xid_enabled = false;
831833
config.stats = false;
@@ -884,12 +886,12 @@ main(int argc, char **argv)
884886
{
885887
if (pg_strcasecmp(optarg, RmgrDescTable[i].rm_name) == 0)
886888
{
887-
config.filter_by_rmgr = i;
889+
config.filter_by_rmgr[i] = true;
890+
config.filter_by_rmgr_enabled = true;
888891
break;
889892
}
890893
}
891-
892-
if (config.filter_by_rmgr == -1)
894+
if (i > RM_MAX_ID)
893895
{
894896
pg_log_error("resource manager \"%s\" does not exist",
895897
optarg);
@@ -1098,8 +1100,8 @@ main(int argc, char **argv)
10981100
}
10991101

11001102
/* apply all specified filters */
1101-
if (config.filter_by_rmgr != -1 &&
1102-
config.filter_by_rmgr != record->xl_rmid)
1103+
if (config.filter_by_rmgr_enabled &&
1104+
!config.filter_by_rmgr[record->xl_rmid])
11031105
continue;
11041106

11051107
if (config.filter_by_xid_enabled &&

0 commit comments

Comments
 (0)