| 1 |
# Test for page level predicate locking in gist |
| 2 |
# |
| 3 |
# Test to verify serialization failures and to check reduced false positives |
| 4 |
# |
| 5 |
# To verify serialization failures, queries and permutations are written in such |
| 6 |
# a way that an index scan (from one transaction) and an index insert (from |
| 7 |
# another transaction) will try to access the same part (sub-tree) of the index |
| 8 |
# whereas to check reduced false positives, they will try to access different |
| 9 |
# parts (sub-tree) of the index. |
| 10 |
|
| 11 |
setup |
| 12 |
{ |
| 13 |
create table gist_point_tbl(id int4, p point); |
| 14 |
create index gist_pointidx on gist_point_tbl using gist(p); |
| 15 |
insert into gist_point_tbl (id, p) |
| 16 |
select g, point(g*10, g*10) from generate_series(1, 1000) g; |
| 17 |
} |
| 18 |
|
| 19 |
teardown |
| 20 |
{ |
| 21 |
drop table gist_point_tbl; |
| 22 |
} |
| 23 |
|
| 24 |
session s1 |
| 25 |
setup |
| 26 |
{ |
| 27 |
begin isolation level serializable; |
| 28 |
set enable_seqscan=off; |
| 29 |
set enable_bitmapscan=off; |
| 30 |
set enable_indexonlyscan=on; |
| 31 |
} |
| 32 |
|
| 33 |
step rxy1 { select sum(p[0]) from gist_point_tbl where p << point(2500, 2500); } |
| 34 |
step wx1 { insert into gist_point_tbl (id, p) |
| 35 |
select g, point(g*500, g*500) from generate_series(15, 20) g; } |
| 36 |
step rxy3 { select sum(p[0]) from gist_point_tbl where p >> point(6000,6000); } |
| 37 |
step wx3 { insert into gist_point_tbl (id, p) |
| 38 |
select g, point(g*500, g*500) from generate_series(12, 18) g; } |
| 39 |
step c1 { commit; } |
| 40 |
|
| 41 |
|
| 42 |
session s2 |
| 43 |
setup |
| 44 |
{ |
| 45 |
begin isolation level serializable; |
| 46 |
set enable_seqscan=off; |
| 47 |
set enable_bitmapscan=off; |
| 48 |
set enable_indexonlyscan=on; |
| 49 |
} |
| 50 |
|
| 51 |
step rxy2 { select sum(p[0]) from gist_point_tbl where p >> point(7500,7500); } |
| 52 |
step wy2 { insert into gist_point_tbl (id, p) |
| 53 |
select g, point(g*500, g*500) from generate_series(1, 5) g; } |
| 54 |
step rxy4 { select sum(p[0]) from gist_point_tbl where p << point(1000,1000); } |
| 55 |
step wy4 { insert into gist_point_tbl (id, p) |
| 56 |
select g, point(g*50, g*50) from generate_series(1, 20) g; } |
| 57 |
step c2 { commit; } |
| 58 |
|
| 59 |
# An index scan (from one transaction) and an index insert (from another |
| 60 |
# transaction) try to access the same part of the index but one transaction |
| 61 |
# commits before other transaction begins so no r-w conflict. |
| 62 |
|
| 63 |
permutation rxy1 wx1 c1 rxy2 wy2 c2 |
| 64 |
permutation rxy2 wy2 c2 rxy1 wx1 c1 |
| 65 |
|
| 66 |
# An index scan (from one transaction) and an index insert (from another |
| 67 |
# transaction) try to access different parts of the index and also one |
| 68 |
# transaction commits before other transaction begins, so no r-w conflict. |
| 69 |
|
| 70 |
permutation rxy3 wx3 c1 rxy4 wy4 c2 |
| 71 |
permutation rxy4 wy4 c2 rxy3 wx3 c1 |
| 72 |
|
| 73 |
|
| 74 |
# An index scan (from one transaction) and an index insert (from another |
| 75 |
# transaction) try to access the same part of the index and one transaction |
| 76 |
# begins before other transaction commits so there is a r-w conflict. |
| 77 |
|
| 78 |
permutation rxy1 wx1 rxy2 c1 wy2 c2 |
| 79 |
permutation rxy1 wx1 rxy2 wy2 c1 c2 |
| 80 |
permutation rxy1 wx1 rxy2 wy2 c2 c1 |
| 81 |
permutation rxy1 rxy2 wx1 c1 wy2 c2 |
| 82 |
permutation rxy1 rxy2 wx1 wy2 c1 c2 |
| 83 |
permutation rxy1 rxy2 wx1 wy2 c2 c1 |
| 84 |
permutation rxy1 rxy2 wy2 wx1 c1 c2 |
| 85 |
permutation rxy1 rxy2 wy2 wx1 c2 c1 |
| 86 |
permutation rxy1 rxy2 wy2 c2 wx1 c1 |
| 87 |
permutation rxy2 rxy1 wx1 c1 wy2 c2 |
| 88 |
permutation rxy2 rxy1 wx1 wy2 c1 c2 |
| 89 |
permutation rxy2 rxy1 wx1 wy2 c2 c1 |
| 90 |
permutation rxy2 rxy1 wy2 wx1 c1 c2 |
| 91 |
permutation rxy2 rxy1 wy2 wx1 c2 c1 |
| 92 |
permutation rxy2 rxy1 wy2 c2 wx1 c1 |
| 93 |
permutation rxy2 wy2 rxy1 wx1 c1 c2 |
| 94 |
permutation rxy2 wy2 rxy1 wx1 c2 c1 |
| 95 |
permutation rxy2 wy2 rxy1 c2 wx1 c1 |
| 96 |
|
| 97 |
# An index scan (from one transaction) and an index insert (from another |
| 98 |
# transaction) try to access different parts of the index so no r-w conflict. |
| 99 |
|
| 100 |
permutation rxy3 wx3 rxy4 c1 wy4 c2 |
| 101 |
permutation rxy3 wx3 rxy4 wy4 c1 c2 |
| 102 |
permutation rxy3 wx3 rxy4 wy4 c2 c1 |
| 103 |
permutation rxy3 rxy4 wx3 c1 wy4 c2 |
| 104 |
permutation rxy3 rxy4 wx3 wy4 c1 c2 |
| 105 |
permutation rxy3 rxy4 wx3 wy4 c2 c1 |
| 106 |
permutation rxy3 rxy4 wy4 wx3 c1 c2 |
| 107 |
permutation rxy3 rxy4 wy4 wx3 c2 c1 |
| 108 |
permutation rxy3 rxy4 wy4 c2 wx3 c1 |
| 109 |
permutation rxy4 rxy3 wx3 c1 wy4 c2 |
| 110 |
permutation rxy4 rxy3 wx3 wy4 c1 c2 |
| 111 |
permutation rxy4 rxy3 wx3 wy4 c2 c1 |
| 112 |
permutation rxy4 rxy3 wy4 wx3 c1 c2 |
| 113 |
permutation rxy4 rxy3 wy4 wx3 c2 c1 |
| 114 |
permutation rxy4 rxy3 wy4 c2 wx3 c1 |
| 115 |
permutation rxy4 wy4 rxy3 wx3 c1 c2 |
| 116 |
permutation rxy4 wy4 rxy3 wx3 c2 c1 |
| 117 |
permutation rxy4 wy4 rxy3 c2 wx3 c1 |