Send marked GUC variables as string literals to the remote node.
authorPavan Deolasee <[email protected]>
Mon, 24 Jun 2019 05:21:47 +0000 (10:51 +0530)
committerPavan Deolasee <[email protected]>
Mon, 24 Jun 2019 05:21:47 +0000 (10:51 +0530)
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.

src/backend/pgxc/pool/pgxcnode.c
src/backend/utils/misc/guc.c
src/include/utils/guc.h

index 1c4409708bced151b740ebf51afbcd92d3aa7132..30afad4718f3dfe054f03ae2f0357a4f90004d6a 100644 (file)
@@ -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 = "''";
index fa5b5eb85cf03c4947201b7be2ef92b384eb4f2f..35e8aff3d35598427ca6b2d1f9e8cf5e18dbf291 100644 (file)
@@ -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
index b840dce34c0442b13ee77672fffaf8d802145005..c92e77d6850228be99e5a855c4e165044c4440f7 100644 (file)
@@ -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;