@@ -197,6 +197,7 @@ char const* const MtmNodeStatusMnem[] =
197
197
198
198
bool MtmDoReplication ;
199
199
char * MtmDatabaseName ;
200
+ char * MtmUtilityStmt = NULL ;
200
201
201
202
int MtmNodes ;
202
203
int MtmNodeId ;
@@ -213,8 +214,6 @@ int MtmHeartbeatRecvTimeout;
213
214
bool MtmUseRaftable ;
214
215
bool MtmUseDtm ;
215
216
216
- // static int reset_wrokers = 0;
217
-
218
217
static char * MtmConnStrs ;
219
218
static int MtmQueueSize ;
220
219
static int MtmWorkers ;
@@ -693,6 +692,10 @@ static const char* const isoLevelStr[] =
693
692
static void
694
693
MtmBeginTransaction (MtmCurrentTrans * x )
695
694
{
695
+ if (MtmUtilityStmt )
696
+ pfree (MtmUtilityStmt );
697
+ MtmUtilityStmt = NULL ;
698
+
696
699
if (x -> snapshot == INVALID_CSN ) {
697
700
TransactionId xmin = (Mtm -> gcCount >= MtmGcPeriod ) ? PgGetOldestXmin (NULL , false) : InvalidTransactionId ; /* Get oldest xmin outside critical section */
698
701
@@ -3087,7 +3090,14 @@ MtmGenerateGid(char* gid)
3087
3090
3088
3091
static bool MtmTwoPhaseCommit (MtmCurrentTrans * x )
3089
3092
{
3090
- if (x -> isDistributed && x -> containsDML ) {
3093
+ if (MtmUtilityStmt && !MyXactAccessedTempRel )
3094
+ {
3095
+ MtmProcessDDLCommand (MtmUtilityStmt );
3096
+ pfree (MtmUtilityStmt );
3097
+ MtmUtilityStmt = NULL ;
3098
+ }
3099
+
3100
+ if (!x -> isReplicated && (x -> isDistributed && x -> containsDML )) {
3091
3101
MtmGenerateGid (x -> gid );
3092
3102
if (!x -> isTransactionBlock ) {
3093
3103
BeginTransactionBlock ();
@@ -3118,6 +3128,9 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
3118
3128
DestReceiver * dest , char * completionTag )
3119
3129
{
3120
3130
bool skipCommand = false;
3131
+
3132
+ // skipCommand = MyXactAccessedTempRel;
3133
+
3121
3134
MTM_LOG3 ("%d: Process utility statement %s" , MyProcPid , queryString );
3122
3135
switch (nodeTag (parsetree ))
3123
3136
{
@@ -3198,12 +3211,12 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
3198
3211
}
3199
3212
break ;
3200
3213
case T_CreateTableAsStmt :
3201
- {
3202
- /* Do not replicate temp tables */
3203
- CreateTableAsStmt * stmt = (CreateTableAsStmt * ) parsetree ;
3204
- skipCommand = stmt -> into -> rel -> relpersistence == RELPERSISTENCE_TEMP ||
3205
- (stmt -> into -> rel -> schemaname && strcmp (stmt -> into -> rel -> schemaname , "pg_temp" ) == 0 );
3206
- }
3214
+ // {
3215
+ // /* Do not replicate temp tables */
3216
+ // CreateTableAsStmt *stmt = (CreateTableAsStmt *) parsetree;
3217
+ // skipCommand = stmt->into->rel->relpersistence == RELPERSISTENCE_TEMP ||
3218
+ // (stmt->into->rel->schemaname && strcmp(stmt->into->rel->schemaname, "pg_temp") == 0);
3219
+ // }
3207
3220
break ;
3208
3221
case T_CreateStmt :
3209
3222
{
@@ -3306,11 +3319,26 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
3306
3319
skipCommand = false;
3307
3320
break ;
3308
3321
}
3309
- if (!skipCommand && !MtmTx .isReplicated && context == PROCESS_UTILITY_TOPLEVEL ) {
3310
- if (MtmProcessDDLCommand (queryString )) {
3311
- return ;
3322
+ if (context == PROCESS_UTILITY_TOPLEVEL )
3323
+ {
3324
+ if (!skipCommand && !MtmTx .isReplicated ) {
3325
+ // if (MtmProcessDDLCommand(queryString)) {
3326
+ // return;
3327
+ // }
3328
+
3329
+ MemoryContext oldcontext ;
3330
+
3331
+ if (MtmUtilityStmt )
3332
+ pfree (MtmUtilityStmt );
3333
+
3334
+ oldcontext = MemoryContextSwitchTo (TopMemoryContext );
3335
+ MtmUtilityStmt = palloc (strlen (queryString ) + 1 );
3336
+ MemoryContextSwitchTo (oldcontext );
3337
+
3338
+ strncpy (MtmUtilityStmt , queryString , strlen (queryString ) + 1 );
3312
3339
}
3313
3340
}
3341
+
3314
3342
if (PreviousProcessUtilityHook != NULL )
3315
3343
{
3316
3344
PreviousProcessUtilityHook (parsetree , queryString , context ,
0 commit comments