1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Add txid_current_ifassigned().

Add a variant of txid_current() that returns NULL if no transaction ID
is assigned.  This version can be used even on a standby server,
although it will always return NULL since no transaction IDs can be
assigned during recovery.

Craig Ringer, per suggestion from Jim Nasby.  Reviewed by Petr Jelinek
and by me.
This commit is contained in:
Robert Haas
2016-08-23 10:30:52 -04:00
parent ff36700c3b
commit 86f31695f3
6 changed files with 56 additions and 0 deletions

View File

@ -17119,6 +17119,10 @@ SELECT collation for ('foo' COLLATE "de_DE");
<primary>txid_current</primary>
</indexterm>
<indexterm>
<primary>txid_current_if_assigned</primary>
</indexterm>
<indexterm>
<primary>txid_current_snapshot</primary>
</indexterm>
@ -17159,6 +17163,11 @@ SELECT collation for ('foo' COLLATE "de_DE");
<entry><type>bigint</type></entry>
<entry>get current transaction ID, assigning a new one if the current transaction does not have one</entry>
</row>
<row>
<entry><literal><function>txid_current_if_assigned()</function></literal></entry>
<entry><type>bigint</type></entry>
<entry>same as <function>txid_current()</function> but returns null instead of assigning an xid if none is already assigned</entry>
</row>
<row>
<entry><literal><function>txid_current_snapshot()</function></literal></entry>
<entry><type>txid_snapshot</type></entry>