mirror of https://github.com/citusdata/citus.git
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 a04daa97a4339c38e304cd6164d37da540d665a8pull/5209/head
parent
b644ac55c6
commit
fd2ca2825b
|
@ -64,6 +64,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
Relation rel;
|
Relation rel;
|
||||||
EState *estate;
|
EState *estate;
|
||||||
|
ResultRelInfo *resultRelInfo;
|
||||||
} ModifyState;
|
} ModifyState;
|
||||||
|
|
||||||
/* RowNumberLookupMode to be used in StripeMetadataLookupRowNumber */
|
/* RowNumberLookupMode to be used in StripeMetadataLookupRowNumber */
|
||||||
|
@ -1314,12 +1315,20 @@ StartModifyRelation(Relation rel)
|
||||||
{
|
{
|
||||||
EState *estate = create_estate_for_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 */
|
/* ExecSimpleRelationInsert, ... require caller to open indexes */
|
||||||
ExecOpenIndices(estate->es_result_relation_info, false);
|
ExecOpenIndices(resultRelInfo, false);
|
||||||
|
|
||||||
ModifyState *modifyState = palloc(sizeof(ModifyState));
|
ModifyState *modifyState = palloc(sizeof(ModifyState));
|
||||||
modifyState->rel = rel;
|
modifyState->rel = rel;
|
||||||
modifyState->estate = estate;
|
modifyState->estate = estate;
|
||||||
|
modifyState->resultRelInfo = resultRelInfo;
|
||||||
|
|
||||||
return modifyState;
|
return modifyState;
|
||||||
}
|
}
|
||||||
|
@ -1341,7 +1350,7 @@ InsertTupleAndEnforceConstraints(ModifyState *state, Datum *values, bool *nulls)
|
||||||
ExecStoreHeapTuple(tuple, slot, false);
|
ExecStoreHeapTuple(tuple, slot, false);
|
||||||
|
|
||||||
/* use ExecSimpleRelationInsert to enforce constraints */
|
/* 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)
|
DeleteTupleAndEnforceConstraints(ModifyState *state, HeapTuple heapTuple)
|
||||||
{
|
{
|
||||||
EState *estate = state->estate;
|
EState *estate = state->estate;
|
||||||
ResultRelInfo *resultRelInfo = estate->es_result_relation_info;
|
ResultRelInfo *resultRelInfo = state->resultRelInfo;
|
||||||
|
|
||||||
ItemPointer tid = &(heapTuple->t_self);
|
ItemPointer tid = &(heapTuple->t_self);
|
||||||
simple_heap_delete(state->rel, tid);
|
simple_heap_delete(state->rel, tid);
|
||||||
|
@ -1369,10 +1378,15 @@ DeleteTupleAndEnforceConstraints(ModifyState *state, HeapTuple heapTuple)
|
||||||
static void
|
static void
|
||||||
FinishModifyRelation(ModifyState *state)
|
FinishModifyRelation(ModifyState *state)
|
||||||
{
|
{
|
||||||
ExecCloseIndices(state->estate->es_result_relation_info);
|
ExecCloseIndices(state->resultRelInfo);
|
||||||
|
|
||||||
AfterTriggerEndQuery(state->estate);
|
AfterTriggerEndQuery(state->estate);
|
||||||
|
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||||
|
ExecCloseResultRelations(state->estate);
|
||||||
|
ExecCloseRangeTableRelations(state->estate);
|
||||||
|
#else
|
||||||
ExecCleanUpTriggerState(state->estate);
|
ExecCleanUpTriggerState(state->estate);
|
||||||
|
#endif
|
||||||
ExecResetTupleTable(state->estate->es_tupleTable, false);
|
ExecResetTupleTable(state->estate->es_tupleTable, false);
|
||||||
FreeExecutorState(state->estate);
|
FreeExecutorState(state->estate);
|
||||||
|
|
||||||
|
@ -1401,13 +1415,6 @@ create_estate_for_relation(Relation rel)
|
||||||
rte->rellockmode = AccessShareLock;
|
rte->rellockmode = AccessShareLock;
|
||||||
ExecInitRangeTable(estate, list_make1(rte));
|
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);
|
estate->es_output_cid = GetCurrentCommandId(true);
|
||||||
|
|
||||||
/* Prepare to catch AFTER triggers. */
|
/* Prepare to catch AFTER triggers. */
|
||||||
|
|
|
@ -19,12 +19,16 @@
|
||||||
PrevProcessUtilityHook(a, b, c, d, e, f, g, h)
|
PrevProcessUtilityHook(a, b, c, d, e, f, g, h)
|
||||||
#define GetOldestNonRemovableTransactionId_compat(a, b) \
|
#define GetOldestNonRemovableTransactionId_compat(a, b) \
|
||||||
GetOldestNonRemovableTransactionId(a)
|
GetOldestNonRemovableTransactionId(a)
|
||||||
|
#define ExecSimpleRelationInsert_compat(a, b, c) \
|
||||||
|
ExecSimpleRelationInsert(a, b, c)
|
||||||
#else
|
#else
|
||||||
#define ColumnarProcessUtility_compat(a, b, c, d, e, f, g, h) \
|
#define ColumnarProcessUtility_compat(a, b, c, d, e, f, g, h) \
|
||||||
ColumnarProcessUtility(a, b, d, e, f, g, h)
|
ColumnarProcessUtility(a, b, d, e, f, g, h)
|
||||||
#define PrevProcessUtilityHook_compat(a, b, c, d, e, f, g, h) \
|
#define PrevProcessUtilityHook_compat(a, b, c, d, e, f, g, h) \
|
||||||
PrevProcessUtilityHook(a, b, d, e, f, g, h)
|
PrevProcessUtilityHook(a, b, d, e, f, g, h)
|
||||||
#define GetOldestNonRemovableTransactionId_compat(a, b) GetOldestXmin(a, b)
|
#define GetOldestNonRemovableTransactionId_compat(a, b) GetOldestXmin(a, b)
|
||||||
|
#define ExecSimpleRelationInsert_compat(a, b, c) \
|
||||||
|
ExecSimpleRelationInsert(b, c)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ACLCHECK_OBJECT_TABLE OBJECT_TABLE
|
#define ACLCHECK_OBJECT_TABLE OBJECT_TABLE
|
||||||
|
|
Loading…
Reference in New Issue