The following functions provide server transaction information in an exportable form. The main use of these functions is to determine which transactions were committed between two snapshots.
Description: Determines whether the given XID is committed or ignored. NULL indicates the unknown status (such as running, preparing, and freezing).
Return type: Boolean
Description: Gets current transaction ID.
Return type: bigint
Description: Gets current snapshot.
Return type: txid_snapshot
Description: Gets in-progress transaction IDs in snapshot.
Return type: setof bigint
Description: Gets xmax of snapshot.
Return type: bigint
Description: Gets xmin of snapshot.
Return type: bigint
Description: Queries whether the transaction ID is visible in snapshot. (do not use with subtransaction IDs)
Return type: boolean
The internal transaction ID type (xid) is 32 bits wide and wraps around every 4 billion transactions. txid_snapshot, the data type used by these functions, stores information about transaction ID visibility at a particular moment in time. Table 1 describes its components.
Name |
Description |
---|---|
xmin |
Earliest transaction ID (txid) that is still active. All earlier transactions will either be committed and visible, or rolled back. |
xmax |
First as-yet-unassigned txid. All txids greater than or equal to this are not yet started as of the time of the snapshot, so they are invisible. |
xip_list |
Active txids at the time of the snapshot. The list includes only those active txids between xmin and xmax; there might be active txids higher than xmax. A txid that is xmin <= txid < xmax and not in this list was already completed at the time of the snapshot, and is either visible or dead according to its commit status. The list does not include txids of subtransactions. |
txid_snapshot's textual representation is xmin:xmax:xip_list.
For example: 10:20:10,14,15 means xmin=10, xmax=20, xip_list=10, 14, 15.