Debian Codegraph @

src/test/isolation/specs/drop-index-concurrently-1.spec

raw
1 # DROP INDEX CONCURRENTLY
2 #
3 # This test shows that the concurrent write behaviour works correctly
4 # with the expected output being 2 rows at the READ COMMITTED and READ
5 # UNCOMMITTED transaction isolation levels, and 1 row at the other
6 # transaction isolation levels. We ensure this is the case by checking
7 # the returned rows in an index scan plan and a seq scan plan.
8 #
9 setup
10 {
11 CREATE TABLE test_dc(id serial primary key, data int);
12 INSERT INTO test_dc(data) SELECT * FROM generate_series(1, 100);
13 CREATE INDEX test_dc_data ON test_dc(data);
14 }
15
16 teardown
17 {
18 DROP TABLE test_dc;
19 }
20
21 session s1
22 step chkiso { SELECT (setting in ('read committed','read uncommitted')) AS is_read_committed FROM pg_settings WHERE name = 'default_transaction_isolation'; }
23 step prepi { PREPARE getrow_idxscan AS SELECT * FROM test_dc WHERE data = 34 ORDER BY id,data; }
24 step preps { PREPARE getrow_seqscan AS SELECT * FROM test_dc WHERE data = 34 ORDER BY id,data; }
25 step begin { BEGIN; }
26 step disableseq { SET enable_seqscan = false; }
27 step explaini { EXPLAIN (COSTS OFF) EXECUTE getrow_idxscan; }
28 step enableseq { SET enable_seqscan = true; }
29 step explains { EXPLAIN (COSTS OFF) EXECUTE getrow_seqscan; }
30 step selecti { EXECUTE getrow_idxscan; }
31 step selects { EXECUTE getrow_seqscan; }
32 step end { COMMIT; }
33
34 session s2
35 setup { BEGIN; }
36 step select2 { SELECT * FROM test_dc WHERE data = 34 ORDER BY id,data; }
37 step insert2 { INSERT INTO test_dc(data) SELECT * FROM generate_series(1, 100); }
38 step end2 { COMMIT; }
39
40 session s3
41 step drop { DROP INDEX CONCURRENTLY test_dc_data; }
42
43 permutation chkiso prepi preps begin disableseq explaini enableseq explains select2 drop insert2 end2 selecti selects end