Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 78d6a9c

Browse files
committed
Fix and improve SnapshotType comments.
The comment for SNAPSHOT_SELF was unfortunately explaining SNAPSHOT_DIRTY, as reported by Sergei. Also expand a few comments, and include a few more comments from heapam_visibility.c, so they're in an AM independent place. Reported-By: Sergei Kornilov Author: Andres Freund Discussion: https://postgr.es/m/9152241558192351@sas1-d856b3d759c7.qloud-c.yandex.net
1 parent ae35e1c commit 78d6a9c

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/include/utils/snapshot.h

+24-5
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ typedef enum SnapshotType
5050
SNAPSHOT_MVCC = 0,
5151

5252
/*-------------------------------------------------------------------------
53-
* A tuple is visible iff the tuple is valid including effects of open
54-
* transactions.
53+
* A tuple is visible iff the tuple is valid "for itself".
5554
*
5655
* Here, we consider the effects of:
57-
* - all committed and in-progress transactions (as of the current instant)
56+
* - all committed transactions (as of the current instant)
5857
* - previous commands of this transaction
5958
* - changes made by the current command
59+
*
60+
* Does _not_ include:
61+
* - in-progress transactions (as of the current instant)
6062
* -------------------------------------------------------------------------
6163
*/
6264
SNAPSHOT_SELF,
@@ -79,6 +81,22 @@ typedef enum SnapshotType
7981
* - all committed and in-progress transactions (as of the current instant)
8082
* - previous commands of this transaction
8183
* - changes made by the current command
84+
*
85+
* This is essentially like SNAPSHOT_SELF as far as effects of the current
86+
* transaction and committed/aborted xacts are concerned. However, it
87+
* also includes the effects of other xacts still in progress.
88+
*
89+
* A special hack is that when a snapshot of this type is used to
90+
* determine tuple visibility, the passed-in snapshot struct is used as an
91+
* output argument to return the xids of concurrent xacts that affected
92+
* the tuple. snapshot->xmin is set to the tuple's xmin if that is
93+
* another transaction that's still in progress; or to
94+
* InvalidTransactionId if the tuple's xmin is committed good, committed
95+
* dead, or my own xact. Similarly for snapshot->xmax and the tuple's
96+
* xmax. If the tuple was inserted speculatively, meaning that the
97+
* inserter might still back down on the insertion without aborting the
98+
* whole transaction, the associated token is also returned in
99+
* snapshot->speculativeToken. See also InitDirtySnapshot().
82100
* -------------------------------------------------------------------------
83101
*/
84102
SNAPSHOT_DIRTY,
@@ -92,9 +110,10 @@ typedef enum SnapshotType
92110

93111
/*
94112
* A tuple is visible iff the tuple might be visible to some transaction;
95-
* false if it's surely dead to everyone, ie, vacuumable.
113+
* false if it's surely dead to everyone, i.e., vacuumable.
96114
*
97-
* Snapshot.xmin must have been set up with the xmin horizon to use.
115+
* For visibility checks snapshot->min must have been set up with the xmin
116+
* horizon to use.
98117
*/
99118
SNAPSHOT_NON_VACUUMABLE
100119
} SnapshotType;

0 commit comments

Comments
 (0)