Skip to content

Commit 25f915b

Browse files
committed
pg_waldump: Improve option parsing error messages
I rephrased the error messages to be more in the style of option_parse_int(), and also made use of the new "detail" message facility. I didn't actually use option_parse_int() (which could be used for -n) because libpgfeutils wasn't used here yet and I wanted to keep this just to string changes. But it could be done in the future.
1 parent 1d8ef62 commit 25f915b

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/bin/pg_waldump/pg_waldump.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ main(int argc, char **argv)
794794
if (sscanf(optarg, "%u", &config.filter_by_relation_block) != 1 ||
795795
!BlockNumberIsValid(config.filter_by_relation_block))
796796
{
797-
pg_log_error("could not parse valid block number \"%s\"", optarg);
797+
pg_log_error("invalid block number: \"%s\"", optarg);
798798
goto bad_argument;
799799
}
800800
config.filter_by_relation_block_enabled = true;
@@ -803,7 +803,7 @@ main(int argc, char **argv)
803803
case 'e':
804804
if (sscanf(optarg, "%X/%X", &xlogid, &xrecoff) != 2)
805805
{
806-
pg_log_error("could not parse end WAL location \"%s\"",
806+
pg_log_error("invalid WAL location: \"%s\"",
807807
optarg);
808808
goto bad_argument;
809809
}
@@ -816,15 +816,15 @@ main(int argc, char **argv)
816816
config.filter_by_relation_forknum = forkname_to_number(optarg);
817817
if (config.filter_by_relation_forknum == InvalidForkNumber)
818818
{
819-
pg_log_error("could not parse fork \"%s\"", optarg);
819+
pg_log_error("invalid fork name: \"%s\"", optarg);
820820
goto bad_argument;
821821
}
822822
config.filter_by_extended = true;
823823
break;
824824
case 'n':
825825
if (sscanf(optarg, "%d", &config.stop_after_records) != 1)
826826
{
827-
pg_log_error("could not parse limit \"%s\"", optarg);
827+
pg_log_error("invalid value \"%s\" for option %s", optarg, "-n/--limit");
828828
goto bad_argument;
829829
}
830830
break;
@@ -891,9 +891,8 @@ main(int argc, char **argv)
891891
!OidIsValid(config.filter_by_relation.spcNode) ||
892892
!OidIsValid(config.filter_by_relation.relNode))
893893
{
894-
pg_log_error("could not parse valid relation from \"%s\""
895-
" (expecting \"tablespace OID/database OID/"
896-
"relation filenode\")", optarg);
894+
pg_log_error("invalid relation specification: \"%s\"", optarg);
895+
pg_log_error_detail("Expecting \"tablespace OID/database OID/relation filenode\".");
897896
goto bad_argument;
898897
}
899898
config.filter_by_relation_enabled = true;
@@ -902,7 +901,7 @@ main(int argc, char **argv)
902901
case 's':
903902
if (sscanf(optarg, "%X/%X", &xlogid, &xrecoff) != 2)
904903
{
905-
pg_log_error("could not parse start WAL location \"%s\"",
904+
pg_log_error("invalid WAL location: \"%s\"",
906905
optarg);
907906
goto bad_argument;
908907
}
@@ -912,7 +911,7 @@ main(int argc, char **argv)
912911
case 't':
913912
if (sscanf(optarg, "%u", &private.timeline) != 1)
914913
{
915-
pg_log_error("could not parse timeline \"%s\"", optarg);
914+
pg_log_error("invalid timeline specification: \"%s\"", optarg);
916915
goto bad_argument;
917916
}
918917
break;
@@ -922,7 +921,7 @@ main(int argc, char **argv)
922921
case 'x':
923922
if (sscanf(optarg, "%u", &config.filter_by_xid) != 1)
924923
{
925-
pg_log_error("could not parse \"%s\" as a transaction ID",
924+
pg_log_error("invalid transaction ID specification: \"%s\"",
926925
optarg);
927926
goto bad_argument;
928927
}
@@ -937,8 +936,8 @@ main(int argc, char **argv)
937936
config.stats_per_record = true;
938937
else if (strcmp(optarg, "rmgr") != 0)
939938
{
940-
pg_log_error("unrecognized argument to --stats: %s",
941-
optarg);
939+
pg_log_error("unrecognized value for option %s: %s",
940+
"--stats", optarg);
942941
goto bad_argument;
943942
}
944943
}
@@ -951,7 +950,8 @@ main(int argc, char **argv)
951950
if (config.filter_by_relation_block_enabled &&
952951
!config.filter_by_relation_enabled)
953952
{
954-
pg_log_error("--block option requires --relation option to be specified");
953+
pg_log_error("option %s requires option %s to be specified",
954+
"-B/--block", "-R/--relation");
955955
goto bad_argument;
956956
}
957957

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy