pg_xact_status()

报告事务提交状态的函数

pg_xact_status() 是一个报告近期事务提交状态的系统函数。

pg_xact_status()PostgreSQL 13 中添加。

用法

pg_xact_status ( xid8 ) → text

pg_xact_status() 返回以下值之一

  • committed
  • in progress
  • aborted

pg_xact_status() 替代了 txid_status()

变更历史

示例

pg_xact_status() 的基本用法示例

postgres=# BEGIN;
BEGIN

postgres=*# SELECT pg_current_xact_id();
 pg_current_xact_id 
--------------------
                762
(1 row)

postgres=*# SELECT pg_xact_status('762');
 pg_xact_status 
----------------
 in progress
(1 row)

postgres=*# COMMIT; COMMIT postgres=# SELECT pg_xact_status('762'); pg_xact_status ---------------- committed (1 row)

尝试检索尚未发生的事务的状态

postgres=# SELECT pg_xact_status('9999');
ERROR:  transaction ID 9999 is in the future

分类

系统函数, 事务

另请参阅

pg_current_xact_id(), pg_current_xact_id_if_assigned(), pg_prepared_xacts

反馈

提交关于“pg_xact_status()”的任何评论、建议或更正 请点击这里