mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
Clean up the representation of special snapshots by including a "method
pointer" in every Snapshot struct. This allows removal of the case-by-case tests in HeapTupleSatisfiesVisibility, which should make it a bit faster (I didn't try any performance tests though). More importantly, we are no longer violating portable C practices by assuming that small integers are distinct from all pointer values, and HeapTupleSatisfiesDirty no longer has a non-reentrant API involving side-effects on a global variable. There were a couple of places calling HeapTupleSatisfiesXXX routines directly rather than through the HeapTupleSatisfiesVisibility macro. Since these places had to be changed anyway, I chose to make them go through the macro for uniformity. Along the way I renamed HeapTupleSatisfiesSnapshot to HeapTupleSatisfiesMVCC to emphasize that it's only used with MVCC-type snapshots. I was sorely tempted to rename HeapTupleSatisfiesVisibility to HeapTupleSatisfiesSnapshot, but forebore for the moment to avoid confusion and reduce the likelihood that this patch breaks some of the pending patches. Might want to reconsider doing that later.
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.290 2007/03/06 02:06:13 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.291 2007/03/25 19:45:14 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1893,6 +1893,7 @@ EvalPlanQual(EState *estate, Index rti,
|
||||
Relation relation;
|
||||
HeapTupleData tuple;
|
||||
HeapTuple copyTuple = NULL;
|
||||
SnapshotData SnapshotDirty;
|
||||
bool endNode;
|
||||
|
||||
Assert(rti != 0);
|
||||
@ -1925,12 +1926,13 @@ EvalPlanQual(EState *estate, Index rti,
|
||||
*
|
||||
* Loop here to deal with updated or busy tuples
|
||||
*/
|
||||
InitDirtySnapshot(SnapshotDirty);
|
||||
tuple.t_self = *tid;
|
||||
for (;;)
|
||||
{
|
||||
Buffer buffer;
|
||||
|
||||
if (heap_fetch(relation, SnapshotDirty, &tuple, &buffer, true, NULL))
|
||||
if (heap_fetch(relation, &SnapshotDirty, &tuple, &buffer, true, NULL))
|
||||
{
|
||||
/*
|
||||
* If xmin isn't what we're expecting, the slot must have been
|
||||
@ -1948,17 +1950,17 @@ EvalPlanQual(EState *estate, Index rti,
|
||||
}
|
||||
|
||||
/* otherwise xmin should not be dirty... */
|
||||
if (TransactionIdIsValid(SnapshotDirty->xmin))
|
||||
if (TransactionIdIsValid(SnapshotDirty.xmin))
|
||||
elog(ERROR, "t_xmin is uncommitted in tuple to be updated");
|
||||
|
||||
/*
|
||||
* If tuple is being updated by other transaction then we have to
|
||||
* wait for its commit/abort.
|
||||
*/
|
||||
if (TransactionIdIsValid(SnapshotDirty->xmax))
|
||||
if (TransactionIdIsValid(SnapshotDirty.xmax))
|
||||
{
|
||||
ReleaseBuffer(buffer);
|
||||
XactLockTableWait(SnapshotDirty->xmax);
|
||||
XactLockTableWait(SnapshotDirty.xmax);
|
||||
continue; /* loop back to repeat heap_fetch */
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user