Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3b09aba

Browse files
committed
fix GUC escaping rules
1 parent e6518cc commit 3b09aba

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

multimaster.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "executor/executor.h"
4343
#include "access/twophase.h"
4444
#include "utils/guc.h"
45+
#include "utils/guc_tables.h"
4546
#include "utils/hsearch.h"
4647
#include "utils/timeout.h"
4748
#include "utils/tqual.h"
@@ -4891,6 +4892,34 @@ static void MtmGucSet(VariableSetStmt *stmt, const char *queryStr)
48914892
MemoryContextSwitchTo(oldcontext);
48924893
}
48934894

4895+
static int
4896+
_var_name_cmp(const void *a, const void *b)
4897+
{
4898+
const struct config_generic *confa = *(struct config_generic * const *) a;
4899+
const struct config_generic *confb = *(struct config_generic * const *) b;
4900+
4901+
return strcmp(confa->name, confb->name);
4902+
}
4903+
4904+
static struct config_generic *
4905+
fing_guc_conf(const char *name)
4906+
{
4907+
int num;
4908+
struct config_generic **vars;
4909+
const char **key = &name;
4910+
struct config_generic **res;
4911+
4912+
num = GetNumConfigOptions();
4913+
vars = get_guc_variables();
4914+
4915+
res = (struct config_generic **) bsearch((void *) &key,
4916+
(void *) vars,
4917+
num, sizeof(struct config_generic *),
4918+
_var_name_cmp);
4919+
4920+
return res ? *res : NULL;
4921+
}
4922+
48944923
char* MtmGucSerialize(void)
48954924
{
48964925
StringInfo serialized_gucs;
@@ -4905,6 +4934,7 @@ char* MtmGucSerialize(void)
49054934
dlist_foreach(iter, &MtmGucList)
49064935
{
49074936
MtmGucEntry *cur_entry = dlist_container(MtmGucEntry, list_node, iter.cur);
4937+
struct config_generic *gconf;
49084938

49094939
if (strcmp(cur_entry->key, "search_path") == 0)
49104940
continue;
@@ -4913,8 +4943,8 @@ char* MtmGucSerialize(void)
49134943
appendStringInfoString(serialized_gucs, cur_entry->key);
49144944
appendStringInfoString(serialized_gucs, " TO ");
49154945

4916-
/* quite a crutch */
4917-
if (strstr(cur_entry->key, "_mem") != NULL || *(cur_entry->value) == '\0')
4946+
gconf = fing_guc_conf(cur_entry->key);
4947+
if (gconf && (gconf->vartype == PGC_STRING || gconf->flags & (GUC_UNIT_MEMORY | GUC_UNIT_TIME)))
49184948
{
49194949
appendStringInfoString(serialized_gucs, "'");
49204950
appendStringInfoString(serialized_gucs, cur_entry->value);

0 commit comments

Comments
 (0)