Skip to content

Commit 52440ba

Browse files
danolivokelvich
authored andcommitted
[PGPRO-3171] The multimaster code improvement
1 parent 1a566de commit 52440ba

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/ddl.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ static ExecutorFinish_hook_type PreviousExecutorFinishHook;
103103
static ProcessUtility_hook_type PreviousProcessUtilityHook;
104104
static seq_nextval_hook_t PreviousSeqNextvalHook;
105105

106+
107+
/* Set given temp namespace in receiver */
108+
PG_FUNCTION_INFO_V1(mtm_set_temp_schema);
109+
106110
static void MtmSeqNextvalHook(Oid seqid, int64 next);
107111
static void MtmExecutorStart(QueryDesc *queryDesc, int eflags);
108112
static void MtmExecutorFinish(QueryDesc *queryDesc);
@@ -113,7 +117,7 @@ static void MtmProcessUtility(PlannedStmt *pstmt,
113117
QueryEnvironment *queryEnv, DestReceiver *dest,
114118
char *completionTag);
115119

116-
static void MtmProcessUtilityReciever(PlannedStmt *pstmt,
120+
static void MtmProcessUtilityReceiver(PlannedStmt *pstmt,
117121
const char *queryString,
118122
ProcessUtilityContext context, ParamListInfo params,
119123
QueryEnvironment *queryEnv, DestReceiver *dest,
@@ -265,8 +269,6 @@ temp_schema_init(void)
265269
}
266270
}
267271

268-
/* Set given temp namespace in receiver */
269-
PG_FUNCTION_INFO_V1(mtm_set_temp_schema);
270272
Datum
271273
mtm_set_temp_schema(PG_FUNCTION_ARGS)
272274
{
@@ -302,7 +304,6 @@ static void
302304
MtmGucInit(void)
303305
{
304306
HASHCTL hash_ctl;
305-
char *current_role;
306307
MemoryContext oldcontext;
307308

308309
MemSet(&hash_ctl, 0, sizeof(hash_ctl));
@@ -321,7 +322,6 @@ MtmGucInit(void)
321322
* XXX: try to avoid using MtmDatabaseUser somehow
322323
*/
323324
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
324-
current_role = GetConfigOptionByName("session_authorization", NULL, false);
325325
// XXX if (current_role && *current_role && strcmp(MtmDatabaseUser, current_role) != 0)
326326
MtmGucUpdate("session_authorization");
327327
MemoryContextSwitchTo(oldcontext);
@@ -606,7 +606,7 @@ MtmProcessUtility(PlannedStmt *pstmt, const char *queryString,
606606
{
607607
if (MtmIsLogicalReceiver)
608608
{
609-
MtmProcessUtilityReciever(pstmt, queryString, context, params,
609+
MtmProcessUtilityReceiver(pstmt, queryString, context, params,
610610
queryEnv, dest, completionTag);
611611
}
612612
else
@@ -633,7 +633,7 @@ MtmProcessUtility(PlannedStmt *pstmt, const char *queryString,
633633
* receiver (e.g calling DDL from trigger) this hook does nothing.
634634
*/
635635
static void
636-
MtmProcessUtilityReciever(PlannedStmt *pstmt, const char *queryString,
636+
MtmProcessUtilityReceiver(PlannedStmt *pstmt, const char *queryString,
637637
ProcessUtilityContext context, ParamListInfo params,
638638
QueryEnvironment *queryEnv, DestReceiver *dest,
639639
char *completionTag)
@@ -647,7 +647,7 @@ MtmProcessUtilityReciever(PlannedStmt *pstmt, const char *queryString,
647647
bool captured = false;
648648

649649
mtm_log(DDLProcessingTrace,
650-
"MtmProcessUtilityReciever: tag=%s, context=%d, issubtrans=%d, statement=%s",
650+
"MtmProcessUtilityReceiver: tag=%s, context=%d, issubtrans=%d, statement=%s",
651651
CreateCommandTag(parsetree), context, IsSubTransaction(), queryString);
652652

653653
Assert(oldMemContext != MtmApplyContext);
@@ -883,7 +883,7 @@ MtmProcessUtilitySender(PlannedStmt *pstmt, const char *queryString,
883883
{
884884
DiscardStmt *stmt = (DiscardStmt *) parsetree;
885885

886-
if (stmt->type == DISCARD_TEMP)
886+
if (stmt->target == DISCARD_TEMP)
887887
temp_schema_reset();
888888

889889
if (!IsTransactionBlock() && stmt->target == DISCARD_ALL)
@@ -1504,15 +1504,17 @@ MtmSeqNextvalHook(Oid seqid, int64 next)
15041504
static List *
15051505
AdjustCreateSequence(List *options)
15061506
{
1507-
bool has_increment = false, has_start = false;
1508-
ListCell *option;
1507+
bool has_increment = false;
1508+
bool has_start = false;
1509+
ListCell *option;
1510+
DefElem *defel;
15091511

15101512
if (!MtmIsEnabled())
15111513
return options;
15121514

15131515
foreach(option, options)
15141516
{
1515-
DefElem *defel = (DefElem *) lfirst(option);
1517+
defel = (DefElem *) lfirst(option);
15161518
if (strcmp(defel->defname, "increment") == 0)
15171519
has_increment = true;
15181520
else if (strcmp(defel->defname, "start") == 0)
@@ -1532,13 +1534,13 @@ AdjustCreateSequence(List *options)
15321534
max_node = mtm_cfg->nodes[i].node_id;
15331535
}
15341536

1535-
DefElem *defel = makeDefElem("increment", (Node *) makeInteger(max_node), -1);
1537+
defel = makeDefElem("increment", (Node *) makeInteger(max_node), -1);
15361538
options = lappend(options, defel);
15371539
}
15381540

15391541
if (!has_start)
15401542
{
1541-
DefElem *defel = makeDefElem("start", (Node *) makeInteger(Mtm->my_node_id), -1);
1543+
defel = makeDefElem("start", (Node *) makeInteger(Mtm->my_node_id), -1);
15421544
options = lappend(options, defel);
15431545
}
15441546

0 commit comments

Comments
 (0)