此条目涉及一个 PostgreSQL 功能,该功能已弃用,并可能在未来的版本中不再支持。
txid_status() 是一个已弃用的系统函数,用于报告近期事务的提交状态。
txid_status() 在 PostgreSQL 8.3 中添加。
用法
txid_status (bigint) →text
txid_status() 返回以下值之一:
committed(已提交)in progress(进行中)aborted(已中止)
在 PostgreSQL 13 中引入 xid8 数据类型后,此函数已被弃用,并被 pg_xact_status() 取代。
变更历史
- PostgreSQL 13
- 标记为已弃用 (commit 4c04be9b)
- PostgreSQL 8.3
- 添加 (commit 1f92630f)
示例
txid_status() 的基本用法示例
postgres=# BEGIN ; BEGIN postgres=*# SELECT txid_current(); txid_current -------------- 757 (1 row) postgres=*# SELECT txid_status(757); txid_status ------------- in progress (1 row) postgres=*# COMMIT; COMMIT postgres=# SELECT txid_status(757); txid_status ------------- committed (1 row)
尝试检索尚未发生的事务的状态
postgres=# SELECT txid_status(9999); ERROR: transaction ID 9999 is in the future
参考资料
- PostgreSQL 文档: 已弃用的事务 ID 和快照信息函数
