Debian Codegraph @

src/test/isolation/specs/partition-concurrent-attach.spec

raw
1 # Verify that default partition constraint is enforced correctly
2 # in light of partitions being added concurrently to its parent
3 setup {
4 drop table if exists tpart;
5 create table tpart(i int, j text) partition by range(i);
6 create table tpart_1(like tpart);
7 create table tpart_2(like tpart);
8 create table tpart_default (a int, j text, i int) partition by list (j);
9 create table tpart_default_default (a int, i int, b int, j text);
10 alter table tpart_default_default drop b;
11 alter table tpart_default attach partition tpart_default_default default;
12 alter table tpart_default drop a;
13 alter table tpart attach partition tpart_default default;
14 alter table tpart attach partition tpart_1 for values from(0) to (100);
15 insert into tpart_2 values (110,'xxx'), (120, 'yyy'), (150, 'zzz');
16 }
17
18 session s1
19 step s1b { begin; }
20 step s1a { alter table tpart attach partition tpart_2 for values from (100) to (200); }
21 step s1c { commit; }
22
23 session s2
24 step s2b { begin; }
25 step s2i { insert into tpart values (110,'xxx'), (120, 'yyy'), (150, 'zzz'); }
26 step s2i2 { insert into tpart_default (i, j) values (110, 'xxx'), (120, 'yyy'), (150, 'zzz'); }
27 step s2c { commit; }
28 step s2s { select tableoid::regclass, * from tpart; }
29
30 teardown { drop table tpart; }
31
32 # insert into tpart by s2 which routes to tpart_default due to not seeing
33 # concurrently added tpart_2 should fail, because the partition constraint
34 # of tpart_default would have changed due to tpart_2 having been added
35 permutation s1b s1a s2b s2i s1c s2c s2s
36
37 # similar to above, but now insert into sub-partitioned tpart_default
38 permutation s1b s1a s2b s2i2 s1c s2c s2s
39
40 # reverse: now the insert into tpart_default by s2 occurs first followed by
41 # attach in s1, which should fail when it scans the leaf default partition
42 # find the violating rows
43 permutation s1b s2b s2i s1a s2c s1c s2s