| 1 |
# Scenario: |
| 2 |
# T1=({R(B)}) |
| 3 |
# T2=({R(B), W(B), C}, HIGH_PRIORITY). |
| 4 |
# |
| 5 |
# Outcome: T1 must abort, T2 must commit. |
| 6 |
|
| 7 |
--source include/count_sessions.inc |
| 8 |
|
| 9 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 10 |
INSERT INTO t1 VALUES (0); |
| 11 |
|
| 12 |
--connect(con1,localhost,root,,test) |
| 13 |
--connect(con2,localhost,root,,test) |
| 14 |
|
| 15 |
--echo |
| 16 |
--echo # On connection 1 |
| 17 |
--connection con1 |
| 18 |
START TRANSACTION; |
| 19 |
SELECT * FROM t1 WHERE c1=0 FOR UPDATE; |
| 20 |
|
| 21 |
--echo |
| 22 |
--echo # On connection 2 |
| 23 |
--connection con2 |
| 24 |
--source include/start_transaction_high_prio.inc |
| 25 |
UPDATE t1 SET c1=2 WHERE c1=0; |
| 26 |
COMMIT; |
| 27 |
--disconnect con2 |
| 28 |
|
| 29 |
--echo |
| 30 |
--echo # On connection 1 |
| 31 |
--connection con1 |
| 32 |
# Note: DEADLOCK implies a full ROLLBACK |
| 33 |
--error ER_LOCK_DEADLOCK |
| 34 |
UPDATE t1 SET c1=1 WHERE c1=0; |
| 35 |
--disconnect con1 |
| 36 |
|
| 37 |
--connection default |
| 38 |
--let $assert_text= 'There is a 2 in t1' |
| 39 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1 |
| 40 |
--source include/assert.inc |
| 41 |
|
| 42 |
--let $assert_text= 'There is no 1 in t1' |
| 43 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 0 |
| 44 |
--source include/assert.inc |
| 45 |
|
| 46 |
--let $assert_text= 'There is no 0 in t1' |
| 47 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 0, count, 1] = 0 |
| 48 |
--source include/assert.inc |
| 49 |
|
| 50 |
DROP TABLE t1; |
| 51 |
|
| 52 |
--source include/wait_until_count_sessions.inc |