
-----------------------------------------------------------------------
- Locking issues case 1.2:
-   Locking rows that do not exist without using all primary key
-   columns in a WHERE clause
-   using READ COMMITTED transaction isolation level
-----------------------------------------------------------------------
DROP TABLE IF EXISTS t0;
CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2));
INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0);
connect  con1,localhost,root,,;
connect  con2,localhost,root,,;
connection con1;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
BEGIN;
SELECT * FROM t0 WHERE id1=1 FOR UPDATE;
id1	id2	value
1	1	0
connection con2;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
BEGIN;
SELECT * FROM t0 WHERE id1=1 AND id2=4 FOR UPDATE;
id1	id2	value
INSERT INTO t0 VALUES (1,5,0);
connection con1;
COMMIT;
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t0;
