diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2021-07-01 15:32:57 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2021-07-01 15:32:57 +0300 |
commit | c8bf5098cbc4f32ca724d830d45d5ceb2ad7f96d (patch) | |
tree | ccd95069f1c161b23ef00d9838d3024f31315e9d | |
parent | 71ba45a3602da0bdbb518e16e3990cfcf21e5f73 (diff) | |
download | postgresql-c8bf5098cbc4f32ca724d830d45d5ceb2ad7f96d.tar.gz postgresql-c8bf5098cbc4f32ca724d830d45d5ceb2ad7f96d.zip |
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
-rw-r--r-- | doc/src/sgml/ref/pg_waldump.sgml | 3 | ||||
-rw-r--r-- | src/bin/pg_waldump/pg_waldump.c | 16 |
2 files changed, 11 insertions, 8 deletions
diff --git a/doc/src/sgml/ref/pg_waldump.sgml b/doc/src/sgml/ref/pg_waldump.sgml index 5fcdfe210ac..432254d2d5d 100644 --- a/doc/src/sgml/ref/pg_waldump.sgml +++ b/doc/src/sgml/ref/pg_waldump.sgml @@ -142,7 +142,8 @@ PostgreSQL documentation <term><option>--rmgr=<replaceable>rmgr</replaceable></option></term> <listitem> <para> - Only display records generated by the specified resource manager. + Only display records generated by the specified resource manager. You can + specify the option multiple times to select multiple resource managers. If <literal>list</literal> is passed as name, print a list of valid resource manager names, and exit. </para> diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index d83847b276d..74664bef6a4 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -49,7 +49,8 @@ typedef struct XLogDumpConfig bool stats_per_record; /* filter options */ - int filter_by_rmgr; + bool filter_by_rmgr[RM_MAX_ID + 1]; + bool filter_by_rmgr_enabled; TransactionId filter_by_xid; bool filter_by_xid_enabled; } XLogDumpConfig; @@ -825,7 +826,8 @@ main(int argc, char **argv) config.stop_after_records = -1; config.already_displayed_records = 0; config.follow = false; - config.filter_by_rmgr = -1; + /* filter_by_rmgr array was zeroed by memset above */ + config.filter_by_rmgr_enabled = false; config.filter_by_xid = InvalidTransactionId; config.filter_by_xid_enabled = false; config.stats = false; @@ -884,12 +886,12 @@ main(int argc, char **argv) { if (pg_strcasecmp(optarg, RmgrDescTable[i].rm_name) == 0) { - config.filter_by_rmgr = i; + config.filter_by_rmgr[i] = true; + config.filter_by_rmgr_enabled = true; break; } } - - if (config.filter_by_rmgr == -1) + if (i > RM_MAX_ID) { pg_log_error("resource manager \"%s\" does not exist", optarg); @@ -1098,8 +1100,8 @@ main(int argc, char **argv) } /* apply all specified filters */ - if (config.filter_by_rmgr != -1 && - config.filter_by_rmgr != record->xl_rmid) + if (config.filter_by_rmgr_enabled && + !config.filter_by_rmgr[record->xl_rmid]) continue; if (config.filter_by_xid_enabled && |