16
16
* Portions Copyright (c) 1994, Regents of the University of California
17
17
*
18
18
* IDENTIFICATION
19
- * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.48 2002/01/16 23:09:09 momjian Exp $
19
+ * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.49 2002/01/16 23:51:56 tgl Exp $
20
20
*
21
21
*-------------------------------------------------------------------------
22
22
*/
@@ -38,10 +38,10 @@ bool ReferentialIntegritySnapshotOverride = false;
38
38
39
39
/*
40
40
* HeapTupleSatisfiesItself
41
+ * True iff heap tuple is valid "for itself".
41
42
*
42
- * Visible tuples are those of:
43
- *
44
- * transactions committed before our _command_ started (READ COMMITTED)
43
+ * Here, we consider the effects of:
44
+ * all committed transactions (as of the current instant)
45
45
* previous commands of this transaction
46
46
* changes made by the current command
47
47
*
@@ -156,13 +156,15 @@ HeapTupleSatisfiesItself(HeapTupleHeader tuple)
156
156
157
157
/*
158
158
* HeapTupleSatisfiesNow
159
+ * True iff heap tuple is valid "now".
159
160
*
160
- * Visible tuples are those of:
161
- *
162
- * transactions committed before our _command_ started (READ COMMITTED)
161
+ * Here, we consider the effects of:
162
+ * all committed transactions (as of the current instant)
163
163
* previous commands of this transaction
164
164
*
165
- * Does _not_ include changes made by the current command
165
+ * Note we do _not_ include changes made by the current command. This
166
+ * solves the "Halloween problem" wherein an UPDATE might try to re-update
167
+ * its own output tuples.
166
168
*
167
169
* Note:
168
170
* Assumes heap tuple is valid.
@@ -302,8 +304,7 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple)
302
304
303
305
/*
304
306
* HeapTupleSatisfiesToast
305
- *
306
- * Valid if the heap tuple is valid for TOAST usage.
307
+ * True iff heap tuple is valid as a TOAST row.
307
308
*
308
309
* This is a simplified version that only checks for VACUUM moving conditions.
309
310
* It's appropriate for TOAST usage because TOAST really doesn't want to do
@@ -361,12 +362,8 @@ HeapTupleSatisfiesToast(HeapTupleHeader tuple)
361
362
/*
362
363
* HeapTupleSatisfiesUpdate
363
364
*
364
- * Same as HeapTupleSatisfiesNow, but returns more information needed
365
- * by UPDATE.
366
- *
367
- * This applies the same checks as HeapTupleSatisfiesNow,
368
- * but returns a more detailed result code, since UPDATE needs to know
369
- * more than "is it visible?".
365
+ * Same logic as HeapTupleSatisfiesNow, but returns a more detailed result
366
+ * code, since UPDATE needs to know more than "is it visible?".
370
367
*/
371
368
int
372
369
HeapTupleSatisfiesUpdate (HeapTuple htuple )
@@ -484,13 +481,14 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple)
484
481
return HeapTupleUpdated ; /* updated by other */
485
482
}
486
483
487
- /* HeapTupleSatisfiesDirty
488
- *
489
- * Visible tuples are those of:
484
+ /*
485
+ * HeapTupleSatisfiesDirty
486
+ * True iff heap tuple is valid including effects of open transactions.
490
487
*
491
- * _any_ in-progress transaction
488
+ * Here, we consider the effects of:
489
+ * all committed and in-progress transactions (as of the current instant)
492
490
* previous commands of this transaction
493
- * changes by the current command
491
+ * changes made by the current command
494
492
*
495
493
* This is essentially like HeapTupleSatisfiesItself as far as effects of
496
494
* the current transaction and committed/aborted xacts are concerned.
@@ -614,15 +612,15 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple)
614
612
615
613
/*
616
614
* HeapTupleSatisfiesSnapshot
615
+ * True iff heap tuple is valid for the given snapshot.
617
616
*
618
- * Visible tuples are those of:
619
- *
620
- * transactions committed before our transaction started (SERIALIZABLE)
617
+ * Here, we consider the effects of:
618
+ * all transactions committed as of the time of the given snapshot
621
619
* previous commands of this transaction
622
620
*
623
621
* Does _not_ include:
624
- * transactions in-progress when our transaction started
625
- * transactions committed after our transaction started
622
+ * transactions shown as in-progress by the snapshot
623
+ * transactions started after the snapshot was taken
626
624
* changes made by the current command
627
625
*
628
626
* This is the same as HeapTupleSatisfiesNow, except that transactions that
@@ -770,11 +768,9 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
770
768
/*
771
769
* HeapTupleSatisfiesVacuum
772
770
*
773
- * Visible tuples are those of:
774
- *
775
- * tuples visible by any running transaction
776
- *
777
- * Used by VACUUM and related operations.
771
+ * Determine the status of tuples for VACUUM purposes. Here, what
772
+ * we mainly want to know is if a tuple is potentially visible to *any*
773
+ * running transaction. If so, it can't be removed yet by VACUUM.
778
774
*
779
775
* OldestXmin is a cutoff XID (obtained from GetOldestXmin()). Tuples
780
776
* deleted by XIDs >= OldestXmin are deemed "recently dead"; they might
0 commit comments