diff options
author | Nathan Bossart | 2024-12-04 21:04:15 +0000 |
---|---|---|
committer | Nathan Bossart | 2024-12-04 21:04:15 +0000 |
commit | 76fd342496612c8432ef8f6c71794c935497d3c9 (patch) | |
tree | f2a5310795961aaa9f7c2925e38056415b43028c /src/include | |
parent | 24c1c6338719e4de1dd5f045418e64957781c595 (diff) |
Provide a better error message for misplaced dispatch options.
Before this patch, misplacing a special must-be-first option for
dispatching to a subprogram (e.g., postgres -D . --single) would
fail with an error like
FATAL: --single requires a value
This patch adjusts this error to more accurately complain that the
special option wasn't listed first. The aforementioned error
message now looks like
FATAL: --single must be first argument
The dispatch option parsing code has been refactored for use
wherever ParseLongOption() is called. Beyond the obvious advantage
of avoiding code duplication, this should prevent similar problems
when new dispatch options are added. Note that we assume that none
of the dispatch option names match another valid command-line
argument, such as the name of a configuration parameter.
Ideally, we'd remove this must-be-first requirement for these
options, but after some investigation, we decided that wasn't worth
the added complexity and behavior changes.
Author: Nathan Bossart, Greg Sabino Mullane
Reviewed-by: Greg Sabino Mullane, Peter Eisentraut, Álvaro Herrera, Tom Lane
Discussion: https://postgr.es/m/CAKAnmmJkZtZAiSryho%3DgYpbvC7H-HNjEDAh16F3SoC9LPu8rqQ%40mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/postmaster/postmaster.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/include/postmaster/postmaster.h b/src/include/postmaster/postmaster.h index f05eb1c470b..24d49a5439e 100644 --- a/src/include/postmaster/postmaster.h +++ b/src/include/postmaster/postmaster.h @@ -138,4 +138,21 @@ extern PMChild *FindPostmasterChildByPid(int pid); */ #define MAX_BACKENDS 0x3FFFF +/* + * These values correspond to the special must-be-first options for dispatching + * to various subprograms. parse_dispatch_option() can be used to convert an + * option name to one of these values. + */ +typedef enum DispatchOption +{ + DISPATCH_CHECK, + DISPATCH_BOOT, + DISPATCH_FORKCHILD, + DISPATCH_DESCRIBE_CONFIG, + DISPATCH_SINGLE, + DISPATCH_POSTMASTER, /* must be last */ +} DispatchOption; + +extern DispatchOption parse_dispatch_option(const char *name); + #endif /* _POSTMASTER_H */ |