mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Revert 11470f544e
Discussion: https://postgr.es/m/20230323003003.plgaxjqahjgkuxrk%40awork3.anarazel.de
This commit is contained in:
@@ -45,12 +45,6 @@
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
static TM_Result heapam_tuple_lock_internal(Relation relation, ItemPointer tid,
|
||||
Snapshot snapshot, TupleTableSlot *slot,
|
||||
CommandId cid, LockTupleMode mode,
|
||||
LockWaitPolicy wait_policy, uint8 flags,
|
||||
TM_FailureData *tmfd, bool updated);
|
||||
|
||||
static void reform_and_rewrite_tuple(HeapTuple tuple,
|
||||
Relation OldHeap, Relation NewHeap,
|
||||
Datum *values, bool *isnull, RewriteState rwstate);
|
||||
@@ -305,46 +299,14 @@ heapam_tuple_complete_speculative(Relation relation, TupleTableSlot *slot,
|
||||
static TM_Result
|
||||
heapam_tuple_delete(Relation relation, ItemPointer tid, CommandId cid,
|
||||
Snapshot snapshot, Snapshot crosscheck, bool wait,
|
||||
TM_FailureData *tmfd, bool changingPart,
|
||||
LazyTupleTableSlot *lockedSlot)
|
||||
TM_FailureData *tmfd, bool changingPart)
|
||||
{
|
||||
TM_Result result;
|
||||
|
||||
/*
|
||||
* Currently Deleting of index tuples are handled at vacuum, in case if
|
||||
* the storage itself is cleaning the dead tuples by itself, it is the
|
||||
* time to call the index tuple deletion also.
|
||||
*/
|
||||
result = heap_delete(relation, tid, cid, crosscheck, wait,
|
||||
tmfd, changingPart);
|
||||
|
||||
/*
|
||||
* If the tuple has been concurrently updated, then get the lock on it.
|
||||
* (Do this if caller asked for tat by providing a 'lockedSlot'.) With the
|
||||
* lock held retry of delete should succeed even if there are more
|
||||
* concurrent update attempts.
|
||||
*/
|
||||
if (result == TM_Updated && lockedSlot)
|
||||
{
|
||||
TupleTableSlot *evalSlot;
|
||||
|
||||
Assert(wait);
|
||||
|
||||
evalSlot = LAZY_TTS_EVAL(lockedSlot);
|
||||
result = heapam_tuple_lock_internal(relation, tid, snapshot,
|
||||
evalSlot, cid, LockTupleExclusive,
|
||||
LockWaitBlock,
|
||||
TUPLE_LOCK_FLAG_FIND_LAST_VERSION,
|
||||
tmfd, true);
|
||||
|
||||
if (result == TM_Ok)
|
||||
{
|
||||
tmfd->traversed = true;
|
||||
return TM_Updated;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return heap_delete(relation, tid, cid, crosscheck, wait, tmfd, changingPart);
|
||||
}
|
||||
|
||||
|
||||
@@ -352,8 +314,7 @@ static TM_Result
|
||||
heapam_tuple_update(Relation relation, ItemPointer otid, TupleTableSlot *slot,
|
||||
CommandId cid, Snapshot snapshot, Snapshot crosscheck,
|
||||
bool wait, TM_FailureData *tmfd,
|
||||
LockTupleMode *lockmode, TU_UpdateIndexes *update_indexes,
|
||||
LazyTupleTableSlot *lockedSlot)
|
||||
LockTupleMode *lockmode, TU_UpdateIndexes *update_indexes)
|
||||
{
|
||||
bool shouldFree = true;
|
||||
HeapTuple tuple = ExecFetchSlotHeapTuple(slot, true, &shouldFree);
|
||||
@@ -391,32 +352,6 @@ heapam_tuple_update(Relation relation, ItemPointer otid, TupleTableSlot *slot,
|
||||
if (shouldFree)
|
||||
pfree(tuple);
|
||||
|
||||
/*
|
||||
* If the tuple has been concurrently updated, then get the lock on it.
|
||||
* (Do this if caller asked for tat by providing a 'lockedSlot'.) With the
|
||||
* lock held retry of update should succeed even if there are more
|
||||
* concurrent update attempts.
|
||||
*/
|
||||
if (result == TM_Updated && lockedSlot)
|
||||
{
|
||||
TupleTableSlot *evalSlot;
|
||||
|
||||
Assert(wait);
|
||||
|
||||
evalSlot = LAZY_TTS_EVAL(lockedSlot);
|
||||
result = heapam_tuple_lock_internal(relation, otid, snapshot,
|
||||
evalSlot, cid, *lockmode,
|
||||
LockWaitBlock,
|
||||
TUPLE_LOCK_FLAG_FIND_LAST_VERSION,
|
||||
tmfd, true);
|
||||
|
||||
if (result == TM_Ok)
|
||||
{
|
||||
tmfd->traversed = true;
|
||||
return TM_Updated;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -425,26 +360,10 @@ heapam_tuple_lock(Relation relation, ItemPointer tid, Snapshot snapshot,
|
||||
TupleTableSlot *slot, CommandId cid, LockTupleMode mode,
|
||||
LockWaitPolicy wait_policy, uint8 flags,
|
||||
TM_FailureData *tmfd)
|
||||
{
|
||||
return heapam_tuple_lock_internal(relation, tid, snapshot, slot, cid,
|
||||
mode, wait_policy, flags, tmfd, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine does the work for heapam_tuple_lock(), but also support
|
||||
* `updated` argument to re-use the work done by heapam_tuple_update() or
|
||||
* heapam_tuple_delete() on figuring out that tuple was concurrently updated.
|
||||
*/
|
||||
static TM_Result
|
||||
heapam_tuple_lock_internal(Relation relation, ItemPointer tid,
|
||||
Snapshot snapshot, TupleTableSlot *slot,
|
||||
CommandId cid, LockTupleMode mode,
|
||||
LockWaitPolicy wait_policy, uint8 flags,
|
||||
TM_FailureData *tmfd, bool updated)
|
||||
{
|
||||
BufferHeapTupleTableSlot *bslot = (BufferHeapTupleTableSlot *) slot;
|
||||
TM_Result result;
|
||||
Buffer buffer = InvalidBuffer;
|
||||
Buffer buffer;
|
||||
HeapTuple tuple = &bslot->base.tupdata;
|
||||
bool follow_updates;
|
||||
|
||||
@@ -455,26 +374,16 @@ heapam_tuple_lock_internal(Relation relation, ItemPointer tid,
|
||||
|
||||
tuple_lock_retry:
|
||||
tuple->t_self = *tid;
|
||||
if (!updated)
|
||||
result = heap_lock_tuple(relation, tuple, cid, mode, wait_policy,
|
||||
follow_updates, &buffer, tmfd);
|
||||
else
|
||||
result = TM_Updated;
|
||||
result = heap_lock_tuple(relation, tuple, cid, mode, wait_policy,
|
||||
follow_updates, &buffer, tmfd);
|
||||
|
||||
if (result == TM_Updated &&
|
||||
(flags & TUPLE_LOCK_FLAG_FIND_LAST_VERSION))
|
||||
{
|
||||
if (!updated)
|
||||
{
|
||||
/* Should not encounter speculative tuple on recheck */
|
||||
Assert(!HeapTupleHeaderIsSpeculative(tuple->t_data));
|
||||
/* Should not encounter speculative tuple on recheck */
|
||||
Assert(!HeapTupleHeaderIsSpeculative(tuple->t_data));
|
||||
|
||||
ReleaseBuffer(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
updated = false;
|
||||
}
|
||||
ReleaseBuffer(buffer);
|
||||
|
||||
if (!ItemPointerEquals(&tmfd->ctid, &tuple->t_self))
|
||||
{
|
||||
|
@@ -306,8 +306,7 @@ simple_table_tuple_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
|
||||
GetCurrentCommandId(true),
|
||||
snapshot, InvalidSnapshot,
|
||||
true /* wait for commit */ ,
|
||||
&tmfd, false /* changingPart */ ,
|
||||
NULL);
|
||||
&tmfd, false /* changingPart */ );
|
||||
|
||||
switch (result)
|
||||
{
|
||||
@@ -356,8 +355,7 @@ simple_table_tuple_update(Relation rel, ItemPointer otid,
|
||||
GetCurrentCommandId(true),
|
||||
snapshot, InvalidSnapshot,
|
||||
true /* wait for commit */ ,
|
||||
&tmfd, &lockmode, update_indexes,
|
||||
NULL);
|
||||
&tmfd, &lockmode, update_indexes);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
|
Reference in New Issue
Block a user