| 1 |
# Test predicate locks on HOT updated tuples. |
| 2 |
# |
| 3 |
# This test has two serializable transactions. Both select two rows |
| 4 |
# from the table, and then update one of them. |
| 5 |
# If these were serialized (run one at a time), the transaction that |
| 6 |
# runs later would see one of the rows to be updated. |
| 7 |
# |
| 8 |
# Any overlap between the transactions must cause a serialization failure. |
| 9 |
# We used to have a bug in predicate locking HOT updated tuples, which |
| 10 |
# caused the conflict to be missed, if the row was HOT updated. |
| 11 |
|
| 12 |
setup |
| 13 |
{ |
| 14 |
CREATE TABLE test (i int PRIMARY KEY, t text); |
| 15 |
INSERT INTO test VALUES (5, 'apple'), (7, 'pear'), (11, 'banana'); |
| 16 |
-- HOT-update 'pear' row. |
| 17 |
UPDATE test SET t = 'pear_hot_updated' WHERE i = 7; |
| 18 |
} |
| 19 |
|
| 20 |
teardown |
| 21 |
{ |
| 22 |
DROP TABLE test; |
| 23 |
} |
| 24 |
|
| 25 |
session s1 |
| 26 |
step b1 { BEGIN ISOLATION LEVEL SERIALIZABLE; } |
| 27 |
step r1 { SELECT * FROM test WHERE i IN (5, 7) } |
| 28 |
step w1 { UPDATE test SET t = 'pear_xact1' WHERE i = 7 } |
| 29 |
step c1 { COMMIT; } |
| 30 |
|
| 31 |
session s2 |
| 32 |
step b2 { BEGIN ISOLATION LEVEL SERIALIZABLE; } |
| 33 |
step r2 { SELECT * FROM test WHERE i IN (5, 7) } |
| 34 |
step w2 { UPDATE test SET t = 'apple_xact2' WHERE i = 5 } |
| 35 |
step c2 { COMMIT; } |
| 36 |
|
| 37 |
permutation b1 b2 r1 r2 w1 w2 c1 c2 |