]> granicus.if.org Git - postgresql/commit
Change the way we mark tuples as frozen.
authorRobert Haas <rhaas@postgresql.org>
Sun, 22 Dec 2013 20:49:09 +0000 (15:49 -0500)
committerRobert Haas <rhaas@postgresql.org>
Sun, 22 Dec 2013 20:49:09 +0000 (15:49 -0500)
commit37484ad2aacef5ec794f4dd3d5cf814475180a78
treead9ca294fdb229d6b24309d90b9ee4e0b9a31b0a
parent961bf59fb7a7e4fab751e20e9372de7ab37c5649
Change the way we mark tuples as frozen.

Instead of changing the tuple xmin to FrozenTransactionId, the combination
of HEAP_XMIN_COMMITTED and HEAP_XMIN_INVALID, which were previously never
set together, is now defined as HEAP_XMIN_FROZEN.  A variety of previous
proposals to freeze tuples opportunistically before vacuum_freeze_min_age
is reached have foundered on the objection that replacing xmin by
FrozenTransactionId might hinder debugging efforts when things in this
area go awry; this patch is intended to solve that problem by keeping
the XID around (but largely ignoring the value to which it is set).

Third-party code that checks for HEAP_XMIN_INVALID on tuples where
HEAP_XMIN_COMMITTED might be set will be broken by this change.  To fix,
use the new accessor macros in htup_details.h rather than consulting the
bits directly.  HeapTupleHeaderGetXmin has been modified to return
FrozenTransactionId when the infomask bits indicate that the tuple is
frozen; use HeapTupleHeaderGetRawXmin when you already know that the
tuple isn't marked commited or frozen, or want the raw value anyway.
We currently do this in routines that display the xmin for user consumption,
in tqual.c where it's known to be safe and important for the avoidance of
extra cycles, and in the function-caching code for various procedural
languages, which shouldn't invalidate the cache just because the tuple
gets frozen.

Robert Haas and Andres Freund
17 files changed:
contrib/pageinspect/heapfuncs.c
src/backend/access/common/heaptuple.c
src/backend/access/heap/heapam.c
src/backend/commands/sequence.c
src/backend/commands/vacuumlazy.c
src/backend/storage/buffer/README
src/backend/utils/fmgr/fmgr.c
src/backend/utils/time/combocid.c
src/backend/utils/time/tqual.c
src/include/access/heapam_xlog.h
src/include/access/htup_details.h
src/include/access/xlog_internal.h
src/pl/plperl/plperl.c
src/pl/plpgsql/src/pl_comp.c
src/pl/plpython/plpy_procedure.c
src/pl/plpython/plpy_typeio.c
src/pl/tcl/pltcl.c