mirror of
https://github.com/postgres/postgres.git
synced 2025-08-19 23:22:23 +03:00
Remove es_result_relation_info from EState.
Maintaining 'es_result_relation_info' correctly at all times has become cumbersome, especially with partitioning where each partition gets its own result relation info. Having to set and reset it across arbitrary operations has caused bugs in the past. This changes all the places that used 'es_result_relation_info', to receive the currently active ResultRelInfo via function parameters instead. Author: Amit Langote Discussion: https://www.postgresql.org/message-id/CA%2BHiwqGEmiib8FLiHMhKB%2BCH5dRgHSLc5N5wnvc4kym%2BZYpQEQ%40mail.gmail.com
This commit is contained in:
@@ -404,10 +404,10 @@ retry:
|
||||
* Caller is responsible for opening the indexes.
|
||||
*/
|
||||
void
|
||||
ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot)
|
||||
ExecSimpleRelationInsert(ResultRelInfo *resultRelInfo,
|
||||
EState *estate, TupleTableSlot *slot)
|
||||
{
|
||||
bool skip_tuple = false;
|
||||
ResultRelInfo *resultRelInfo = estate->es_result_relation_info;
|
||||
Relation rel = resultRelInfo->ri_RelationDesc;
|
||||
|
||||
/* For now we support only tables. */
|
||||
@@ -430,7 +430,8 @@ ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot)
|
||||
/* Compute stored generated columns */
|
||||
if (rel->rd_att->constr &&
|
||||
rel->rd_att->constr->has_generated_stored)
|
||||
ExecComputeStoredGenerated(estate, slot, CMD_INSERT);
|
||||
ExecComputeStoredGenerated(resultRelInfo, estate, slot,
|
||||
CMD_INSERT);
|
||||
|
||||
/* Check the constraints of the tuple */
|
||||
if (rel->rd_att->constr)
|
||||
@@ -442,7 +443,8 @@ ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot)
|
||||
simple_table_tuple_insert(resultRelInfo->ri_RelationDesc, slot);
|
||||
|
||||
if (resultRelInfo->ri_NumIndices > 0)
|
||||
recheckIndexes = ExecInsertIndexTuples(slot, estate, false, NULL,
|
||||
recheckIndexes = ExecInsertIndexTuples(resultRelInfo,
|
||||
slot, estate, false, NULL,
|
||||
NIL);
|
||||
|
||||
/* AFTER ROW INSERT Triggers */
|
||||
@@ -466,11 +468,11 @@ ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot)
|
||||
* Caller is responsible for opening the indexes.
|
||||
*/
|
||||
void
|
||||
ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate,
|
||||
ExecSimpleRelationUpdate(ResultRelInfo *resultRelInfo,
|
||||
EState *estate, EPQState *epqstate,
|
||||
TupleTableSlot *searchslot, TupleTableSlot *slot)
|
||||
{
|
||||
bool skip_tuple = false;
|
||||
ResultRelInfo *resultRelInfo = estate->es_result_relation_info;
|
||||
Relation rel = resultRelInfo->ri_RelationDesc;
|
||||
ItemPointer tid = &(searchslot->tts_tid);
|
||||
|
||||
@@ -496,7 +498,8 @@ ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate,
|
||||
/* Compute stored generated columns */
|
||||
if (rel->rd_att->constr &&
|
||||
rel->rd_att->constr->has_generated_stored)
|
||||
ExecComputeStoredGenerated(estate, slot, CMD_UPDATE);
|
||||
ExecComputeStoredGenerated(resultRelInfo, estate, slot,
|
||||
CMD_UPDATE);
|
||||
|
||||
/* Check the constraints of the tuple */
|
||||
if (rel->rd_att->constr)
|
||||
@@ -508,7 +511,8 @@ ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate,
|
||||
&update_indexes);
|
||||
|
||||
if (resultRelInfo->ri_NumIndices > 0 && update_indexes)
|
||||
recheckIndexes = ExecInsertIndexTuples(slot, estate, false, NULL,
|
||||
recheckIndexes = ExecInsertIndexTuples(resultRelInfo,
|
||||
slot, estate, false, NULL,
|
||||
NIL);
|
||||
|
||||
/* AFTER ROW UPDATE Triggers */
|
||||
@@ -527,11 +531,11 @@ ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate,
|
||||
* Caller is responsible for opening the indexes.
|
||||
*/
|
||||
void
|
||||
ExecSimpleRelationDelete(EState *estate, EPQState *epqstate,
|
||||
ExecSimpleRelationDelete(ResultRelInfo *resultRelInfo,
|
||||
EState *estate, EPQState *epqstate,
|
||||
TupleTableSlot *searchslot)
|
||||
{
|
||||
bool skip_tuple = false;
|
||||
ResultRelInfo *resultRelInfo = estate->es_result_relation_info;
|
||||
Relation rel = resultRelInfo->ri_RelationDesc;
|
||||
ItemPointer tid = &searchslot->tts_tid;
|
||||
|
||||
|
Reference in New Issue
Block a user