1616 * Portions Copyright (c) 1994, Regents of the University of California
1717 *
1818 * 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 $
2020 *
2121 *-------------------------------------------------------------------------
2222 */
@@ -38,10 +38,10 @@ boolReferentialIntegritySnapshotOverride = false;
3838
3939/*
4040 * HeapTupleSatisfiesItself
41+ *True iff heap tuple is valid "for itself".
4142 *
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)
4545 *previous commands of this transaction
4646 *changes made by the current command
4747 *
@@ -156,13 +156,15 @@ HeapTupleSatisfiesItself(HeapTupleHeader tuple)
156156
157157/*
158158 * HeapTupleSatisfiesNow
159+ *True iff heap tuple is valid "now".
159160 *
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)
163163 *previous commands of this transaction
164164 *
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.
166168 *
167169 * Note:
168170 *Assumes heap tuple is valid.
@@ -302,8 +304,7 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple)
302304
303305/*
304306 * HeapTupleSatisfiesToast
305- *
306- *Valid if the heap tuple is valid for TOAST usage.
307+ *True iff heap tuple is valid as a TOAST row.
307308 *
308309 * This is a simplified version that only checks for VACUUM moving conditions.
309310 * It's appropriate for TOAST usage because TOAST really doesn't want to do
@@ -361,12 +362,8 @@ HeapTupleSatisfiesToast(HeapTupleHeader tuple)
361362/*
362363 * HeapTupleSatisfiesUpdate
363364 *
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?".
370367 */
371368int
372369HeapTupleSatisfiesUpdate (HeapTuple htuple )
@@ -484,13 +481,14 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple)
484481return HeapTupleUpdated ;/* updated by other */
485482}
486483
487- /* HeapTupleSatisfiesDirty
488- *
489- *Visible tuples are those of:
484+ /*
485+ * HeapTupleSatisfiesDirty
486+ *True iff heap tuple is valid including effects of open transactions.
490487 *
491- *_any_ in-progress transaction
488+ *Here, we consider the effects of:
489+ *all committed and in-progress transactions (as of the current instant)
492490 *previous commands of this transaction
493- *changes by the current command
491+ *changesmade by the current command
494492 *
495493 * This is essentially like HeapTupleSatisfiesItself as far as effects of
496494 * the current transaction and committed/aborted xacts are concerned.
@@ -614,15 +612,15 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple)
614612
615613/*
616614 * HeapTupleSatisfiesSnapshot
615+ *True iff heap tuple is valid for the given snapshot.
617616 *
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
621619 *previous commands of this transaction
622620 *
623621 *Does _not_ include:
624- *transactions in-progresswhen our transaction started
625- *transactionscommitted afterour transaction started
622+ *transactionsshown as in-progressby the snapshot
623+ *transactionsstarted afterthe snapshot was taken
626624 *changes made by the current command
627625 *
628626 * This is the same as HeapTupleSatisfiesNow, except that transactions that
@@ -770,11 +768,9 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
770768/*
771769 * HeapTupleSatisfiesVacuum
772770 *
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.
778774 *
779775 * OldestXmin is a cutoff XID (obtained from GetOldestXmin()).Tuples
780776 * deleted by XIDs >= OldestXmin are deemed "recently dead"; they might