Debian Codegraph @

mysql-test/suite/storage_engine/trx/select_lock_in_share_mode.test

raw
1 #
2 # SELECT .. LOCK IN SHARE MODE
3 #
4 # If the engine has its own lock timeouts,
5 # it makes sense to set them to minimum to decrease
6 # the duration of the test.
7
8 --source ../have_engine.inc
9 --source support_transactions.inc
10
11 --disable_warnings
12 DROP TABLE IF EXISTS t1;
13 --enable_warnings
14
15 --source include/count_sessions.inc
16
17 --source ../create_table.inc
18 INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a');
19
20 --connect (con1,localhost,root,,)
21 BEGIN;
22 --sorted_result
23 SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
24 if ($mysql_errname)
25 {
26 --let $functionality = LOCK IN SHARE MODE
27 --source ../unexpected_result.inc
28 }
29
30 --connection default
31 SET lock_wait_timeout = 1;
32
33 # Should still be able to select
34
35 --sorted_result
36 SELECT a,b FROM t1 WHERE b='a';
37 if ($mysql_errname)
38 {
39 --let $functionality = LOCK IN SHARE MODE
40 --source ../unexpected_result.inc
41 }
42 --sorted_result
43 SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
44 if ($mysql_errname)
45 {
46 --let $functionality = LOCK IN SHARE MODE
47 --source ../unexpected_result.inc
48 }
49
50 --let $error_codes = ER_LOCK_WAIT_TIMEOUT
51 UPDATE t1 SET b='c' WHERE b='a';
52 --source ../check_errors.inc
53 if ($mysql_errname != ER_LOCK_WAIT_TIMEOUT)
54 {
55 --let $functionality = LOCK IN SHARE MODE or UPDATE
56 --source ../unexpected_result.inc
57 }
58
59 --connection con1
60 COMMIT;
61 --sorted_result
62 SELECT a,b FROM t1;
63
64 --disconnect con1
65 --connection default
66 # Now it can be updated all right
67 UPDATE t1 SET b='c' WHERE b='a';
68 if ($mysql_errname)
69 {
70 --let $functionality = UPDATE
71 --source ../unexpected_result.inc
72 }
73 --sorted_result
74 SELECT a,b FROM t1;
75
76 DROP TABLE t1;
77
78 --source include/wait_until_count_sessions.inc
79 --source ../cleanup_engine.inc
80