@@ -119,19 +119,21 @@ 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 );
126126
127127static void MtmProcessUtilityReceiver (PlannedStmt * pstmt ,
128128 const char * queryString ,
129+ bool readOnlyTree ,
129130 ProcessUtilityContext context , ParamListInfo params ,
130131 QueryEnvironment * queryEnv , DestReceiver * dest ,
131132 QueryCompletion * qc );
132133
133134static void MtmProcessUtilitySender (PlannedStmt * pstmt ,
134135 const char * queryString ,
136+ bool readOnlyTree ,
135137 ProcessUtilityContext context , ParamListInfo params ,
136138 QueryEnvironment * queryEnv , DestReceiver * dest ,
137139 QueryCompletion * qc );
@@ -359,7 +361,7 @@ MtmGucInit(void)
359361 MtmGucHash = hash_create ("MtmGucHash" ,
360362 MTM_GUC_HASHSIZE ,
361363 & hash_ctl ,
362- HASH_ELEM | HASH_CONTEXT );
364+ HASH_ELEM | HASH_CONTEXT | HASH_STRINGS );
363365
364366 /*
365367 * If current role is not equal to MtmDatabaseUser, than set it before any
@@ -661,7 +663,7 @@ MtmFinishDDLCommand()
661663
662664
663665static void
664- MtmProcessUtility (PlannedStmt * pstmt , const char * queryString ,
666+ MtmProcessUtility (PlannedStmt * pstmt , const char * queryString , bool readOnlyTree ,
665667 ProcessUtilityContext context , ParamListInfo params ,
666668 QueryEnvironment * queryEnv , DestReceiver * dest ,
667669 QueryCompletion * qc )
@@ -676,13 +678,13 @@ MtmProcessUtility(PlannedStmt *pstmt, const char *queryString,
676678 {
677679 if (PreviousProcessUtilityHook != NULL )
678680 {
679- PreviousProcessUtilityHook (pstmt , queryString ,
681+ PreviousProcessUtilityHook (pstmt , queryString , readOnlyTree ,
680682 context , params , queryEnv ,
681683 dest , qc );
682684 }
683685 else
684686 {
685- standard_ProcessUtility (pstmt , queryString ,
687+ standard_ProcessUtility (pstmt , queryString , readOnlyTree ,
686688 context , params , queryEnv ,
687689 dest , qc );
688690 }
@@ -691,12 +693,12 @@ MtmProcessUtility(PlannedStmt *pstmt, const char *queryString,
691693
692694 if (MtmIsLogicalReceiver )
693695 {
694- MtmProcessUtilityReceiver (pstmt , queryString , context , params ,
696+ MtmProcessUtilityReceiver (pstmt , queryString , context , readOnlyTree , params ,
695697 queryEnv , dest , qc );
696698 }
697699 else
698700 {
699- MtmProcessUtilitySender (pstmt , queryString , context , params ,
701+ MtmProcessUtilitySender (pstmt , queryString , readOnlyTree , context , params ,
700702 queryEnv , dest , qc );
701703 }
702704
@@ -718,7 +720,7 @@ MtmProcessUtility(PlannedStmt *pstmt, const char *queryString,
718720 * receiver (e.g calling DDL from trigger) this hook does nothing.
719721 */
720722static void
721- MtmProcessUtilityReceiver (PlannedStmt * pstmt , const char * queryString ,
723+ MtmProcessUtilityReceiver (PlannedStmt * pstmt , const char * queryString , bool readOnlyTree ,
722724 ProcessUtilityContext context , ParamListInfo params ,
723725 QueryEnvironment * queryEnv , DestReceiver * dest ,
724726 QueryCompletion * qc )
@@ -839,22 +841,18 @@ MtmProcessUtilityReceiver(PlannedStmt *pstmt, const char *queryString,
839841 }
840842
841843 if (PreviousProcessUtilityHook != NULL )
842- {
843- PreviousProcessUtilityHook (pstmt , queryString ,
844+ PreviousProcessUtilityHook (pstmt , queryString , readOnlyTree ,
844845 context , params , queryEnv ,
845846 dest , qc );
846- }
847847 else
848- {
849- standard_ProcessUtility (pstmt , queryString ,
848+ standard_ProcessUtility (pstmt , queryString , readOnlyTree ,
850849 context , params , queryEnv ,
851850 dest , qc );
852- }
853851}
854852
855853
856854static void
857- MtmProcessUtilitySender (PlannedStmt * pstmt , const char * queryString ,
855+ MtmProcessUtilitySender (PlannedStmt * pstmt , const char * queryString , bool readOnlyTree ,
858856 ProcessUtilityContext context , ParamListInfo params ,
859857 QueryEnvironment * queryEnv , DestReceiver * dest ,
860858 QueryCompletion * qc )
@@ -1186,17 +1184,13 @@ MtmProcessUtilitySender(PlannedStmt *pstmt, const char *queryString,
11861184 stmt_string , skipCommand , MtmDDLStatement != NULL );
11871185
11881186 if (PreviousProcessUtilityHook != NULL )
1189- {
1190- PreviousProcessUtilityHook (pstmt , queryString ,
1187+ PreviousProcessUtilityHook (pstmt , queryString , readOnlyTree ,
11911188 context , params , queryEnv ,
11921189 dest , qc );
1193- }
11941190 else
1195- {
1196- standard_ProcessUtility (pstmt , queryString ,
1191+ standard_ProcessUtility (pstmt , queryString , readOnlyTree ,
11971192 context , params , queryEnv ,
11981193 dest , qc );
1199- }
12001194
12011195 /* Catch GUC assignment */
12021196 if (nodeTag (parsetree ) == T_VariableSetStmt )
@@ -1311,11 +1305,12 @@ MtmExecutorFinish(QueryDesc *queryDesc)
13111305 if (operation == CMD_INSERT || operation == CMD_UPDATE ||
13121306 operation == CMD_DELETE || pstmt -> hasModifyingCTE )
13131307 {
1314- int i ;
1308+ ListCell * l ;
13151309
1316- for ( i = 0 ; i < estate -> es_num_result_relations ; i ++ )
1310+ foreach ( l , estate -> es_opened_result_relations )
13171311 {
1318- Relation rel = estate -> es_result_relations [i ].ri_RelationDesc ;
1312+ ResultRelInfo * resultRelInfo = lfirst (l );
1313+ Relation rel = resultRelInfo -> ri_RelationDesc ;
13191314
13201315 /*
13211316 * Don't run 3pc unless we modified at least one non-local table.
@@ -1709,7 +1704,7 @@ MtmInitializeRemoteFunctionsMap()
17091704 if (q != NULL )
17101705 * q ++ = '\0' ;
17111706
1712- clist = FuncnameGetCandidates (stringToQualifiedNameList (p ), -1 , NIL , false, false, true);
1707+ clist = FuncnameGetCandidates (stringToQualifiedNameList (p ), -1 , NIL , false, false, true, true );
17131708 if (clist == NULL )
17141709 mtm_log (DEBUG1 , "Can't resolve function '%s', postponing that" , p );
17151710 else
@@ -1724,7 +1719,7 @@ MtmInitializeRemoteFunctionsMap()
17241719 p = q ;
17251720 } while (p != NULL );
17261721
1727- clist = FuncnameGetCandidates (stringToQualifiedNameList ("mtm.alter_sequences" ), -1 , NIL , false, false, true);
1722+ clist = FuncnameGetCandidates (stringToQualifiedNameList ("mtm.alter_sequences" ), -1 , NIL , false, false, true, true );
17281723 if (clist != NULL )
17291724 hash_search (MtmRemoteFunctions , & clist -> oid , HASH_ENTER , NULL );
17301725
0 commit comments