| 1 |
# Partial Index test |
| 2 |
# |
| 3 |
# Make sure that an update which moves a row out of a partial index |
| 4 |
# is handled correctly. In early versions, an attempt at optimization |
| 5 |
# broke this behavior, allowing anomalies. |
| 6 |
# |
| 7 |
# Any overlap between the transactions must cause a serialization failure. |
| 8 |
|
| 9 |
setup |
| 10 |
{ |
| 11 |
create table test_t (id integer, val1 text, val2 integer); |
| 12 |
create index test_idx on test_t(id) where val2 = 1; |
| 13 |
insert into test_t (select generate_series(0, 10000), 'a', 2); |
| 14 |
insert into test_t (select generate_series(0, 10), 'a', 1); |
| 15 |
} |
| 16 |
|
| 17 |
teardown |
| 18 |
{ |
| 19 |
DROP TABLE test_t; |
| 20 |
} |
| 21 |
|
| 22 |
session s1 |
| 23 |
setup { BEGIN ISOLATION LEVEL SERIALIZABLE; } |
| 24 |
step rxy1 { select * from test_t where val2 = 1; } |
| 25 |
step wx1 { update test_t set val2 = 2 where val2 = 1 and id = 10; } |
| 26 |
step c1 { COMMIT; } |
| 27 |
|
| 28 |
session s2 |
| 29 |
setup { BEGIN ISOLATION LEVEL SERIALIZABLE; } |
| 30 |
step wy2 { update test_t set val2 = 2 where val2 = 1 and id = 9; } |
| 31 |
step rxy2 { select * from test_t where val2 = 1; } |
| 32 |
step c2 { COMMIT; } |