diff options
author | Pavan Deolasee | 2019-06-24 05:21:47 +0000 |
---|---|---|
committer | Pavan Deolasee | 2019-06-24 05:21:47 +0000 |
commit | fe833b3e1c429283f2fb488da318b1a8458a0ec6 (patch) | |
tree | d42fab4d4797a32dfea17cecfbd4c2ca5ccf035b | |
parent | cf7c31a29a3338306a1ca62ee5914e82cf79e29d (diff) |
Send marked GUC variables as string literals to the remote node.
Previously we were double quoting all values, when necessary. This does not
work well when the values cross 64 character limit since double quoted values
are always truncated to 64 character limit. Instead, allow users (specially
extenions) to specify certain GUCs are quote-only and send those as string
literals to the remote node. A quick fix to get some extensions working
correctly.
-rw-r--r-- | src/backend/pgxc/pool/pgxcnode.c | 8 | ||||
-rw-r--r-- | src/backend/utils/misc/guc.c | 12 | ||||
-rw-r--r-- | src/include/utils/guc.h | 2 |
3 files changed, 18 insertions, 4 deletions
diff --git a/src/backend/pgxc/pool/pgxcnode.c b/src/backend/pgxc/pool/pgxcnode.c index 1c4409708b..30afad4718 100644 --- a/src/backend/pgxc/pool/pgxcnode.c +++ b/src/backend/pgxc/pool/pgxcnode.c @@ -194,8 +194,8 @@ uint32 PGXCNodeIdentifier = 0; typedef struct { NameData name; - NameData value; int flags; + char value[1]; } ParamEntry; @@ -2691,9 +2691,9 @@ PGXCNodeSetParam(bool local, const char *name, const char *value, int flags) if (value) { ParamEntry *entry; - entry = (ParamEntry *) palloc(sizeof (ParamEntry)); + entry = (ParamEntry *) palloc0(sizeof (ParamEntry) + strlen(value)); strlcpy((char *) (&entry->name), name, NAMEDATALEN); - strlcpy((char *) (&entry->value), value, NAMEDATALEN); + strcpy((char *) (entry->value), value); entry->flags = flags; param_list = lappend(param_list, entry); @@ -2762,7 +2762,7 @@ get_set_command(List *param_list, StringInfo command, bool local) foreach (lc, param_list) { ParamEntry *entry = (ParamEntry *) lfirst(lc); - const char *value = NameStr(entry->value); + const char *value = entry->value; if (strlen(value) == 0) value = "''"; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index fa5b5eb85c..35e8aff3d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -11648,6 +11648,18 @@ quote_guc_value(const char *value, int flags) if (flags & GUC_LIST_INPUT) return value; + if (flags & GUC_QUOTE_LITERAL) + { + char *newval = palloc(strlen(value) + 3); + int len = strlen(value); + + newval[0] = '\''; + strcpy(newval + 1, value); + newval[len + 1] = '\''; + newval[len + 2] = '\0'; + return newval; + } + /* * Otherwise quote the value. quote_identifier() takes care of correctly * quoting the value when needed, including GUC_UNIT_MEMORY and diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index b840dce34c..c92e77d685 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -231,6 +231,8 @@ typedef enum #define GUC_UNIT (GUC_UNIT_MEMORY | GUC_UNIT_TIME) +/* quote as literal while sending to remote node. */ +#define GUC_QUOTE_LITERAL 0x100000 /* GUC vars that are actually declared in guc.c, rather than elsewhere */ extern bool log_duration; |