有没有办法从SQL查询或plpgsql函数体中获取transactionid(xid)?
版本的PostgreSQL 9.3
答案 0 :(得分:4)
http://www.postgresql.org/docs/9.3/static/functions-info.html#FUNCTIONS-TXID-SNAPSHOT
txid_current()
可能就是你想要的。
答案 1 :(得分:3)
在PostgreSQL 10或更高版本中,请考虑使用txid_current_if_assigned()
。 The manual:
与
txid_current()
相同,但如果没有分配新的事务ID,则返回null而不是分配新的事务ID