@@ -119,19 +119,21 @@ static void MtmSeqNextvalHook(Oid seqid, int64 next);
119
119
static void MtmExecutorStart (QueryDesc * queryDesc , int eflags );
120
120
static void MtmExecutorFinish (QueryDesc * queryDesc );
121
121
122
- static void MtmProcessUtility (PlannedStmt * pstmt , const char * queryString ,
122
+ static void MtmProcessUtility (PlannedStmt * pstmt , const char * queryString , bool readOnlyTree ,
123
123
ProcessUtilityContext context , ParamListInfo params ,
124
124
QueryEnvironment * queryEnv , DestReceiver * dest ,
125
125
QueryCompletion * qc );
126
126
127
127
static void MtmProcessUtilityReceiver (PlannedStmt * pstmt ,
128
128
const char * queryString ,
129
+ bool readOnlyTree ,
129
130
ProcessUtilityContext context , ParamListInfo params ,
130
131
QueryEnvironment * queryEnv , DestReceiver * dest ,
131
132
QueryCompletion * qc );
132
133
133
134
static void MtmProcessUtilitySender (PlannedStmt * pstmt ,
134
135
const char * queryString ,
136
+ bool readOnlyTree ,
135
137
ProcessUtilityContext context , ParamListInfo params ,
136
138
QueryEnvironment * queryEnv , DestReceiver * dest ,
137
139
QueryCompletion * qc );
@@ -359,7 +361,7 @@ MtmGucInit(void)
359
361
MtmGucHash = hash_create ("MtmGucHash" ,
360
362
MTM_GUC_HASHSIZE ,
361
363
& hash_ctl ,
362
- HASH_ELEM | HASH_CONTEXT );
364
+ HASH_ELEM | HASH_CONTEXT | HASH_STRINGS );
363
365
364
366
/*
365
367
* If current role is not equal to MtmDatabaseUser, than set it before any
@@ -661,7 +663,7 @@ MtmFinishDDLCommand()
661
663
662
664
663
665
static void
664
- MtmProcessUtility (PlannedStmt * pstmt , const char * queryString ,
666
+ MtmProcessUtility (PlannedStmt * pstmt , const char * queryString , bool readOnlyTree ,
665
667
ProcessUtilityContext context , ParamListInfo params ,
666
668
QueryEnvironment * queryEnv , DestReceiver * dest ,
667
669
QueryCompletion * qc )
@@ -676,13 +678,13 @@ MtmProcessUtility(PlannedStmt *pstmt, const char *queryString,
676
678
{
677
679
if (PreviousProcessUtilityHook != NULL )
678
680
{
679
- PreviousProcessUtilityHook (pstmt , queryString ,
681
+ PreviousProcessUtilityHook (pstmt , queryString , readOnlyTree ,
680
682
context , params , queryEnv ,
681
683
dest , qc );
682
684
}
683
685
else
684
686
{
685
- standard_ProcessUtility (pstmt , queryString ,
687
+ standard_ProcessUtility (pstmt , queryString , readOnlyTree ,
686
688
context , params , queryEnv ,
687
689
dest , qc );
688
690
}
@@ -691,12 +693,12 @@ MtmProcessUtility(PlannedStmt *pstmt, const char *queryString,
691
693
692
694
if (MtmIsLogicalReceiver )
693
695
{
694
- MtmProcessUtilityReceiver (pstmt , queryString , context , params ,
696
+ MtmProcessUtilityReceiver (pstmt , queryString , context , readOnlyTree , params ,
695
697
queryEnv , dest , qc );
696
698
}
697
699
else
698
700
{
699
- MtmProcessUtilitySender (pstmt , queryString , context , params ,
701
+ MtmProcessUtilitySender (pstmt , queryString , readOnlyTree , context , params ,
700
702
queryEnv , dest , qc );
701
703
}
702
704
@@ -718,7 +720,7 @@ MtmProcessUtility(PlannedStmt *pstmt, const char *queryString,
718
720
* receiver (e.g calling DDL from trigger) this hook does nothing.
719
721
*/
720
722
static void
721
- MtmProcessUtilityReceiver (PlannedStmt * pstmt , const char * queryString ,
723
+ MtmProcessUtilityReceiver (PlannedStmt * pstmt , const char * queryString , bool readOnlyTree ,
722
724
ProcessUtilityContext context , ParamListInfo params ,
723
725
QueryEnvironment * queryEnv , DestReceiver * dest ,
724
726
QueryCompletion * qc )
@@ -839,22 +841,18 @@ MtmProcessUtilityReceiver(PlannedStmt *pstmt, const char *queryString,
839
841
}
840
842
841
843
if (PreviousProcessUtilityHook != NULL )
842
- {
843
- PreviousProcessUtilityHook (pstmt , queryString ,
844
+ PreviousProcessUtilityHook (pstmt , queryString , readOnlyTree ,
844
845
context , params , queryEnv ,
845
846
dest , qc );
846
- }
847
847
else
848
- {
849
- standard_ProcessUtility (pstmt , queryString ,
848
+ standard_ProcessUtility (pstmt , queryString , readOnlyTree ,
850
849
context , params , queryEnv ,
851
850
dest , qc );
852
- }
853
851
}
854
852
855
853
856
854
static void
857
- MtmProcessUtilitySender (PlannedStmt * pstmt , const char * queryString ,
855
+ MtmProcessUtilitySender (PlannedStmt * pstmt , const char * queryString , bool readOnlyTree ,
858
856
ProcessUtilityContext context , ParamListInfo params ,
859
857
QueryEnvironment * queryEnv , DestReceiver * dest ,
860
858
QueryCompletion * qc )
@@ -1186,17 +1184,13 @@ MtmProcessUtilitySender(PlannedStmt *pstmt, const char *queryString,
1186
1184
stmt_string , skipCommand , MtmDDLStatement != NULL );
1187
1185
1188
1186
if (PreviousProcessUtilityHook != NULL )
1189
- {
1190
- PreviousProcessUtilityHook (pstmt , queryString ,
1187
+ PreviousProcessUtilityHook (pstmt , queryString , readOnlyTree ,
1191
1188
context , params , queryEnv ,
1192
1189
dest , qc );
1193
- }
1194
1190
else
1195
- {
1196
- standard_ProcessUtility (pstmt , queryString ,
1191
+ standard_ProcessUtility (pstmt , queryString , readOnlyTree ,
1197
1192
context , params , queryEnv ,
1198
1193
dest , qc );
1199
- }
1200
1194
1201
1195
/* Catch GUC assignment */
1202
1196
if (nodeTag (parsetree ) == T_VariableSetStmt )
@@ -1311,11 +1305,12 @@ MtmExecutorFinish(QueryDesc *queryDesc)
1311
1305
if (operation == CMD_INSERT || operation == CMD_UPDATE ||
1312
1306
operation == CMD_DELETE || pstmt -> hasModifyingCTE )
1313
1307
{
1314
- int i ;
1308
+ ListCell * l ;
1315
1309
1316
- for ( i = 0 ; i < estate -> es_num_result_relations ; i ++ )
1310
+ foreach ( l , estate -> es_opened_result_relations )
1317
1311
{
1318
- Relation rel = estate -> es_result_relations [i ].ri_RelationDesc ;
1312
+ ResultRelInfo * resultRelInfo = lfirst (l );
1313
+ Relation rel = resultRelInfo -> ri_RelationDesc ;
1319
1314
1320
1315
/*
1321
1316
* Don't run 3pc unless we modified at least one non-local table.
@@ -1709,7 +1704,7 @@ MtmInitializeRemoteFunctionsMap()
1709
1704
if (q != NULL )
1710
1705
* q ++ = '\0' ;
1711
1706
1712
- clist = FuncnameGetCandidates (stringToQualifiedNameList (p ), -1 , NIL , false, false, true);
1707
+ clist = FuncnameGetCandidates (stringToQualifiedNameList (p ), -1 , NIL , false, false, true, true );
1713
1708
if (clist == NULL )
1714
1709
mtm_log (DEBUG1 , "Can't resolve function '%s', postponing that" , p );
1715
1710
else
@@ -1724,7 +1719,7 @@ MtmInitializeRemoteFunctionsMap()
1724
1719
p = q ;
1725
1720
} while (p != NULL );
1726
1721
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 );
1728
1723
if (clist != NULL )
1729
1724
hash_search (MtmRemoteFunctions , & clist -> oid , HASH_ENTER , NULL );
1730
1725
0 commit comments