@@ -489,7 +489,7 @@ static void MtmPrepareTransaction(MtmCurrentTrans* x)
489489MtmLock (LW_EXCLUSIVE );
490490ts = hash_search (xid2state ,& x -> xid ,HASH_ENTER ,NULL );
491491ts -> status = TRANSACTION_STATUS_IN_PROGRESS ;
492- ts -> snapshot = x -> isReplicated ?INVALID_CSN :x -> snapshot ;
492+ ts -> snapshot = x -> isReplicated || ! x -> containsDML ?INVALID_CSN :x -> snapshot ;
493493ts -> csn = MtmAssignCSN ();
494494ts -> gtid = x -> gtid ;
495495ts -> cmd = MSG_INVALID ;
@@ -868,7 +868,7 @@ mtm_drop_node(PG_FUNCTION_ARGS)
868868dtm -> nNodes -= 1 ;
869869if (!IsTransactionBlock ())
870870{
871- MtmBroadcastUtilityStmt (psprintf ("selectmultimaster .drop_node(%d,%s)" ,nodeId ,dropSlot ?"true" :"false" ), true);
871+ MtmBroadcastUtilityStmt (psprintf ("selectmtm .drop_node(%d,%s)" ,nodeId ,dropSlot ?"true" :"false" ), true);
872872}
873873if (dropSlot )
874874{
@@ -989,7 +989,7 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
989989}
990990}
991991
992- static void MtmProcessDDLCommand (char const * queryString )
992+ static bool MtmProcessDDLCommand (char const * queryString )
993993{
994994RangeVar * rv ;
995995Relation rel ;
@@ -1002,8 +1002,12 @@ static void MtmProcessDDLCommand(char const* queryString)
10021002rv = makeRangeVar (MULTIMASTER_SCHEMA_NAME ,MULTIMASTER_DDL_TABLE ,-1 );
10031003rel = heap_openrv_extended (rv ,RowExclusiveLock , true);
10041004
1005- if (rel == NULL ) {
1006- return ;
1005+ if (rel == NULL ) {
1006+ if (!IsTransactionBlock ()) {
1007+ MtmBroadcastUtilityStmt (queryString , false);
1008+ return true;
1009+ }
1010+ return false;
10071011}
10081012
10091013tupDesc = RelationGetDescr (rel );
@@ -1026,9 +1030,8 @@ static void MtmProcessDDLCommand(char const* queryString)
10261030heap_freetuple (tup );
10271031heap_close (rel ,RowExclusiveLock );
10281032
1029- elog (WARNING ,"Replicate command: '%s'" ,queryString );
1030-
10311033dtmTx .containsDML = true;
1034+ return false;
10321035}
10331036
10341037static void MtmProcessUtility (Node * parsetree ,const char * queryString ,
@@ -1038,7 +1041,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
10381041bool skipCommand ;
10391042switch (nodeTag (parsetree ))
10401043{
1041- case T_TransactionStmt :
10421044case T_PlannedStmt :
10431045case T_ClosePortalStmt :
10441046case T_FetchStmt :
@@ -1052,14 +1054,17 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
10521054case T_LoadStmt :
10531055case T_VariableSetStmt :
10541056case T_VariableShowStmt :
1057+ case T_TransactionStmt :
10551058skipCommand = true;
10561059break ;
10571060default :
1058- skipCommand = false;
1061+ skipCommand = false;
10591062break ;
10601063}
1061- if (!skipCommand && !dtmTx .isReplicated ) {
1062- MtmProcessDDLCommand (queryString );
1064+ if (!skipCommand && !dtmTx .isReplicated && context == PROCESS_UTILITY_TOPLEVEL ) {
1065+ if (MtmProcessDDLCommand (queryString )) {
1066+ return ;
1067+ }
10631068}
10641069if (PreviousProcessUtilityHook != NULL )
10651070{