diff options
| author | Robert Haas | 2016-08-23 14:30:52 +0000 |
|---|---|---|
| committer | Robert Haas | 2016-08-23 14:30:52 +0000 |
| commit | 86f31695f3b54211226949de519063bbf248e8c4 (patch) | |
| tree | 982c2bdcb5b6453e51b1318ac54be75ecdc665c3 /src/test | |
| parent | ff36700c3ba2180047b4103de440ffaa34889b72 (diff) | |
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.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/txid.out | 16 | ||||
| -rw-r--r-- | src/test/regress/sql/txid.sql | 7 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/test/regress/expected/txid.out b/src/test/regress/expected/txid.out index ddd217eb102..802ccb949f8 100644 --- a/src/test/regress/expected/txid.out +++ b/src/test/regress/expected/txid.out @@ -238,3 +238,19 @@ SELECT txid_snapshot '1:9223372036854775808:3'; ERROR: invalid input syntax for type txid_snapshot: "1:9223372036854775808:3" LINE 1: SELECT txid_snapshot '1:9223372036854775808:3'; ^ +-- test txid_current_if_assigned +BEGIN; +SELECT txid_current_if_assigned() IS NULL; + ?column? +---------- + t +(1 row) + +SELECT txid_current() \gset +SELECT txid_current_if_assigned() IS NOT DISTINCT FROM BIGINT :'txid_current'; + ?column? +---------- + t +(1 row) + +COMMIT; diff --git a/src/test/regress/sql/txid.sql b/src/test/regress/sql/txid.sql index b6650b922e6..4aefd9e64d1 100644 --- a/src/test/regress/sql/txid.sql +++ b/src/test/regress/sql/txid.sql @@ -52,3 +52,10 @@ select txid_visible_in_snapshot('1000100010001015', '1000100010001000:1000100010 -- test 64bit overflow SELECT txid_snapshot '1:9223372036854775807:3'; SELECT txid_snapshot '1:9223372036854775808:3'; + +-- test txid_current_if_assigned +BEGIN; +SELECT txid_current_if_assigned() IS NULL; +SELECT txid_current() \gset +SELECT txid_current_if_assigned() IS NOT DISTINCT FROM BIGINT :'txid_current'; +COMMIT; |
