From e276c28414645022ead3f33e6a6bc11ae0479496 Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Fri, 25 Mar 2022 00:22:01 +1300 Subject: [PATCH v2] Use fork names, not numbers, in pg_waldump option. Improvement for commit 127aea2a. Suggested-by: Peter Eisentraut Discussion: https://postgr.es/m/3a4c2e93-7976-2320-fc0a-32097fe148a7%40enterprisedb.com --- doc/src/sgml/ref/pg_waldump.sgml | 8 ++++---- src/bin/pg_waldump/pg_waldump.c | 15 +++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/doc/src/sgml/ref/pg_waldump.sgml b/doc/src/sgml/ref/pg_waldump.sgml index 981d3c9038..9e1b91683d 100644 --- a/doc/src/sgml/ref/pg_waldump.sgml +++ b/doc/src/sgml/ref/pg_waldump.sgml @@ -118,10 +118,10 @@ PostgreSQL documentation If provided, only display records that modify blocks in the given fork. - The valid values are 0 for the main fork, - 1 for the free space map, - 2 for the visibility map, - and 3 for the init fork. + The valid values are main for the main fork, + fsm for the free space map, + vm for the visibility map, + and init for the init fork. diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index 92238f30c9..bb6b7576fd 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -828,8 +828,8 @@ usage(void) printf(_(" -e, --end=RECPTR stop reading at WAL location RECPTR\n")); printf(_(" -f, --follow keep retrying after reaching end of WAL\n")); printf(_(" -k, --block=N with --relation, only show records matching this block\n")); - printf(_(" -F, --fork=N only show records matching a specific fork number\n" - " (defaults to showing all)\n")); + printf(_(" -F, --fork=FORK only show records matching a specific fork;\n" + " valid fork names are main, fsm, vm, init\n")); printf(_(" -l, --relation=N/N/N only show records that affect a specific relation\n")); printf(_(" -n, --limit=N number of records to display\n")); printf(_(" -p, --path=PATH directory in which to find log segment files or a\n" @@ -968,16 +968,15 @@ main(int argc, char **argv) break; case 'F': { - unsigned int forknum; + ForkNumber forknum; - if (sscanf(optarg, "%u", &forknum) != 1 || - forknum > MAX_FORKNUM) + forknum = forkname_to_number(optarg); + if (forknum == InvalidForkNumber) { - pg_log_error("could not parse valid fork number (0..%d) \"%s\"", - MAX_FORKNUM, optarg); + pg_log_error("could not parse fork \"%s\"", optarg); goto bad_argument; } - config.filter_by_relation_forknum = (ForkNumber) forknum; + config.filter_by_relation_forknum = forknum; config.filter_by_extended = true; } break; -- 2.30.2