diff options
author | Alexander Korotkov <akorotkov@postgresql.org> | 2023-04-03 16:55:09 +0300 |
---|---|---|
committer | Alexander Korotkov <akorotkov@postgresql.org> | 2023-04-03 16:55:09 +0300 |
commit | b0b91ced167f02ced4adaf1b2ecdc6fa0f6eb6e9 (patch) | |
tree | b012a7d0cc8e2a76b48305fa4793ace836357f47 /src | |
parent | 2b65bf046d8a23be25502638da77a1592da2548d (diff) | |
download | postgresql-b0b91ced167f02ced4adaf1b2ecdc6fa0f6eb6e9.tar.gz postgresql-b0b91ced167f02ced4adaf1b2ecdc6fa0f6eb6e9.zip |
Revert 764da7710b
Discussion: https://postgr.es/m/20230323003003.plgaxjqahjgkuxrk%40awork3.anarazel.de
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/executor/nodeModifyTable.c | 48 |
1 files changed, 13 insertions, 35 deletions
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index 93ebfdbb0d8..3a673895082 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -1559,22 +1559,6 @@ ldelete: { case TM_Ok: Assert(context->tmfd.traversed); - - /* - * Save locked tuple for further processing of - * RETURNING clause. - */ - if (processReturning && - resultRelInfo->ri_projectReturning && - !resultRelInfo->ri_FdwRoutine) - { - TupleTableSlot *returningSlot; - - returningSlot = ExecGetReturningSlot(estate, resultRelInfo); - ExecCopySlot(returningSlot, inputslot); - ExecMaterializeSlot(returningSlot); - } - epqslot = EvalPlanQual(context->epqstate, resultRelationDesc, resultRelInfo->ri_RangeTableIndex, @@ -1689,17 +1673,12 @@ ldelete: } else { - /* - * Tuple can be already fetched to the returning slot in case - * we've previously locked it. Fetch the tuple only if the slot - * is empty. - */ slot = ExecGetReturningSlot(estate, resultRelInfo); if (oldtuple != NULL) { ExecForceStoreHeapTuple(oldtuple, slot, false); } - else if (TupIsNull(slot)) + else { if (!table_tuple_fetch_row_version(resultRelationDesc, tupleid, SnapshotAny, slot)) @@ -2414,19 +2393,6 @@ redo_act: case TM_Ok: Assert(context->tmfd.traversed); - /* Make sure ri_oldTupleSlot is initialized. */ - if (unlikely(!resultRelInfo->ri_projectNewInfoValid)) - ExecInitUpdateProjection(context->mtstate, - resultRelInfo); - - /* - * Save the locked tuple for further calculation - * of the new tuple. - */ - oldSlot = resultRelInfo->ri_oldTupleSlot; - ExecCopySlot(oldSlot, inputslot); - ExecMaterializeSlot(oldSlot); - epqslot = EvalPlanQual(context->epqstate, resultRelationDesc, resultRelInfo->ri_RangeTableIndex, @@ -2435,6 +2401,18 @@ redo_act: /* Tuple not passing quals anymore, exiting... */ return NULL; + /* Make sure ri_oldTupleSlot is initialized. */ + if (unlikely(!resultRelInfo->ri_projectNewInfoValid)) + ExecInitUpdateProjection(context->mtstate, + resultRelInfo); + + /* Fetch the most recent version of old tuple. */ + oldSlot = resultRelInfo->ri_oldTupleSlot; + if (!table_tuple_fetch_row_version(resultRelationDesc, + tupleid, + SnapshotAny, + oldSlot)) + elog(ERROR, "failed to fetch tuple being updated"); slot = ExecGetUpdateNewTuple(resultRelInfo, epqslot, oldSlot); goto redo_act; |