|
| 1 | +-- init |
| 2 | +\set ECHO none |
| 3 | +-- i/o |
| 4 | +select '12:13:'::txid_snapshot; |
| 5 | + txid_snapshot |
| 6 | +--------------- |
| 7 | + 12:13: |
| 8 | +(1 row) |
| 9 | + |
| 10 | +select '12:13:1,2'::txid_snapshot; |
| 11 | +ERROR: illegal txid_snapshot input format |
| 12 | +-- errors |
| 13 | +select '31:12:'::txid_snapshot; |
| 14 | +ERROR: illegal txid_snapshot input format |
| 15 | +select '0:1:'::txid_snapshot; |
| 16 | +ERROR: illegal txid_snapshot input format |
| 17 | +select '12:13:0'::txid_snapshot; |
| 18 | +ERROR: illegal txid_snapshot input format |
| 19 | +select '12:16:14,13'::txid_snapshot; |
| 20 | +ERROR: illegal txid_snapshot input format |
| 21 | +select '12:16:14,14'::txid_snapshot; |
| 22 | +ERROR: illegal txid_snapshot input format |
| 23 | +create table snapshot_test ( |
| 24 | + nr integer, |
| 25 | + snap txid_snapshot |
| 26 | +); |
| 27 | +insert into snapshot_test values (1, '12:13:'); |
| 28 | +insert into snapshot_test values (2, '12:20:13,15,18'); |
| 29 | +insert into snapshot_test values (3, '100001:100009:100005,100007,100008'); |
| 30 | +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'); |
| 31 | +select snap from snapshot_test order by nr; |
| 32 | + snap |
| 33 | +------------------------------------------------------------------------------------------------------------------------------------- |
| 34 | + 12:13: |
| 35 | + 12:20:13,15,18 |
| 36 | + 100001:100009:100005,100007,100008 |
| 37 | + 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 |
| 38 | +(4 rows) |
| 39 | + |
| 40 | +select txid_snapshot_xmin(snap), |
| 41 | + txid_snapshot_xmax(snap), |
| 42 | + txid_snapshot_xip(snap) |
| 43 | +from snapshot_test order by nr; |
| 44 | + txid_snapshot_xmin | txid_snapshot_xmax | txid_snapshot_xip |
| 45 | +--------------------+--------------------+------------------- |
| 46 | + 12 | 20 | 13 |
| 47 | + 12 | 20 | 15 |
| 48 | + 12 | 20 | 18 |
| 49 | + 100001 | 100009 | 100005 |
| 50 | + 100001 | 100009 | 100007 |
| 51 | + 100001 | 100009 | 100008 |
| 52 | + 100 | 150 | 101 |
| 53 | + 100 | 150 | 102 |
| 54 | + 100 | 150 | 103 |
| 55 | + 100 | 150 | 104 |
| 56 | + 100 | 150 | 105 |
| 57 | + 100 | 150 | 106 |
| 58 | + 100 | 150 | 107 |
| 59 | + 100 | 150 | 108 |
| 60 | + 100 | 150 | 109 |
| 61 | + 100 | 150 | 110 |
| 62 | + 100 | 150 | 111 |
| 63 | + 100 | 150 | 112 |
| 64 | + 100 | 150 | 113 |
| 65 | + 100 | 150 | 114 |
| 66 | + 100 | 150 | 115 |
| 67 | + 100 | 150 | 116 |
| 68 | + 100 | 150 | 117 |
| 69 | + 100 | 150 | 118 |
| 70 | + 100 | 150 | 119 |
| 71 | + 100 | 150 | 120 |
| 72 | + 100 | 150 | 121 |
| 73 | + 100 | 150 | 122 |
| 74 | + 100 | 150 | 123 |
| 75 | + 100 | 150 | 124 |
| 76 | + 100 | 150 | 125 |
| 77 | + 100 | 150 | 126 |
| 78 | + 100 | 150 | 127 |
| 79 | + 100 | 150 | 128 |
| 80 | + 100 | 150 | 129 |
| 81 | + 100 | 150 | 130 |
| 82 | + 100 | 150 | 131 |
| 83 | +(37 rows) |
| 84 | + |
| 85 | +select id, txid_visible_in_snapshot(id, snap) |
| 86 | +from snapshot_test, generate_series(11, 21) id |
| 87 | +where nr = 2; |
| 88 | + id | txid_visible_in_snapshot |
| 89 | +----+-------------------------- |
| 90 | + 11 | t |
| 91 | + 12 | t |
| 92 | + 13 | f |
| 93 | + 14 | t |
| 94 | + 15 | f |
| 95 | + 16 | t |
| 96 | + 17 | t |
| 97 | + 18 | f |
| 98 | + 19 | t |
| 99 | + 20 | f |
| 100 | + 21 | f |
| 101 | +(11 rows) |
| 102 | + |
| 103 | +-- test bsearch |
| 104 | +select id, txid_visible_in_snapshot(id, snap) |
| 105 | +from snapshot_test, generate_series(90, 160) id |
| 106 | +where nr = 4; |
| 107 | + id | txid_visible_in_snapshot |
| 108 | +-----+-------------------------- |
| 109 | + 90 | t |
| 110 | + 91 | t |
| 111 | + 92 | t |
| 112 | + 93 | t |
| 113 | + 94 | t |
| 114 | + 95 | t |
| 115 | + 96 | t |
| 116 | + 97 | t |
| 117 | + 98 | t |
| 118 | + 99 | t |
| 119 | + 100 | t |
| 120 | + 101 | f |
| 121 | + 102 | f |
| 122 | + 103 | f |
| 123 | + 104 | f |
| 124 | + 105 | f |
| 125 | + 106 | f |
| 126 | + 107 | f |
| 127 | + 108 | f |
| 128 | + 109 | f |
| 129 | + 110 | f |
| 130 | + 111 | f |
| 131 | + 112 | f |
| 132 | + 113 | f |
| 133 | + 114 | f |
| 134 | + 115 | f |
| 135 | + 116 | f |
| 136 | + 117 | f |
| 137 | + 118 | f |
| 138 | + 119 | f |
| 139 | + 120 | f |
| 140 | + 121 | f |
| 141 | + 122 | f |
| 142 | + 123 | f |
| 143 | + 124 | f |
| 144 | + 125 | f |
| 145 | + 126 | f |
| 146 | + 127 | f |
| 147 | + 128 | f |
| 148 | + 129 | f |
| 149 | + 130 | f |
| 150 | + 131 | f |
| 151 | + 132 | t |
| 152 | + 133 | t |
| 153 | + 134 | t |
| 154 | + 135 | t |
| 155 | + 136 | t |
| 156 | + 137 | t |
| 157 | + 138 | t |
| 158 | + 139 | t |
| 159 | + 140 | t |
| 160 | + 141 | t |
| 161 | + 142 | t |
| 162 | + 143 | t |
| 163 | + 144 | t |
| 164 | + 145 | t |
| 165 | + 146 | t |
| 166 | + 147 | t |
| 167 | + 148 | t |
| 168 | + 149 | t |
| 169 | + 150 | f |
| 170 | + 151 | f |
| 171 | + 152 | f |
| 172 | + 153 | f |
| 173 | + 154 | f |
| 174 | + 155 | f |
| 175 | + 156 | f |
| 176 | + 157 | f |
| 177 | + 158 | f |
| 178 | + 159 | f |
| 179 | + 160 | f |
| 180 | +(71 rows) |
| 181 | + |
| 182 | +-- test current values also |
| 183 | +select txid_current() >= txid_snapshot_xmin(txid_current_snapshot()); |
| 184 | + ?column? |
| 185 | +---------- |
| 186 | + t |
| 187 | +(1 row) |
| 188 | + |
| 189 | +/* due to lazy xid alloc in 8.3 those are different in 8.2 and 8.3 |
| 190 | +select txid_current() < txid_snapshot_xmax(txid_current_snapshot()); |
| 191 | + |
| 192 | +select txid_visible_in_snapshot(txid_current(), txid_current_snapshot()); |
| 193 | +*/ |
| 194 | +-- test 64bitness |
| 195 | +select txid_snapshot '1000100010001000:1000100010001100:1000100010001012,1000100010001013'; |
| 196 | + txid_snapshot |
| 197 | +--------------------------------------------------------------------- |
| 198 | + 1000100010001000:1000100010001100:1000100010001012,1000100010001013 |
| 199 | +(1 row) |
| 200 | + |
| 201 | +select txid_visible_in_snapshot('1000100010001012', '1000100010001000:1000100010001100:1000100010001012,1000100010001013'); |
| 202 | + txid_visible_in_snapshot |
| 203 | +-------------------------- |
| 204 | + f |
| 205 | +(1 row) |
| 206 | + |
| 207 | +select txid_visible_in_snapshot('1000100010001015', '1000100010001000:1000100010001100:1000100010001012,1000100010001013'); |
| 208 | + txid_visible_in_snapshot |
| 209 | +-------------------------- |
| 210 | + t |
| 211 | +(1 row) |
| 212 | + |
0 commit comments