@@ -197,6 +197,7 @@ char const* const MtmNodeStatusMnem[] =
197197
198198bool MtmDoReplication ;
199199char * MtmDatabaseName ;
200+ char * MtmUtilityStmt = NULL ;
200201
201202int MtmNodes ;
202203int MtmNodeId ;
@@ -213,8 +214,6 @@ int MtmHeartbeatRecvTimeout;
213214bool MtmUseRaftable ;
214215bool MtmUseDtm ;
215216
216- // static int reset_wrokers = 0;
217-
218217static char * MtmConnStrs ;
219218static int MtmQueueSize ;
220219static int MtmWorkers ;
@@ -683,6 +682,10 @@ static const char* const isoLevelStr[] =
683682static void
684683MtmBeginTransaction (MtmCurrentTrans * x )
685684{
685+ if (MtmUtilityStmt )
686+ pfree (MtmUtilityStmt );
687+ MtmUtilityStmt = NULL ;
688+
686689 if (x -> snapshot == INVALID_CSN ) {
687690 TransactionId xmin = (Mtm -> gcCount >= MtmGcPeriod ) ? PgGetOldestXmin (NULL , false) : InvalidTransactionId ; /* Get oldest xmin outside critical section */
688691
@@ -3042,6 +3045,13 @@ MtmGenerateGid(char* gid)
30423045
30433046static bool MtmTwoPhaseCommit (MtmCurrentTrans * x )
30443047{
3048+ if (MtmUtilityStmt && !MyXactAccessedTempRel )
3049+ {
3050+ MtmProcessDDLCommand (MtmUtilityStmt );
3051+ pfree (MtmUtilityStmt );
3052+ MtmUtilityStmt = NULL ;
3053+ }
3054+
30453055 if (!x -> isReplicated && (x -> isDistributed && x -> containsDML )) {
30463056 MtmGenerateGid (x -> gid );
30473057 if (!x -> isTransactionBlock ) {
@@ -3074,6 +3084,9 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
30743084 DestReceiver * dest , char * completionTag )
30753085{
30763086 bool skipCommand = false;
3087+
3088+ // skipCommand = MyXactAccessedTempRel;
3089+
30773090 MTM_LOG3 ("%d: Process utility statement %s" , MyProcPid , queryString );
30783091 switch (nodeTag (parsetree ))
30793092 {
@@ -3157,12 +3170,12 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
31573170 }
31583171 break ;
31593172 case T_CreateTableAsStmt :
3160- {
3161- /* Do not replicate temp tables */
3162- CreateTableAsStmt * stmt = (CreateTableAsStmt * ) parsetree ;
3163- skipCommand = stmt -> into -> rel -> relpersistence == RELPERSISTENCE_TEMP ||
3164- (stmt -> into -> rel -> schemaname && strcmp (stmt -> into -> rel -> schemaname , "pg_temp" ) == 0 );
3165- }
3173+ // {
3174+ // /* Do not replicate temp tables */
3175+ // CreateTableAsStmt *stmt = (CreateTableAsStmt *) parsetree;
3176+ // skipCommand = stmt->into->rel->relpersistence == RELPERSISTENCE_TEMP ||
3177+ // (stmt->into->rel->schemaname && strcmp(stmt->into->rel->schemaname, "pg_temp") == 0);
3178+ // }
31663179 break ;
31673180 case T_CreateStmt :
31683181 {
@@ -3265,11 +3278,26 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
32653278 skipCommand = false;
32663279 break ;
32673280 }
3268- if (!skipCommand && !MtmTx .isReplicated && context == PROCESS_UTILITY_TOPLEVEL ) {
3269- if (MtmProcessDDLCommand (queryString )) {
3270- return ;
3281+ if (context == PROCESS_UTILITY_TOPLEVEL )
3282+ {
3283+ if (!skipCommand && !MtmTx .isReplicated ) {
3284+ // if (MtmProcessDDLCommand(queryString)) {
3285+ // return;
3286+ // }
3287+
3288+ MemoryContext oldcontext ;
3289+
3290+ if (MtmUtilityStmt )
3291+ pfree (MtmUtilityStmt );
3292+
3293+ oldcontext = MemoryContextSwitchTo (TopMemoryContext );
3294+ MtmUtilityStmt = palloc (strlen (queryString ) + 1 );
3295+ MemoryContextSwitchTo (oldcontext );
3296+
3297+ strncpy (MtmUtilityStmt , queryString , strlen (queryString ) + 1 );
32713298 }
32723299 }
3300+
32733301 if (PreviousProcessUtilityHook != NULL )
32743302 {
32753303 PreviousProcessUtilityHook (parsetree , queryString , context ,
0 commit comments