78
78
79
79
80
80
/* 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 };
83
83
84
84
85
85
/*
@@ -152,10 +152,7 @@ HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer,
152
152
* HeapTupleSatisfiesSelf
153
153
* True iff heap tuple is valid "for itself".
154
154
*
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.
159
156
*
160
157
* Note:
161
158
* Assumes heap tuple is valid.
@@ -172,7 +169,7 @@ HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer,
172
169
* (Xmax != my-transaction && the row was deleted by another transaction
173
170
* Xmax is not committed))) that has not been committed
174
171
*/
175
- bool
172
+ static bool
176
173
HeapTupleSatisfiesSelf (HeapTuple htup , Snapshot snapshot , Buffer buffer )
177
174
{
178
175
HeapTupleHeader tuple = htup -> t_data ;
@@ -342,7 +339,7 @@ HeapTupleSatisfiesSelf(HeapTuple htup, Snapshot snapshot, Buffer buffer)
342
339
* HeapTupleSatisfiesAny
343
340
* Dummy "satisfies" routine: any tuple satisfies SnapshotAny.
344
341
*/
345
- bool
342
+ static bool
346
343
HeapTupleSatisfiesAny (HeapTuple htup , Snapshot snapshot , Buffer buffer )
347
344
{
348
345
return true;
@@ -352,6 +349,8 @@ HeapTupleSatisfiesAny(HeapTuple htup, Snapshot snapshot, Buffer buffer)
352
349
* HeapTupleSatisfiesToast
353
350
* True iff heap tuple is valid as a TOAST row.
354
351
*
352
+ * See SNAPSHOT_TOAST's definition for the intended behaviour.
353
+ *
355
354
* This is a simplified version that only checks for VACUUM moving conditions.
356
355
* It's appropriate for TOAST usage because TOAST really doesn't want to do
357
356
* 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)
362
361
* Among other things, this means you can't do UPDATEs of rows in a TOAST
363
362
* table.
364
363
*/
365
- bool
364
+ static bool
366
365
HeapTupleSatisfiesToast (HeapTuple htup , Snapshot snapshot ,
367
366
Buffer buffer )
368
367
{
@@ -716,10 +715,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
716
715
* HeapTupleSatisfiesDirty
717
716
* True iff heap tuple is valid including effects of open transactions.
718
717
*
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.
723
719
*
724
720
* This is essentially like HeapTupleSatisfiesSelf as far as effects of
725
721
* the current transaction and committed/aborted xacts are concerned.
@@ -735,7 +731,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
735
731
* on the insertion without aborting the whole transaction, the associated
736
732
* token is also returned in snapshot->speculativeToken.
737
733
*/
738
- bool
734
+ static bool
739
735
HeapTupleSatisfiesDirty (HeapTuple htup , Snapshot snapshot ,
740
736
Buffer buffer )
741
737
{
@@ -934,14 +930,7 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
934
930
* HeapTupleSatisfiesMVCC
935
931
* True iff heap tuple is valid for the given MVCC snapshot.
936
932
*
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.
945
934
*
946
935
* Notice that here, we will not update the tuple status hint bits if the
947
936
* inserting/deleting transaction is still running according to our snapshot,
@@ -959,7 +948,7 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
959
948
* inserting/deleting transaction was still running --- which was more cycles
960
949
* and more contention on the PGXACT array.
961
950
*/
962
- bool
951
+ static bool
963
952
HeapTupleSatisfiesMVCC (HeapTuple htup , Snapshot snapshot ,
964
953
Buffer buffer )
965
954
{
@@ -1390,11 +1379,13 @@ HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin,
1390
1379
* True if tuple might be visible to some transaction; false if it's
1391
1380
* surely dead to everyone, ie, vacuumable.
1392
1381
*
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.
1395
1386
* snapshot->xmin must have been set up with the xmin horizon to use.
1396
1387
*/
1397
- bool
1388
+ static bool
1398
1389
HeapTupleSatisfiesNonVacuumable (HeapTuple htup , Snapshot snapshot ,
1399
1390
Buffer buffer )
1400
1391
{
@@ -1659,7 +1650,7 @@ TransactionIdInArray(TransactionId xid, TransactionId *xip, Size num)
1659
1650
* dangerous to do so as the semantics of doing so during timetravel are more
1660
1651
* complicated than when dealing "only" with the present.
1661
1652
*/
1662
- bool
1653
+ static bool
1663
1654
HeapTupleSatisfiesHistoricMVCC (HeapTuple htup , Snapshot snapshot ,
1664
1655
Buffer buffer )
1665
1656
{
@@ -1796,3 +1787,44 @@ HeapTupleSatisfiesHistoricMVCC(HeapTuple htup, Snapshot snapshot,
1796
1787
else
1797
1788
return true;
1798
1789
}
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