@@ -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 ,
123123 ProcessUtilityContext context , ParamListInfo params ,
124124 QueryEnvironment * queryEnv , DestReceiver * dest ,
125125 QueryCompletion * qc );
@@ -359,7 +359,7 @@ MtmGucInit(void)
359359 MtmGucHash = hash_create ("MtmGucHash" ,
360360 MTM_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 ,
665665 ProcessUtilityContext context , ParamListInfo params ,
666666 QueryEnvironment * queryEnv , DestReceiver * dest ,
667667 QueryCompletion * qc )
@@ -677,13 +677,13 @@ MtmProcessUtility(PlannedStmt *pstmt, const char *queryString,
677677 {
678678 if (PreviousProcessUtilityHook != NULL )
679679 {
680- PreviousProcessUtilityHook (pstmt , queryString ,
680+ PreviousProcessUtilityHook (pstmt , queryString , readOnlyTree ,
681681 context , params , queryEnv ,
682682 dest , qc );
683683 }
684684 else
685685 {
686- standard_ProcessUtility (pstmt , queryString ,
686+ standard_ProcessUtility (pstmt , queryString , readOnlyTree ,
687687 context , params , queryEnv ,
688688 dest , qc );
689689 }
@@ -841,13 +841,17 @@ MtmProcessUtilityReceiver(PlannedStmt *pstmt, const char *queryString,
841841
842842 if (PreviousProcessUtilityHook != NULL )
843843 {
844- PreviousProcessUtilityHook (pstmt , queryString ,
844+ bool readOnlyTree = false;
845+
846+ PreviousProcessUtilityHook (pstmt , queryString , readOnlyTree ,
845847 context , params , queryEnv ,
846848 dest , qc );
847849 }
848850 else
849851 {
850- standard_ProcessUtility (pstmt , queryString ,
852+ bool readOnlyTree = false;
853+
854+ standard_ProcessUtility (pstmt , queryString , readOnlyTree ,
851855 context , params , queryEnv ,
852856 dest , qc );
853857 }
@@ -1188,13 +1192,17 @@ MtmProcessUtilitySender(PlannedStmt *pstmt, const char *queryString,
11881192
11891193 if (PreviousProcessUtilityHook != NULL )
11901194 {
1191- PreviousProcessUtilityHook (pstmt , queryString ,
1195+ bool readOnlyTree = false;
1196+
1197+ PreviousProcessUtilityHook (pstmt , queryString , readOnlyTree ,
11921198 context , params , queryEnv ,
11931199 dest , qc );
11941200 }
11951201 else
11961202 {
1197- standard_ProcessUtility (pstmt , queryString ,
1203+ bool readOnlyTree = false;
1204+
1205+ standard_ProcessUtility (pstmt , queryString , readOnlyTree ,
11981206 context , params , queryEnv ,
11991207 dest , qc );
12001208 }
@@ -1312,11 +1320,17 @@ MtmExecutorFinish(QueryDesc *queryDesc)
13121320 if (operation == CMD_INSERT || operation == CMD_UPDATE ||
13131321 operation == CMD_DELETE || pstmt -> hasModifyingCTE )
13141322 {
1315- int i ;
1323+ // int i;
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()
17101724 if (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 );
17141728 if (clist == NULL )
17151729 mtm_log (DEBUG1 , "Can't resolve function '%s', postponing that" , p );
17161730 else
@@ -1725,7 +1739,7 @@ MtmInitializeRemoteFunctionsMap()
17251739 p = 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 );
17291743 if (clist != NULL )
17301744 hash_search (MtmRemoteFunctions , & clist -> oid , HASH_ENTER , NULL );
17311745
0 commit comments