diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-06-02 18:50:15 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-06-02 18:50:23 -0400 |
commit | 2955c2be79b35fa369c83fa3b5f44661cb88afa9 (patch) | |
tree | 061cd7a9b9c0bedf03d43d34cd5edd11d213e256 /src/backend/utils/misc | |
parent | 8e03eb92e9ad54e2f1ed8b5a73617601f6262f81 (diff) | |
download | postgresql-2955c2be79b35fa369c83fa3b5f44661cb88afa9.tar.gz postgresql-2955c2be79b35fa369c83fa3b5f44661cb88afa9.zip |
Re-allow custom GUC names that have more than two components.
Commit 3db826bd5 disallowed this case, but it turns out that some
people are depending on it. Since the core grammar has allowed
it since 3dc37cd8d, it seems like this code should fall in line.
Per bug #17045 from Robert Sosinski.
Discussion: https://postgr.es/m/17045-6a4a9f0d1513f72b@postgresql.org
Diffstat (limited to 'src/backend/utils/misc')
-rw-r--r-- | src/backend/utils/misc/guc.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 87bc6887046..68b62d523dc 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -5368,13 +5368,14 @@ add_guc_variable(struct config_generic *var, int elevel) /* * Decide whether a proposed custom variable name is allowed. * - * It must be "identifier.identifier", where the rules for what is an - * identifier agree with scan.l. + * It must be two or more identifiers separated by dots, where the rules + * for what is an identifier agree with scan.l. (If you change this rule, + * adjust the errdetail in find_option().) */ static bool valid_custom_variable_name(const char *name) { - int num_sep = 0; + bool saw_sep = false; bool name_start = true; for (const char *p = name; *p; p++) @@ -5383,7 +5384,7 @@ valid_custom_variable_name(const char *name) { if (name_start) return false; /* empty name component */ - num_sep++; + saw_sep = true; name_start = true; } else if (strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -5400,8 +5401,8 @@ valid_custom_variable_name(const char *name) } if (name_start) return false; /* empty name component */ - /* OK if we had exactly one separator */ - return (num_sep == 1); + /* OK if we found at least one separator */ + return saw_sep; } /* @@ -5516,7 +5517,7 @@ find_option(const char *name, bool create_placeholders, bool skip_errors, (errcode(ERRCODE_INVALID_NAME), errmsg("invalid configuration parameter name \"%s\"", name), - errdetail("Custom parameter names must be of the form \"identifier.identifier\"."))); + errdetail("Custom parameter names must be two or more simple identifiers separated by dots."))); return NULL; } } |