Debian Codegraph @

mysql-test/suite/storage_engine/insert_high_prio.test

raw
1 #
2 # INSERT HIGH_PRIOIRITY
3 #
4 --source have_engine.inc
5
6 --source include/count_sessions.inc
7
8 --disable_warnings
9 DROP TABLE IF EXISTS t1;
10 --enable_warnings
11
12 # We will be changing the GLOBAL value of low_priority_updates
13 # due to bug#64892
14 # (Session-level low_priority_updates does not work for INSERT)
15 SET @low_prio_updates = @@global.low_priority_updates;
16
17 # Concurrent insert might interfere
18 # with HIGH|LOW_PRIORITY logic
19 SET @concur_insert = @@global.concurrent_insert;
20 SET GLOBAL concurrent_insert = NEVER;
21
22 # We will have 3 connections:
23 # con1 will start SELECT which should give us enough time;
24 # con0 will run INSERT
25 # con2 will then start another SELECT.
26 # With standard INSERT and low_priority_updates=1
27 # we should see only old rows in both resultsets,
28 # while with INSERT HIGH_PRIORITY we should see new rows in con2 resultset.
29
30 --connect (con0,localhost,root,,)
31 SET lock_wait_timeout = 4;
32 --connect (con1,localhost,root,,)
33 SET lock_wait_timeout = 4;
34 --connect (con2,localhost,root,,)
35 SET lock_wait_timeout = 4;
36
37
38 --source create_table.inc
39 INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
40
41 # Normal INSERT with low_priority_updates=1
42 # should work like INSERT LOW_PRIORITY
43
44 SET GLOBAL LOW_PRIORITY_UPDATES = 1;
45
46 --connection con1
47 --send
48 SELECT SLEEP(1) FROM t1;
49
50 --connection con0
51 let $show_statement = SHOW PROCESSLIST;
52 let $field = State;
53 let $condition = = 'User sleep';
54 let $wait_timeout = 2;
55 --source include/wait_show_condition.inc
56 --send
57 INSERT INTO t1 (a,b) VALUES (3,'z');
58
59 --connection con2
60 let $condition = = 'Waiting for table level lock';
61 let $wait_timeout = 2;
62 --source include/wait_show_condition.inc
63 if (!$found)
64 {
65 --let $mysql_errname = timeout in wait_show_condition.inc
66 --let $functionality = @@low_priority_updates or INSERT or table locking
67 --source unexpected_result.inc
68 }
69 if ($found)
70 {
71 --echo # Should return only 2 rows
72 SELECT SLEEP(1) FROM t1;
73 }
74
75 --connection con1
76 --reap
77
78 --connection con0
79 --reap
80 --sorted_result
81 SELECT a,b FROM t1;
82
83 DROP TABLE t1;
84
85 --source create_table.inc
86 INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
87
88 # INSERT HIGH_PRIORITY should override low_priority_updates=1
89
90 --connection con1
91 --send
92 SELECT SLEEP(1) FROM t1;
93
94 --connection con0
95 let $condition = = 'User sleep';
96 let $wait_timeout = 2;
97 --source include/wait_show_condition.inc
98 --send
99 INSERT HIGH_PRIORITY INTO t1 (a,b) VALUES (3,'z');
100
101 --connection con2
102 let $condition = = 'Waiting for table level lock';
103 let $wait_timeout = 2;
104 --source include/wait_show_condition.inc
105 if (!$found)
106 {
107 --let $mysql_errname = timeout in wait_show_condition.inc
108 --let $functionality = @@low_priority_updates or INSERT HIGH_PRIORITY or table locking
109 --source unexpected_result.inc
110 }
111 if ($found)
112 {
113 --echo # Should return 3 rows
114 SELECT SLEEP(1) FROM t1;
115 }
116
117 --connection con1
118 --reap
119
120 --connection con0
121 --reap
122 --sorted_result
123 SELECT a,b FROM t1;
124
125 --disconnect con1
126 --disconnect con2
127 --disconnect con0
128 let $wait_timeout = 30;
129
130 --connection default
131
132 SET GLOBAL low_priority_updates = @low_prio_updates;
133 SET GLOBAL concurrent_insert = @concur_insert;
134
135 # Cleanup
136 DROP TABLE t1;
137
138 --source include/wait_until_count_sessions.inc
139
140 --source cleanup_engine.inc
141