Introduces ExecSimpleRelationInsert_compat and modifyStateResultRelInfo macros

es_result_relation_info is removed from Estate. In this commit we make some changes to handle that.
resultRelationInfo filed is added to ModifyState to support the removed field.

Relevant PG commits:
1375422c7826a2bf387be29895e961614f69de4b
a04daa97a4339c38e304cd6164d37da540d665a8
pull/5209/head
Halil Ozan Akgul 2021-08-18 15:51:22 +03:00 committed by Sait Talha Nisanci
parent b644ac55c6
commit fd2ca2825b
2 changed files with 22 additions and 11 deletions

View File

@ -64,6 +64,7 @@ typedef struct
{
Relation rel;
EState *estate;
ResultRelInfo *resultRelInfo;
} ModifyState;
/* RowNumberLookupMode to be used in StripeMetadataLookupRowNumber */
@ -1314,12 +1315,20 @@ StartModifyRelation(Relation rel)
{
EState *estate = create_estate_for_relation(rel);
#if PG_VERSION_NUM >= PG_VERSION_14
ResultRelInfo *resultRelInfo = makeNode(ResultRelInfo);
InitResultRelInfo(resultRelInfo, rel, 1, NULL, 0);
#else
ResultRelInfo *resultRelInfo = estate->es_result_relation_info;
#endif
/* ExecSimpleRelationInsert, ... require caller to open indexes */
ExecOpenIndices(estate->es_result_relation_info, false);
ExecOpenIndices(resultRelInfo, false);
ModifyState *modifyState = palloc(sizeof(ModifyState));
modifyState->rel = rel;
modifyState->estate = estate;
modifyState->resultRelInfo = resultRelInfo;
return modifyState;
}
@ -1341,7 +1350,7 @@ InsertTupleAndEnforceConstraints(ModifyState *state, Datum *values, bool *nulls)
ExecStoreHeapTuple(tuple, slot, false);
/* use ExecSimpleRelationInsert to enforce constraints */
ExecSimpleRelationInsert(state->estate, slot);
ExecSimpleRelationInsert_compat(state->resultRelInfo, state->estate, slot);
}
@ -1353,7 +1362,7 @@ static void
DeleteTupleAndEnforceConstraints(ModifyState *state, HeapTuple heapTuple)
{
EState *estate = state->estate;
ResultRelInfo *resultRelInfo = estate->es_result_relation_info;
ResultRelInfo *resultRelInfo = state->resultRelInfo;
ItemPointer tid = &(heapTuple->t_self);
simple_heap_delete(state->rel, tid);
@ -1369,10 +1378,15 @@ DeleteTupleAndEnforceConstraints(ModifyState *state, HeapTuple heapTuple)
static void
FinishModifyRelation(ModifyState *state)
{
ExecCloseIndices(state->estate->es_result_relation_info);
ExecCloseIndices(state->resultRelInfo);
AfterTriggerEndQuery(state->estate);
#if PG_VERSION_NUM >= PG_VERSION_14
ExecCloseResultRelations(state->estate);
ExecCloseRangeTableRelations(state->estate);
#else
ExecCleanUpTriggerState(state->estate);
#endif
ExecResetTupleTable(state->estate->es_tupleTable, false);
FreeExecutorState(state->estate);
@ -1401,13 +1415,6 @@ create_estate_for_relation(Relation rel)
rte->rellockmode = AccessShareLock;
ExecInitRangeTable(estate, list_make1(rte));
ResultRelInfo *resultRelInfo = makeNode(ResultRelInfo);
InitResultRelInfo(resultRelInfo, rel, 1, NULL, 0);
estate->es_result_relations = resultRelInfo;
estate->es_num_result_relations = 1;
estate->es_result_relation_info = resultRelInfo;
estate->es_output_cid = GetCurrentCommandId(true);
/* Prepare to catch AFTER triggers. */

View File

@ -19,12 +19,16 @@
PrevProcessUtilityHook(a, b, c, d, e, f, g, h)
#define GetOldestNonRemovableTransactionId_compat(a, b) \
GetOldestNonRemovableTransactionId(a)
#define ExecSimpleRelationInsert_compat(a, b, c) \
ExecSimpleRelationInsert(a, b, c)
#else
#define ColumnarProcessUtility_compat(a, b, c, d, e, f, g, h) \
ColumnarProcessUtility(a, b, d, e, f, g, h)
#define PrevProcessUtilityHook_compat(a, b, c, d, e, f, g, h) \
PrevProcessUtilityHook(a, b, d, e, f, g, h)
#define GetOldestNonRemovableTransactionId_compat(a, b) GetOldestXmin(a, b)
#define ExecSimpleRelationInsert_compat(a, b, c) \
ExecSimpleRelationInsert(b, c)
#endif
#define ACLCHECK_OBJECT_TABLE OBJECT_TABLE