1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

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
This commit is contained in:
Heikki Linnakangas
2021-07-01 15:32:57 +03:00
parent 71ba45a360
commit c8bf5098cb
2 changed files with 11 additions and 8 deletions

View File

@ -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 &&