Skip to content

Commit 869aefc

Browse files
committed
Fix mess in MtmGucSet()
1 parent 05af1db commit 869aefc

File tree

1 file changed

+26
-41
lines changed

1 file changed

+26
-41
lines changed

contrib/mmts/multimaster.c

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3599,6 +3599,7 @@ typedef struct MtmGucHashEntry
35993599
} MtmGucHashEntry;
36003600

36013601
static HTAB *MtmGucHash = NULL;
3602+
static List *MtmGucList = NULL;
36023603

36033604
static void MtmGucHashInit(void)
36043605
{
@@ -3619,7 +3620,6 @@ static void MtmGucSet(VariableSetStmt *stmt, const char *queryStr)
36193620
MemoryContext oldcontext;
36203621
MtmGucHashEntry *hentry;
36213622
bool found;
3622-
char *key;
36233623

36243624
if (!MtmGucHash)
36253625
MtmGucHashInit();
@@ -3629,54 +3629,30 @@ static void MtmGucSet(VariableSetStmt *stmt, const char *queryStr)
36293629
switch (stmt->kind)
36303630
{
36313631
case VAR_SET_VALUE:
3632-
case VAR_SET_DEFAULT:
3633-
case VAR_SET_CURRENT:
3634-
{
3635-
char *value;
3636-
3637-
key = pstrdup(stmt->name);
3638-
hash_search(MtmGucHash, key, HASH_FIND, &found);
3639-
value = ExtractSetVariableArgs(stmt);
3640-
3641-
fprintf(stderr, ":MtmGucSet: %s -> %s\n", key, value);
3642-
3643-
if (value)
3644-
{
3645-
hentry = (MtmGucHashEntry *) hash_search(MtmGucHash, key,
3646-
HASH_ENTER, &found);
3647-
3648-
// if (found)
3649-
// pfree(hentry->value);
3632+
hentry = (MtmGucHashEntry *) hash_search(MtmGucHash, stmt->name,
3633+
HASH_ENTER, &found);
3634+
if (found)
3635+
pfree(hentry->value);
3636+
hentry->value = ExtractSetVariableArgs(stmt);
3637+
break;
36503638

3651-
hentry->value = palloc(strlen(value) + 1);
3652-
strcpy(hentry->value, value);
3653-
}
3654-
else if (found)
3655-
{
3656-
/* That was SET TO DEFAULT and we already had some value */
3657-
hash_search(MtmGucHash, key, HASH_REMOVE, NULL);
3658-
}
3659-
}
3639+
case VAR_SET_DEFAULT:
3640+
hash_search(MtmGucHash, stmt->name, HASH_REMOVE, NULL);
36603641
break;
36613642

36623643
case VAR_RESET:
3663-
{
3664-
if (strcmp(stmt->name, "session_authorization") == 0)
3665-
{
3666-
hash_search(MtmGucHash, "role", HASH_REMOVE, NULL);
3667-
}
3668-
key = pstrdup(stmt->name);
3669-
hash_search(MtmGucHash, key, HASH_REMOVE, NULL);
3670-
}
3644+
if (strcmp(stmt->name, "session_authorization") == 0)
3645+
hash_search(MtmGucHash, "role", HASH_REMOVE, NULL);
3646+
hash_search(MtmGucHash, stmt->name, HASH_REMOVE, NULL);
36713647
break;
36723648

36733649
case VAR_RESET_ALL:
3674-
{
3675-
hash_destroy(MtmGucHash);
3676-
MtmGucHashInit();
3677-
}
3650+
/* XXX: shouldn't we keep auth/role here? */
3651+
hash_destroy(MtmGucHash);
3652+
MtmGucHashInit();
36783653
break;
36793654

3655+
case VAR_SET_CURRENT:
36803656
case VAR_SET_MULTI:
36813657
break;
36823658
}
@@ -4000,10 +3976,19 @@ MtmExecutorStart(QueryDesc *queryDesc, int eflags)
40003976
TargetEntry *tle = (TargetEntry *) lfirst(tlist);
40013977

40023978
if (tle->resname && strcmp(tle->resname, "lo_create") == 0)
3979+
{
40033980
ddl_generating_call = true;
3981+
break;
3982+
}
3983+
3984+
if (tle->resname && strcmp(tle->resname, "lo_unlink") == 0)
3985+
{
3986+
ddl_generating_call = true;
3987+
break;
3988+
}
40043989
}
40053990

4006-
if (ddl_generating_call)
3991+
if (ddl_generating_call && !MtmTx.isReplicated)
40073992
MtmProcessDDLCommand(ActivePortal->sourceText, true);
40083993

40093994
if (PreviousExecutorStartHook != NULL)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy