1--source include/have_rocksdb.inc
2
3#
4# SELECT .. FOR UPDATE
5#
6
7--enable_connect_log
8
9--source include/count_sessions.inc
10
11# MyRocks does not support gap locks in REPEATABLE-READ mode, this test
12# does not require RR ISO to complete, so lets alter the ISO to RC
13set session transaction_isolation='READ-COMMITTED';
14
15CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB;
16INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a');
17
18--connect (con1,localhost,root,,)
19# MyRocks does not support gap locks in REPEATABLE-READ mode, this test
20# does not require RR ISO to complete, so lets temporarily alter the ISO to RC
21set session transaction_isolation='READ-COMMITTED';
22
23BEGIN;
24--sorted_result
25SELECT a,b FROM t1 WHERE b='a' FOR UPDATE;
26
27--connection default
28SET lock_wait_timeout = 1;
29
30# Should still be able to select
31
32--sorted_result
33SELECT a,b FROM t1 WHERE b='a';
34
35# ... but not with LOCK IN SHARE MODE
36
37--sorted_result
38--error ER_LOCK_WAIT_TIMEOUT
39SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
40
41--error ER_LOCK_WAIT_TIMEOUT
42UPDATE t1 SET b='c' WHERE b='a';
43
44--connection con1
45COMMIT;
46--sorted_result
47SELECT a,b FROM t1;
48
49--disconnect con1
50--connection default
51# Now it can be updated all right
52UPDATE t1 SET b='c' WHERE b='a';
53--sorted_result
54SELECT a,b FROM t1;
55
56DROP TABLE t1;
57
58--source include/wait_until_count_sessions.inc
59