7878
7979
8080/* Static variables representing various special snapshot semantics */
81- SnapshotData SnapshotSelfData = {HeapTupleSatisfiesSelf };
82- SnapshotData SnapshotAnyData = {HeapTupleSatisfiesAny };
81+ SnapshotData SnapshotSelfData = {SNAPSHOT_SELF };
82+ SnapshotData SnapshotAnyData = {SNAPSHOT_ANY };
8383
8484
8585/*
@@ -152,10 +152,7 @@ HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer,
152152 * HeapTupleSatisfiesSelf
153153 * True iff heap tuple is valid "for itself".
154154 *
155- * Here, we consider the effects of:
156- * all committed transactions (as of the current instant)
157- * previous commands of this transaction
158- * changes made by the current command
155+ * See SNAPSHOT_MVCC's definition for the intended behaviour.
159156 *
160157 * Note:
161158 * Assumes heap tuple is valid.
@@ -172,7 +169,7 @@ HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer,
172169 * (Xmax != my-transaction && the row was deleted by another transaction
173170 * Xmax is not committed))) that has not been committed
174171 */
175- bool
172+ static bool
176173HeapTupleSatisfiesSelf (HeapTuple htup , Snapshot snapshot , Buffer buffer )
177174{
178175 HeapTupleHeader tuple = htup -> t_data ;
@@ -342,7 +339,7 @@ HeapTupleSatisfiesSelf(HeapTuple htup, Snapshot snapshot, Buffer buffer)
342339 * HeapTupleSatisfiesAny
343340 * Dummy "satisfies" routine: any tuple satisfies SnapshotAny.
344341 */
345- bool
342+ static bool
346343HeapTupleSatisfiesAny (HeapTuple htup , Snapshot snapshot , Buffer buffer )
347344{
348345 return true;
@@ -352,6 +349,8 @@ HeapTupleSatisfiesAny(HeapTuple htup, Snapshot snapshot, Buffer buffer)
352349 * HeapTupleSatisfiesToast
353350 * True iff heap tuple is valid as a TOAST row.
354351 *
352+ * See SNAPSHOT_TOAST's definition for the intended behaviour.
353+ *
355354 * This is a simplified version that only checks for VACUUM moving conditions.
356355 * It's appropriate for TOAST usage because TOAST really doesn't want to do
357356 * its own time qual checks; if you can see the main table row that contains
@@ -362,7 +361,7 @@ HeapTupleSatisfiesAny(HeapTuple htup, Snapshot snapshot, Buffer buffer)
362361 * Among other things, this means you can't do UPDATEs of rows in a TOAST
363362 * table.
364363 */
365- bool
364+ static bool
366365HeapTupleSatisfiesToast (HeapTuple htup , Snapshot snapshot ,
367366 Buffer buffer )
368367{
@@ -716,10 +715,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
716715 * HeapTupleSatisfiesDirty
717716 * True iff heap tuple is valid including effects of open transactions.
718717 *
719- * Here, we consider the effects of:
720- * all committed and in-progress transactions (as of the current instant)
721- * previous commands of this transaction
722- * changes made by the current command
718+ * See SNAPSHOT_DIRTY's definition for the intended behaviour.
723719 *
724720 * This is essentially like HeapTupleSatisfiesSelf as far as effects of
725721 * the current transaction and committed/aborted xacts are concerned.
@@ -735,7 +731,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
735731 * on the insertion without aborting the whole transaction, the associated
736732 * token is also returned in snapshot->speculativeToken.
737733 */
738- bool
734+ static bool
739735HeapTupleSatisfiesDirty (HeapTuple htup , Snapshot snapshot ,
740736 Buffer buffer )
741737{
@@ -934,14 +930,7 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
934930 * HeapTupleSatisfiesMVCC
935931 * True iff heap tuple is valid for the given MVCC snapshot.
936932 *
937- * Here, we consider the effects of:
938- * all transactions committed as of the time of the given snapshot
939- * previous commands of this transaction
940- *
941- * Does _not_ include:
942- * transactions shown as in-progress by the snapshot
943- * transactions started after the snapshot was taken
944- * changes made by the current command
933+ * See SNAPSHOT_MVCC's definition for the intended behaviour.
945934 *
946935 * Notice that here, we will not update the tuple status hint bits if the
947936 * inserting/deleting transaction is still running according to our snapshot,
@@ -959,7 +948,7 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
959948 * inserting/deleting transaction was still running --- which was more cycles
960949 * and more contention on the PGXACT array.
961950 */
962- bool
951+ static bool
963952HeapTupleSatisfiesMVCC (HeapTuple htup , Snapshot snapshot ,
964953 Buffer buffer )
965954{
@@ -1390,11 +1379,13 @@ HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin,
13901379 * True if tuple might be visible to some transaction; false if it's
13911380 * surely dead to everyone, ie, vacuumable.
13921381 *
1393- * This is an interface to HeapTupleSatisfiesVacuum that meets the
1394- * SnapshotSatisfiesFunc API, so it can be used through a Snapshot.
1382+ * See SNAPSHOT_TOAST's definition for the intended behaviour.
1383+ *
1384+ * This is an interface to HeapTupleSatisfiesVacuum that's callable via
1385+ * HeapTupleSatisfiesSnapshot, so it can be used through a Snapshot.
13951386 * snapshot->xmin must have been set up with the xmin horizon to use.
13961387 */
1397- bool
1388+ static bool
13981389HeapTupleSatisfiesNonVacuumable (HeapTuple htup , Snapshot snapshot ,
13991390 Buffer buffer )
14001391{
@@ -1659,7 +1650,7 @@ TransactionIdInArray(TransactionId xid, TransactionId *xip, Size num)
16591650 * dangerous to do so as the semantics of doing so during timetravel are more
16601651 * complicated than when dealing "only" with the present.
16611652 */
1662- bool
1653+ static bool
16631654HeapTupleSatisfiesHistoricMVCC (HeapTuple htup , Snapshot snapshot ,
16641655 Buffer buffer )
16651656{
@@ -1796,3 +1787,44 @@ HeapTupleSatisfiesHistoricMVCC(HeapTuple htup, Snapshot snapshot,
17961787 else
17971788 return true;
17981789}
1790+
1791+ /*
1792+ * HeapTupleSatisfiesVisibility
1793+ * True iff heap tuple satisfies a time qual.
1794+ *
1795+ * Notes:
1796+ * Assumes heap tuple is valid, and buffer at least share locked.
1797+ *
1798+ * Hint bits in the HeapTuple's t_infomask may be updated as a side effect;
1799+ * if so, the indicated buffer is marked dirty.
1800+ */
1801+ bool
1802+ HeapTupleSatisfiesVisibility (HeapTuple tup , Snapshot snapshot , Buffer buffer )
1803+ {
1804+ switch (snapshot -> snapshot_type )
1805+ {
1806+ case SNAPSHOT_MVCC :
1807+ return HeapTupleSatisfiesMVCC (tup , snapshot , buffer );
1808+ break ;
1809+ case SNAPSHOT_SELF :
1810+ return HeapTupleSatisfiesSelf (tup , snapshot , buffer );
1811+ break ;
1812+ case SNAPSHOT_ANY :
1813+ return HeapTupleSatisfiesAny (tup , snapshot , buffer );
1814+ break ;
1815+ case SNAPSHOT_TOAST :
1816+ return HeapTupleSatisfiesToast (tup , snapshot , buffer );
1817+ break ;
1818+ case SNAPSHOT_DIRTY :
1819+ return HeapTupleSatisfiesDirty (tup , snapshot , buffer );
1820+ break ;
1821+ case SNAPSHOT_HISTORIC_MVCC :
1822+ return HeapTupleSatisfiesHistoricMVCC (tup , snapshot , buffer );
1823+ break ;
1824+ case SNAPSHOT_NON_VACUUMABLE :
1825+ return HeapTupleSatisfiesNonVacuumable (tup , snapshot , buffer );
1826+ break ;
1827+ }
1828+
1829+ return false; /* keep compiler quiet */
1830+ }
0 commit comments