Skip to content

Commit 160984c

Browse files
Isolation test for DROP INDEX CONCURRENTLY
for recent concurrent changes. Abhijit Menon-Sen
1 parent 2f0e480 commit 160984c

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Parsed test spec with 3 sessions
2+
3+
starting permutation: noseq prepi preps begin explaini explains select2 drop insert2 end2 selecti selects end
4+
step noseq: SET enable_seqscan = false;
5+
step prepi: PREPARE getrow_idx AS SELECT * FROM test_dc WHERE data=34 ORDER BY id,data;
6+
step preps: PREPARE getrow_seq AS SELECT * FROM test_dc WHERE data::text=34::text ORDER BY id,data;
7+
step begin: BEGIN;
8+
step explaini: EXPLAIN (COSTS OFF) EXECUTE getrow_idx;
9+
QUERY PLAN
10+
11+
Sort
12+
Sort Key: id
13+
-> Index Scan using test_dc_data on test_dc
14+
Index Cond: (data = 34)
15+
step explains: EXPLAIN (COSTS OFF) EXECUTE getrow_seq;
16+
QUERY PLAN
17+
18+
Sort
19+
Sort Key: id, data
20+
-> Seq Scan on test_dc
21+
Filter: ((data)::text = '34'::text)
22+
step select2: SELECT * FROM test_dc WHERE data=34 ORDER BY id,data;
23+
id data
24+
25+
34 34
26+
step drop: DROP INDEX CONCURRENTLY test_dc_data; <waiting ...>
27+
step insert2: INSERT INTO test_dc(data) SELECT * FROM generate_series(1, 100);
28+
step end2: COMMIT;
29+
step selecti: EXECUTE getrow_idx;
30+
id data
31+
32+
34 34
33+
134 34
34+
step selects: EXECUTE getrow_seq;
35+
id data
36+
37+
34 34
38+
134 34
39+
step end: COMMIT;
40+
step drop: <... completed>

src/test/isolation/isolation_schedule

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test: fk-contention
1414
test: fk-deadlock
1515
test: fk-deadlock2
1616
test: eval-plan-qual
17+
test: drop-index-concurrently-1
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# DROP INDEX CONCURRENTLY
2+
#
3+
# This test shows that the concurrent write behaviour works correctly
4+
# with the expected output being 2 rows.
5+
#
6+
setup
7+
{
8+
CREATE TABLE test_dc(id serial primary key, data int);
9+
INSERT INTO test_dc(data) SELECT * FROM generate_series(1, 100);
10+
CREATE INDEX test_dc_data ON test_dc(data);
11+
}
12+
13+
teardown
14+
{
15+
DROP TABLE test_dc;
16+
}
17+
18+
session "s1"
19+
step "noseq" { SET enable_seqscan = false; }
20+
step "prepi" { PREPARE getrow_idx AS SELECT * FROM test_dc WHERE data=34 ORDER BY id,data; }
21+
step "preps" { PREPARE getrow_seq AS SELECT * FROM test_dc WHERE data::text=34::text ORDER BY id,data; }
22+
step "begin" { BEGIN; }
23+
step "explaini" { EXPLAIN (COSTS OFF) EXECUTE getrow_idx; }
24+
step "explains" { EXPLAIN (COSTS OFF) EXECUTE getrow_seq; }
25+
step "selecti" { EXECUTE getrow_idx; }
26+
step "selects" { EXECUTE getrow_seq; }
27+
step "end" { COMMIT; }
28+
29+
session "s2"
30+
setup { BEGIN; }
31+
step "select2" { SELECT * FROM test_dc WHERE data=34 ORDER BY id,data; }
32+
step "insert2" { INSERT INTO test_dc(data) SELECT * FROM generate_series(1, 100); }
33+
step "end2" { COMMIT; }
34+
35+
session "s3"
36+
step "drop" { DROP INDEX CONCURRENTLY test_dc_data; }
37+
38+
permutation "noseq" "prepi" "preps" "begin" "explaini" "explains" "select2" "drop" "insert2" "end2" "selecti" "selects" "end"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy