|
25 | 25 | 'lock_timeout = ' . (1000 * $PostgreSQL::Test::Utils::timeout_default));
|
26 | 26 | $node->start;
|
27 | 27 | $node->safe_psql('postgres', q(CREATE EXTENSION amcheck));
|
28 |
| -$node->safe_psql('postgres', q(CREATE TABLE tbl(i int))); |
| 28 | +$node->safe_psql('postgres', q(CREATE TABLE tbl(i int, j jsonb))); |
29 | 29 |
|
30 | 30 |
|
31 | 31 | #
|
|
41 | 41 | $main_h->query_safe(
|
42 | 42 | q(
|
43 | 43 | BEGIN;
|
44 |
| -INSERT INTO tbl VALUES(0); |
| 44 | +INSERT INTO tbl VALUES(0, '[[14,2,3]]'); |
45 | 45 | ));
|
46 | 46 |
|
47 | 47 | my $cic_h = $node->background_psql('postgres');
|
|
50 | 50 | qr/start/, q(
|
51 | 51 | \echo start
|
52 | 52 | CREATE INDEX CONCURRENTLY idx ON tbl(i);
|
| 53 | +CREATE INDEX CONCURRENTLY ginidx ON tbl USING gin(j); |
53 | 54 | ));
|
54 | 55 |
|
55 | 56 | $main_h->query_safe(
|
|
60 | 61 | $main_h->query_safe(
|
61 | 62 | q(
|
62 | 63 | BEGIN;
|
63 |
| -INSERT INTO tbl VALUES(0); |
| 64 | +INSERT INTO tbl VALUES(0, '[[14,2,3]]'); |
64 | 65 | ));
|
65 | 66 |
|
66 | 67 | $node->safe_psql('postgres', q(COMMIT PREPARED 'a';));
|
|
69 | 70 | q(
|
70 | 71 | PREPARE TRANSACTION 'b';
|
71 | 72 | BEGIN;
|
72 |
| -INSERT INTO tbl VALUES(0); |
| 73 | +INSERT INTO tbl VALUES(0, '"mary had a little lamb"'); |
73 | 74 | ));
|
74 | 75 |
|
75 | 76 | $node->safe_psql('postgres', q(COMMIT PREPARED 'b';));
|
|
86 | 87 | $result = $node->psql('postgres', q(SELECT bt_index_check('idx',true)));
|
87 | 88 | is($result, '0', 'bt_index_check after overlapping 2PC');
|
88 | 89 |
|
| 90 | +$result = $node->psql('postgres', q(SELECT gin_index_check('ginidx'))); |
| 91 | +is($result, '0', 'gin_index_check after overlapping 2PC'); |
| 92 | + |
89 | 93 |
|
90 | 94 | #
|
91 | 95 | # Server restart shall not change whether prepared xact blocks CIC
|
|
94 | 98 | $node->safe_psql(
|
95 | 99 | 'postgres', q(
|
96 | 100 | BEGIN;
|
97 |
| -INSERT INTO tbl VALUES(0); |
| 101 | +INSERT INTO tbl VALUES(0, '{"a":[["b",{"x":1}],["b",{"x":2}]],"c":3}'); |
98 | 102 | PREPARE TRANSACTION 'spans_restart';
|
99 | 103 | BEGIN;
|
100 | 104 | CREATE TABLE unused ();
|
|
108 | 112 | \echo start
|
109 | 113 | DROP INDEX CONCURRENTLY idx;
|
110 | 114 | CREATE INDEX CONCURRENTLY idx ON tbl(i);
|
| 115 | +DROP INDEX CONCURRENTLY ginidx; |
| 116 | +CREATE INDEX CONCURRENTLY ginidx ON tbl USING gin(j); |
111 | 117 | ));
|
112 | 118 |
|
113 | 119 | $node->safe_psql('postgres', "COMMIT PREPARED 'spans_restart'");
|
114 | 120 | $reindex_h->quit;
|
115 | 121 | $result = $node->psql('postgres', q(SELECT bt_index_check('idx',true)));
|
116 | 122 | is($result, '0', 'bt_index_check after 2PC and restart');
|
| 123 | +$result = $node->psql('postgres', q(SELECT gin_index_check('ginidx'))); |
| 124 | +is($result, '0', 'gin_index_check after 2PC and restart'); |
117 | 125 |
|
118 | 126 |
|
119 | 127 | #
|
|
136 | 144 | {
|
137 | 145 | '003_pgbench_concurrent_2pc' => q(
|
138 | 146 | BEGIN;
|
139 |
| - INSERT INTO tbl VALUES(0); |
| 147 | + INSERT INTO tbl VALUES(0,'null'); |
140 | 148 | PREPARE TRANSACTION 'c:client_id';
|
141 | 149 | COMMIT PREPARED 'c:client_id';
|
142 | 150 | ),
|
143 | 151 | '003_pgbench_concurrent_2pc_savepoint' => q(
|
144 | 152 | BEGIN;
|
145 | 153 | SAVEPOINT s1;
|
146 |
| - INSERT INTO tbl VALUES(0); |
| 154 | + INSERT INTO tbl VALUES(0,'[false, "jnvaba", -76, 7, {"_": [1]}, 9]'); |
147 | 155 | PREPARE TRANSACTION 'c:client_id';
|
148 | 156 | COMMIT PREPARED 'c:client_id';
|
149 | 157 | ),
|
|
163 | 171 | SELECT bt_index_check('idx',true);
|
164 | 172 | SELECT pg_advisory_unlock(42);
|
165 | 173 | \endif
|
| 174 | + ), |
| 175 | + '005_pgbench_concurrent_cic' => q( |
| 176 | + SELECT pg_try_advisory_lock(42)::integer AS gotginlock \gset |
| 177 | + \if :gotginlock |
| 178 | + DROP INDEX CONCURRENTLY ginidx; |
| 179 | + CREATE INDEX CONCURRENTLY ginidx ON tbl USING gin(j); |
| 180 | + SELECT gin_index_check('ginidx'); |
| 181 | + SELECT pg_advisory_unlock(42); |
| 182 | + \endif |
| 183 | + ), |
| 184 | + '006_pgbench_concurrent_ric' => q( |
| 185 | + SELECT pg_try_advisory_lock(42)::integer AS gotginlock \gset |
| 186 | + \if :gotginlock |
| 187 | + REINDEX INDEX CONCURRENTLY ginidx; |
| 188 | + SELECT gin_index_check('ginidx'); |
| 189 | + SELECT pg_advisory_unlock(42); |
| 190 | + \endif |
166 | 191 | )
|
| 192 | + |
167 | 193 | });
|
168 | 194 |
|
169 | 195 | $node->stop;
|
|
0 commit comments