1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
txid - 8 byte transaction ID's
==============================
Based on xxid module from Slony-I.
The goal is to make PostgreSQL internal transaction ID and snapshot
data usable externally. They cannot be used directly as the
internal 4-byte value wraps around and thus breaks indexing.
This module extends the internal value with wraparound cound (epoch).
It uses relaxed method for wraparound check. There is a table
txid.epoch (epoch, last_value) which is used to check if the xid
is in current, next or previous epoch. It requires only occasional
read-write access - ca. after 100k - 500k transactions.
Also it contains type 'txid_snapshot' and following functions:
txid_current() returns int8
Current transaction ID
txid_current_snapshot() returns txid_snapshot
Current snapshot
txid_snapshot_xmin( snap ) returns int8
Smallest TXID in snapshot. TXID's smaller than this
are all visible in snapshot.
txid_snapshot_xmax( snap ) returns int8
Largest TXID in snapshot. TXID's starting from this one are
all invisible in snapshot.
txid_snapshot_xip( snap ) setof int8
List of uncommitted TXID's in snapshot, that are invisible
in snapshot. Values are between xmin and xmax.
txid_visible_in_snapshot(id, snap) returns bool
Is TXID visible in snapshot?
Problems
--------
- it breaks when there are more than 2G tx'es between calls.
Fixed in 8.2
- functions that create new txid's should be 'security definers'
thus better protecting txid_epoch table.
- After loading database from backup you should do:
UPDATE txid.epoch SET epoch = epoch + 1,
last_value = (get_current_txid() & 4294967295);
|