| 1 |
# INSERT...ON CONFLICT DO NOTHING test |
| 2 |
# |
| 3 |
# This test tries to expose problems with the interaction between concurrent |
| 4 |
# sessions during INSERT...ON CONFLICT DO NOTHING. |
| 5 |
# |
| 6 |
# The convention here is that session 1 always ends up inserting, and session 2 |
| 7 |
# always ends up doing nothing. |
| 8 |
|
| 9 |
setup |
| 10 |
{ |
| 11 |
CREATE TABLE ints (key int primary key, val text); |
| 12 |
} |
| 13 |
|
| 14 |
teardown |
| 15 |
{ |
| 16 |
DROP TABLE ints; |
| 17 |
} |
| 18 |
|
| 19 |
session s1 |
| 20 |
setup |
| 21 |
{ |
| 22 |
BEGIN ISOLATION LEVEL READ COMMITTED; |
| 23 |
} |
| 24 |
step donothing1 { INSERT INTO ints(key, val) VALUES(1, 'donothing1') ON CONFLICT DO NOTHING; } |
| 25 |
step c1 { COMMIT; } |
| 26 |
step a1 { ABORT; } |
| 27 |
|
| 28 |
session s2 |
| 29 |
setup |
| 30 |
{ |
| 31 |
BEGIN ISOLATION LEVEL READ COMMITTED; |
| 32 |
} |
| 33 |
step donothing2 { INSERT INTO ints(key, val) VALUES(1, 'donothing2') ON CONFLICT DO NOTHING; } |
| 34 |
step select2 { SELECT * FROM ints; } |
| 35 |
step c2 { COMMIT; } |
| 36 |
|
| 37 |
# Regular case where one session block-waits on another to determine if it |
| 38 |
# should proceed with an insert or do nothing. |
| 39 |
permutation donothing1 donothing2 c1 select2 c2 |
| 40 |
permutation donothing1 donothing2 a1 select2 c2 |