pg_xact_commit_timestamp()

一个返回事务提交时间戳的函数

pg_xact_commit_timestamp() 是一个返回事务提交时间戳的系统函数。

pg_xact_commit_timestamp()PostgreSQL 9.5 中添加。

用法

pg_xact_commit_timestamp ( xid ) → timestamp with time zone

必须启用 track_commit_timestamp,否则 pg_xact_commit_timestamp() 将发出 ERROR 错误。

变更历史

示例

查看表中行的提交时间戳

postgres=# SELECT pg_xact_commit_timestamp(xmin), xmin, * FROM xact_test;
   pg_xact_commit_timestamp    | xmin | id | val
-------------------------------+------+----+-----
 2021-07-07 08:52:14.189175+01 |  738 |  1 | foo
 2021-07-07 08:52:22.72496+01  |  739 |  2 | bar
 2021-07-07 08:52:26.893677+01 |  740 |  3 | baz
(3 rows)

如果 track_commit_timestamp 设置为 offpg_xact_commit_timestamp() 将会因 ERROR 错误而失败。

postgres=# SELECT pg_xact_commit_timestamp(xmin), xmin, * FROM xact_test;
ERROR:  could not get commit timestamp data
HINT:  Make sure the configuration parameter "track_commit_timestamp" is set.

postgres=# SELECT pg_xact_commit_timestamp('738'::xid);
ERROR:  could not get commit timestamp data
HINT:  Make sure the configuration parameter "track_commit_timestamp" is set.

分类

系统函数, 事务

另请参阅

track_commit_timestamp, pg_last_committed_xact()

反馈

提交对“pg_xact_commit_timestamp()”的任何评论、建议或更正,请点击 此处