@@ -119,7 +119,7 @@ static void MtmSeqNextvalHook(Oid seqid, int64 next);
119119static void MtmExecutorStart (QueryDesc * queryDesc ,int eflags );
120120static void MtmExecutorFinish (QueryDesc * queryDesc );
121121
122- static void MtmProcessUtility (PlannedStmt * pstmt ,const char * queryString ,
122+ static void MtmProcessUtility (PlannedStmt * pstmt ,const char * queryString ,bool readOnlyTree ,
123123ProcessUtilityContext context ,ParamListInfo params ,
124124QueryEnvironment * queryEnv ,DestReceiver * dest ,
125125QueryCompletion * qc );
@@ -359,7 +359,7 @@ MtmGucInit(void)
359359MtmGucHash = hash_create ("MtmGucHash" ,
360360MTM_GUC_HASHSIZE ,
361361& hash_ctl ,
362- HASH_ELEM |HASH_CONTEXT );
362+ HASH_ELEM |HASH_CONTEXT | HASH_STRINGS );
363363
364364/*
365365 * If current role is not equal to MtmDatabaseUser, than set it before any
@@ -661,7 +661,7 @@ MtmFinishDDLCommand()
661661
662662
663663static void
664- MtmProcessUtility (PlannedStmt * pstmt ,const char * queryString ,
664+ MtmProcessUtility (PlannedStmt * pstmt ,const char * queryString ,bool readOnlyTree ,
665665ProcessUtilityContext context ,ParamListInfo params ,
666666QueryEnvironment * queryEnv ,DestReceiver * dest ,
667667QueryCompletion * qc )
@@ -677,13 +677,13 @@ MtmProcessUtility(PlannedStmt *pstmt, const char *queryString,
677677{
678678if (PreviousProcessUtilityHook != NULL )
679679{
680- PreviousProcessUtilityHook (pstmt ,queryString ,
680+ PreviousProcessUtilityHook (pstmt ,queryString ,readOnlyTree ,
681681context ,params ,queryEnv ,
682682dest ,qc );
683683}
684684else
685685{
686- standard_ProcessUtility (pstmt ,queryString ,
686+ standard_ProcessUtility (pstmt ,queryString ,readOnlyTree ,
687687context ,params ,queryEnv ,
688688dest ,qc );
689689}
@@ -841,13 +841,17 @@ MtmProcessUtilityReceiver(PlannedStmt *pstmt, const char *queryString,
841841
842842if (PreviousProcessUtilityHook != NULL )
843843{
844- PreviousProcessUtilityHook (pstmt ,queryString ,
844+ bool readOnlyTree = false;
845+
846+ PreviousProcessUtilityHook (pstmt ,queryString ,readOnlyTree ,
845847context ,params ,queryEnv ,
846848dest ,qc );
847849}
848850else
849851{
850- standard_ProcessUtility (pstmt ,queryString ,
852+ bool readOnlyTree = false;
853+
854+ standard_ProcessUtility (pstmt ,queryString ,readOnlyTree ,
851855context ,params ,queryEnv ,
852856dest ,qc );
853857}
@@ -1188,13 +1192,17 @@ MtmProcessUtilitySender(PlannedStmt *pstmt, const char *queryString,
11881192
11891193if (PreviousProcessUtilityHook != NULL )
11901194{
1191- PreviousProcessUtilityHook (pstmt ,queryString ,
1195+ bool readOnlyTree = false;
1196+
1197+ PreviousProcessUtilityHook (pstmt ,queryString ,readOnlyTree ,
11921198context ,params ,queryEnv ,
11931199dest ,qc );
11941200}
11951201else
11961202{
1197- standard_ProcessUtility (pstmt ,queryString ,
1203+ bool readOnlyTree = false;
1204+
1205+ standard_ProcessUtility (pstmt ,queryString ,readOnlyTree ,
11981206context ,params ,queryEnv ,
11991207dest ,qc );
12001208}
@@ -1312,11 +1320,17 @@ MtmExecutorFinish(QueryDesc *queryDesc)
13121320if (operation == CMD_INSERT || operation == CMD_UPDATE ||
13131321operation == CMD_DELETE || pstmt -> hasModifyingCTE )
13141322{
1315- int i ;
1323+ // inti;
13161324
1317- for (i = 0 ;i < estate -> es_num_result_relations ;i ++ )
1318- {
1319- Relation rel = estate -> es_result_relations [i ].ri_RelationDesc ;
1325+ //for (i = 0; i < estate->es_num_result_relations; i++)
1326+ //{
1327+ //
1328+ ListCell * l ;
1329+
1330+ foreach (l ,estate -> es_opened_result_relations )
1331+ {
1332+ ResultRelInfo * resultRelInfo = lfirst (l );
1333+ Relation rel = resultRelInfo -> ri_RelationDesc ;
13201334
13211335/*
13221336 * Don't run 3pc unless we modified at least one non-local table.
@@ -1710,7 +1724,7 @@ MtmInitializeRemoteFunctionsMap()
17101724if (q != NULL )
17111725* q ++ = '\0' ;
17121726
1713- clist = FuncnameGetCandidates (stringToQualifiedNameList (p ),-1 ,NIL , false, false, true);
1727+ clist = FuncnameGetCandidates (stringToQualifiedNameList (p ),-1 ,NIL , false, false, true, true );
17141728if (clist == NULL )
17151729mtm_log (DEBUG1 ,"Can't resolve function '%s', postponing that" ,p );
17161730else
@@ -1725,7 +1739,7 @@ MtmInitializeRemoteFunctionsMap()
17251739p = q ;
17261740}while (p != NULL );
17271741
1728- clist = FuncnameGetCandidates (stringToQualifiedNameList ("mtm.alter_sequences" ),-1 ,NIL , false, false, true);
1742+ clist = FuncnameGetCandidates (stringToQualifiedNameList ("mtm.alter_sequences" ),-1 ,NIL , false, false, true, true );
17291743if (clist != NULL )
17301744hash_search (MtmRemoteFunctions ,& clist -> oid ,HASH_ENTER ,NULL );
17311745