1 -- txid_snapshot data type and related functions
3 select '12:13:'::txid_snapshot;
9 select '12:18:14,16'::txid_snapshot;
16 select '31:12:'::txid_snapshot;
17 ERROR: invalid input for txid_snapshot: "31:12:"
18 LINE 1: select '31:12:'::txid_snapshot;
20 select '0:1:'::txid_snapshot;
21 ERROR: invalid input for txid_snapshot: "0:1:"
22 LINE 1: select '0:1:'::txid_snapshot;
24 select '12:13:0'::txid_snapshot;
25 ERROR: invalid input for txid_snapshot: "12:13:0"
26 LINE 1: select '12:13:0'::txid_snapshot;
28 select '12:16:14,13'::txid_snapshot;
29 ERROR: invalid input for txid_snapshot: "12:16:14,13"
30 LINE 1: select '12:16:14,13'::txid_snapshot;
32 select '12:16:14,14'::txid_snapshot;
33 ERROR: invalid input for txid_snapshot: "12:16:14,14"
34 LINE 1: select '12:16:14,14'::txid_snapshot;
36 create temp table snapshot_test (
40 insert into snapshot_test values (1, '12:13:');
41 insert into snapshot_test values (2, '12:20:13,15,18');
42 insert into snapshot_test values (3, '100001:100009:100005,100007,100008');
43 insert into snapshot_test values (4, '100:150:101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131');
44 select snap from snapshot_test order by nr;
46 -------------------------------------------------------------------------------------------------------------------------------------
49 100001:100009:100005,100007,100008
50 100:150:101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131
53 select txid_snapshot_xmin(snap),
54 txid_snapshot_xmax(snap),
55 txid_snapshot_xip(snap)
56 from snapshot_test order by nr;
57 txid_snapshot_xmin | txid_snapshot_xmax | txid_snapshot_xip
58 --------------------+--------------------+-------------------
62 100001 | 100009 | 100005
63 100001 | 100009 | 100007
64 100001 | 100009 | 100008
98 select id, txid_visible_in_snapshot(id, snap)
99 from snapshot_test, generate_series(11, 21) id
101 id | txid_visible_in_snapshot
102 ----+--------------------------
117 select id, txid_visible_in_snapshot(id, snap)
118 from snapshot_test, generate_series(90, 160) id
120 id | txid_visible_in_snapshot
121 -----+--------------------------
195 -- test current values also
196 select txid_current() >= txid_snapshot_xmin(txid_current_snapshot());
202 -- we can't assume current is always less than xmax, however
203 select txid_visible_in_snapshot(txid_current(), txid_current_snapshot());
204 txid_visible_in_snapshot
205 --------------------------
210 select txid_snapshot '1000100010001000:1000100010001100:1000100010001012,1000100010001013';
212 ---------------------------------------------------------------------
213 1000100010001000:1000100010001100:1000100010001012,1000100010001013
216 select txid_visible_in_snapshot('1000100010001012', '1000100010001000:1000100010001100:1000100010001012,1000100010001013');
217 txid_visible_in_snapshot
218 --------------------------
222 select txid_visible_in_snapshot('1000100010001015', '1000100010001000:1000100010001100:1000100010001012,1000100010001013');
223 txid_visible_in_snapshot
224 --------------------------
228 -- test 64bit overflow
229 SELECT txid_snapshot '1:9223372036854775807:3';
231 -------------------------
232 1:9223372036854775807:3
235 SELECT txid_snapshot '1:9223372036854775808:3';
236 ERROR: invalid input for txid_snapshot: "1:9223372036854775808:3"
237 LINE 1: SELECT txid_snapshot '1:9223372036854775808:3';