@@ -489,7 +489,7 @@ static void MtmPrepareTransaction(MtmCurrentTrans* x)
489
489
MtmLock (LW_EXCLUSIVE );
490
490
ts = hash_search (xid2state , & x -> xid , HASH_ENTER , NULL );
491
491
ts -> 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 ;
493
493
ts -> csn = MtmAssignCSN ();
494
494
ts -> gtid = x -> gtid ;
495
495
ts -> cmd = MSG_INVALID ;
@@ -868,7 +868,7 @@ mtm_drop_node(PG_FUNCTION_ARGS)
868
868
dtm -> nNodes -= 1 ;
869
869
if (!IsTransactionBlock ())
870
870
{
871
- MtmBroadcastUtilityStmt (psprintf ("select multimaster .drop_node(%d,%s)" , nodeId , dropSlot ? "true" : "false" ), true);
871
+ MtmBroadcastUtilityStmt (psprintf ("select mtm .drop_node(%d,%s)" , nodeId , dropSlot ? "true" : "false" ), true);
872
872
}
873
873
if (dropSlot )
874
874
{
@@ -989,7 +989,7 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
989
989
}
990
990
}
991
991
992
- static void MtmProcessDDLCommand (char const * queryString )
992
+ static bool MtmProcessDDLCommand (char const * queryString )
993
993
{
994
994
RangeVar * rv ;
995
995
Relation rel ;
@@ -1002,8 +1002,12 @@ static void MtmProcessDDLCommand(char const* queryString)
1002
1002
rv = makeRangeVar (MULTIMASTER_SCHEMA_NAME , MULTIMASTER_DDL_TABLE , -1 );
1003
1003
rel = heap_openrv_extended (rv , RowExclusiveLock , true);
1004
1004
1005
- if (rel == NULL ) {
1006
- return ;
1005
+ if (rel == NULL ) {
1006
+ if (!IsTransactionBlock ()) {
1007
+ MtmBroadcastUtilityStmt (queryString , false);
1008
+ return true;
1009
+ }
1010
+ return false;
1007
1011
}
1008
1012
1009
1013
tupDesc = RelationGetDescr (rel );
@@ -1026,9 +1030,8 @@ static void MtmProcessDDLCommand(char const* queryString)
1026
1030
heap_freetuple (tup );
1027
1031
heap_close (rel , RowExclusiveLock );
1028
1032
1029
- elog (WARNING , "Replicate command: '%s'" , queryString );
1030
-
1031
1033
dtmTx .containsDML = true;
1034
+ return false;
1032
1035
}
1033
1036
1034
1037
static void MtmProcessUtility (Node * parsetree , const char * queryString ,
@@ -1038,7 +1041,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
1038
1041
bool skipCommand ;
1039
1042
switch (nodeTag (parsetree ))
1040
1043
{
1041
- case T_TransactionStmt :
1042
1044
case T_PlannedStmt :
1043
1045
case T_ClosePortalStmt :
1044
1046
case T_FetchStmt :
@@ -1052,14 +1054,17 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
1052
1054
case T_LoadStmt :
1053
1055
case T_VariableSetStmt :
1054
1056
case T_VariableShowStmt :
1057
+ case T_TransactionStmt :
1055
1058
skipCommand = true;
1056
1059
break ;
1057
1060
default :
1058
- skipCommand = false;
1061
+ skipCommand = false;
1059
1062
break ;
1060
1063
}
1061
- if (!skipCommand && !dtmTx .isReplicated ) {
1062
- MtmProcessDDLCommand (queryString );
1064
+ if (!skipCommand && !dtmTx .isReplicated && context == PROCESS_UTILITY_TOPLEVEL ) {
1065
+ if (MtmProcessDDLCommand (queryString )) {
1066
+ return ;
1067
+ }
1063
1068
}
1064
1069
if (PreviousProcessUtilityHook != NULL )
1065
1070
{
0 commit comments