【问题标题】:PostgreSQL: what does pg_xact_commit_timestamp() return if the xid was from a failed transaction?PostgreSQL:如果 xid 来自失败的事务,那么 pg_xact_commit_timestamp() 会返回什么?
【发布时间】:2016-11-29 18:44:04
【问题描述】:

比如假设xid 6834是回滚,那么这个应该返回什么?

select pg_xact_commit_timestamp('6834'::xid);

文档中没有提到任何内容......似乎假设 xid 来自已提交的事务。所以我的问题是这种回滚事务的答案是稳定且有意义的吗?可以通过 select txid_current();BEGIN ... ROLLBACK uow 中获取此类 xid。

【问题讨论】:

    标签: postgresql transactions


    【解决方案1】:

    它将返回NULL:

    test=> BEGIN;
    BEGIN
    test=> SELECT txid_current();
     txid_current
    --------------
             1942
    (1 row)
    
    test=> ROLLBACK;
    ROLLBACK
    test=> select pg_xact_commit_timestamp('1942'::xid) IS NULL;
     ?column?
    ----------
     t
    (1 row)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-08
      • 1970-01-01
      • 2021-11-06
      • 1970-01-01
      • 1970-01-01
      • 2019-03-10
      • 2019-02-10
      • 1970-01-01
      相关资源
      最近更新 更多