diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-12-31 12:16:57 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-12-31 12:16:57 -0500 |
commit | c35249939b3addf8dc2f57d9213e8aeadc7bccd1 (patch) | |
tree | 1d7107a34132cbac8e7b1b3f29c5cd5b25c547ce /src/bin/psql/settings.h | |
parent | 4e241f7cdf21c293701946cc7f060c8ea5fbcda1 (diff) |
Improve consistency of parsing of psql's magic variables.
For simple boolean variables such as ON_ERROR_STOP, psql has for a long
time recognized variant spellings of "on" and "off" (such as "1"/"0"),
and it also made a point of warning you if you'd misspelled the setting.
But these conveniences did not exist for other keyword-valued variables.
In particular, though ECHO_HIDDEN and ON_ERROR_ROLLBACK include "on" and
"off" as possible values, none of the alternative spellings for those were
recognized; and to make matters worse the code would just silently assume
"on" was meant for any unrecognized spelling. Several people have reported
getting bitten by this, so let's fix it. In detail, this patch:
* Allows all spellings recognized by ParseVariableBool() for ECHO_HIDDEN
and ON_ERROR_ROLLBACK.
* Reports a warning for unrecognized values for COMP_KEYWORD_CASE, ECHO,
ECHO_HIDDEN, HISTCONTROL, ON_ERROR_ROLLBACK, and VERBOSITY.
* Recognizes all values for all these variables case-insensitively;
previously there was a mishmash of case-sensitive and case-insensitive
behaviors.
Back-patch to all supported branches. There is a small risk of breaking
existing scripts that were accidentally failing to malfunction; but the
consensus is that the chance of detecting real problems and preventing
future mistakes outweighs this.
Diffstat (limited to 'src/bin/psql/settings.h')
-rw-r--r-- | src/bin/psql/settings.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h index 0a60e6817b2..5e3e92a8e98 100644 --- a/src/bin/psql/settings.h +++ b/src/bin/psql/settings.h @@ -27,6 +27,11 @@ #define DEFAULT_PROMPT2 "%/%R%# " #define DEFAULT_PROMPT3 ">> " +/* + * Note: these enums should generally be chosen so that zero corresponds + * to the default behavior. + */ + typedef enum { PSQL_ECHO_NONE, @@ -50,6 +55,14 @@ typedef enum typedef enum { + PSQL_COMP_CASE_PRESERVE_UPPER, + PSQL_COMP_CASE_PRESERVE_LOWER, + PSQL_COMP_CASE_UPPER, + PSQL_COMP_CASE_LOWER +} PSQL_COMP_CASE; + +typedef enum +{ hctl_none = 0, hctl_ignorespace = 1, hctl_ignoredups = 2, @@ -108,6 +121,7 @@ typedef struct _psqlSettings PSQL_ECHO echo; PSQL_ECHO_HIDDEN echo_hidden; PSQL_ERROR_ROLLBACK on_error_rollback; + PSQL_COMP_CASE comp_case; HistControl histcontrol; const char *prompt1; const char *prompt2; |