pg_prepared_xacts

A system view providing information about prepared transactions

pg_prepared_xacts is a system catalogue view providing information about transactions currently prepared for two-phase commit.

pg_prepared_xacts was added in PostgreSQL 8.1.

Definition by PostgreSQL version

pg_prepared_xacts (PostgreSQL 15)

                   View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Collation | Nullable | Default 
-------------+--------------------------+-----------+----------+---------
 transaction | xid                      |           |          | 
 gid         | text                     |           |          | 
 prepared    | timestamp with time zone |           |          | 
 owner       | name                     |           |          | 
 database    | name                     |           |          |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 14)

                   View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Collation | Nullable | Default 
-------------+--------------------------+-----------+----------+---------
 transaction | xid                      |           |          | 
 gid         | text                     |           |          | 
 prepared    | timestamp with time zone |           |          | 
 owner       | name                     |           |          | 
 database    | name                     |           |          |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 13)

                   View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Collation | Nullable | Default 
-------------+--------------------------+-----------+----------+---------
 transaction | xid                      |           |          | 
 gid         | text                     |           |          | 
 prepared    | timestamp with time zone |           |          | 
 owner       | name                     |           |          | 
 database    | name                     |           |          |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 12)

                   View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Collation | Nullable | Default 
-------------+--------------------------+-----------+----------+---------
 transaction | xid                      |           |          | 
 gid         | text                     |           |          | 
 prepared    | timestamp with time zone |           |          | 
 owner       | name                     |           |          | 
 database    | name                     |           |          |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 11)

                   View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Collation | Nullable | Default 
-------------+--------------------------+-----------+----------+---------
 transaction | xid                      |           |          | 
 gid         | text                     |           |          | 
 prepared    | timestamp with time zone |           |          | 
 owner       | name                     |           |          | 
 database    | name                     |           |          |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 10)

                   View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Collation | Nullable | Default 
-------------+--------------------------+-----------+----------+---------
 transaction | xid                      |           |          | 
 gid         | text                     |           |          | 
 prepared    | timestamp with time zone |           |          | 
 owner       | name                     |           |          | 
 database    | name                     |           |          |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 9.6)

        View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Modifiers 
-------------+--------------------------+-----------
 transaction | xid                      | 
 gid         | text                     | 
 prepared    | timestamp with time zone | 
 owner       | name                     | 
 database    | name                     |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 9.5)

        View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Modifiers 
-------------+--------------------------+-----------
 transaction | xid                      | 
 gid         | text                     | 
 prepared    | timestamp with time zone | 
 owner       | name                     | 
 database    | name                     |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 9.4)

        View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Modifiers 
-------------+--------------------------+-----------
 transaction | xid                      | 
 gid         | text                     | 
 prepared    | timestamp with time zone | 
 owner       | name                     | 
 database    | name                     |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 9.3)

        View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Modifiers 
-------------+--------------------------+-----------
 transaction | xid                      | 
 gid         | text                     | 
 prepared    | timestamp with time zone | 
 owner       | name                     | 
 database    | name                     |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 9.2)

        View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Modifiers 
-------------+--------------------------+-----------
 transaction | xid                      | 
 gid         | text                     | 
 prepared    | timestamp with time zone | 
 owner       | name                     | 
 database    | name                     |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 9.1)

        View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Modifiers 
-------------+--------------------------+-----------
 transaction | xid                      | 
 gid         | text                     | 
 prepared    | timestamp with time zone | 
 owner       | name                     | 
 database    | name                     |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 9.0)

        View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Modifiers 
-------------+--------------------------+-----------
 transaction | xid                      | 
 gid         | text                     | 
 prepared    | timestamp with time zone | 
 owner       | name                     | 
 database    | name                     |
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 8.4)

        View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Modifiers 
-------------+--------------------------+-----------
 transaction | xid                      | 
 gid         | text                     | 
 prepared    | timestamp with time zone | 
 owner       | name                     | 
 database    | name                     | 
View definition:
 SELECT p.transaction, p.gid, p.prepared, u.rolname AS owner, d.datname AS database
   FROM pg_prepared_xact() p(transaction, gid, prepared, ownerid, dbid)
   LEFT JOIN pg_authid u ON p.ownerid = u.oid
   LEFT JOIN pg_database d ON p.dbid = d.oid;
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 8.3)

        View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Modifiers 
-------------+--------------------------+-----------
 transaction | xid                      | 
 gid         | text                     | 
 prepared    | timestamp with time zone | 
 owner       | name                     | 
 database    | name                     | 
View definition:
 SELECT p.transaction, p.gid, p.prepared, u.rolname AS owner, d.datname AS database
   FROM pg_prepared_xact() p(transaction xid, gid text, prepared timestamp with time zone, ownerid oid, dbid oid)
   LEFT JOIN pg_authid u ON p.ownerid = u.oid
   LEFT JOIN pg_database d ON p.dbid = d.oid;
    

Documentation: pg_prepared_xacts

pg_prepared_xacts (PostgreSQL 8.2)

        View "pg_catalog.pg_prepared_xacts"
   Column    |           Type           | Modifiers 
-------------+--------------------------+-----------
 transaction | xid                      | 
 gid         | text                     | 
 prepared    | timestamp with time zone | 
 owner       | name                     | 
 database    | name                     | 
View definition:
 SELECT p."transaction", p.gid, p."prepared", u.rolname AS "owner", d.datname AS "database"
   FROM pg_prepared_xact() p("transaction" xid, gid text, "prepared" timestamp with time zone, ownerid oid, dbid oid)
   LEFT JOIN pg_authid u ON p.ownerid = u.oid
   LEFT JOIN pg_database d ON p.dbid = d.oid;
    

Documentation: pg_prepared_xacts

Change history

pg_prepared_xacts has not been modified since it was added in PostgreSQL 8.1.

Examples

Sample contents of :

postgres=# BEGIN;
BEGIN

postgres=*# PREPARE TRANSACTION 'foo';
PREPARE TRANSACTION

postgres=# SELECT * FROM pg_prepared_xacts;
 transaction | gid |           prepared            |  owner   | database
-------------+-----+-------------------------------+----------+----------
         721 | foo | 2021-09-07 10:49:32.784179+01 | postgres | postgres
(1 row)

Categories

System catalogue, Transactions

See also

PREPARE TRANSACTION, max_prepared_transactions