mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
tableam: Add and use table_fetch_row_version().
This is essentially the tableam version of heapam_fetch(), i.e. fetching a tuple identified by a tid, performing visibility checks. Note that this different from table_index_fetch_tuple(), which is for index lookups. It therefore has to handle a tid pointing to an earlier version of a tuple if the AM uses an optimization like heap's HOT. Add comments to that end. This commit removes the stats_relation argument from heap_fetch, as it's been unused for a long time. Author: Andres Freund Reviewed-By: Haribabu Kommi Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
This commit is contained in:
@ -229,17 +229,13 @@ ExecCheckTIDVisible(EState *estate,
|
||||
TupleTableSlot *tempSlot)
|
||||
{
|
||||
Relation rel = relinfo->ri_RelationDesc;
|
||||
Buffer buffer;
|
||||
HeapTupleData tuple;
|
||||
|
||||
/* Redundantly check isolation level */
|
||||
if (!IsolationUsesXactSnapshot())
|
||||
return;
|
||||
|
||||
tuple.t_self = *tid;
|
||||
if (!heap_fetch(rel, SnapshotAny, &tuple, &buffer, NULL))
|
||||
if (!table_fetch_row_version(rel, tid, SnapshotAny, tempSlot))
|
||||
elog(ERROR, "failed to fetch conflicting tuple for ON CONFLICT");
|
||||
ExecStorePinnedBufferHeapTuple(&tuple, tempSlot, buffer);
|
||||
ExecCheckTupleVisible(estate, rel, tempSlot);
|
||||
ExecClearTuple(tempSlot);
|
||||
}
|
||||
@ -874,21 +870,9 @@ ldelete:;
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferHeapTupleTableSlot *bslot;
|
||||
HeapTuple deltuple;
|
||||
Buffer buffer;
|
||||
|
||||
Assert(TTS_IS_BUFFERTUPLE(slot));
|
||||
ExecClearTuple(slot);
|
||||
bslot = (BufferHeapTupleTableSlot *) slot;
|
||||
deltuple = &bslot->base.tupdata;
|
||||
|
||||
deltuple->t_self = *tupleid;
|
||||
if (!heap_fetch(resultRelationDesc, SnapshotAny,
|
||||
deltuple, &buffer, NULL))
|
||||
if (!table_fetch_row_version(resultRelationDesc, tupleid,
|
||||
SnapshotAny, slot))
|
||||
elog(ERROR, "failed to fetch deleted tuple for DELETE RETURNING");
|
||||
|
||||
ExecStorePinnedBufferHeapTuple(deltuple, slot, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user