summaryrefslogtreecommitdiff
path: root/mysql-test/suite/storage_engine/delete_low_prio.test
blob: da106791284459183d0f4bf977e00754b5b37602 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# 
# DELETE LOW_PRIORITY
#
--source have_engine.inc

--source include/count_sessions.inc

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

--let $create_definiiton = a $int_col, b $char_col
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');

# We will have 3 connections: 
#   con1 will start SELECT which should give us enough time;
#   default will run DELETE 
#   con2 will then start another SELECT.
# With LOW_PRIORITY_UPDATES = 0,
# with standard DELETE we should see all rows in con1 resultset,
# but no rows in con2 resultset.
# With DELETE LOW_PRIORITY we should see all rows in both resultsets.
# Then we will set LOW_PRIORITY_UPDATES to 1.
# Then with standard DELETE we should see all rows in both resultsets.

SET LOW_PRIORITY_UPDATES = 0;
SET lock_wait_timeout = 4;

# Normal DELETE with low_priority_updates=0

--connect (con1,localhost,root,,)
SET lock_wait_timeout = 2;
--send
SELECT SLEEP(1) FROM t1;

--connection default
let $show_statement = SHOW PROCESSLIST;
let $field = State;
let $condition = = 'User sleep';
# We don't need to wait long, 
# if the feature works, threads
# should show up in the processlist right away
let $wait_timeout = 2;
--source include/wait_show_condition.inc

--send
DELETE FROM t1;

--connect (con2,localhost,root,,)
SET lock_wait_timeout = 3;

let $field = Info;
let $condition =  = 'DELETE FROM t1';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
if (!$found)
{
  --let $mysql_errname = timeout in wait_show_condition.inc
  --let $functionality = DELETE or table locking
  --source unexpected_result.inc
}
if ($found)
{
  SELECT SLEEP(1) FROM t1;
}

--connection con1
--reap

--connection default
--reap
--sorted_result
SELECT a,b FROM t1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');


# DELETE LOW_PRIORITY

--connection con1
--send
SELECT SLEEP(1) FROM t1;

--connection default
let $field = State;
let $condition = = 'User sleep';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
--send
DELETE LOW_PRIORITY FROM t1;

--connection con2
let $field = Info;
let $condition =  = 'DELETE LOW_PRIORITY FROM t1';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
if (!$found)
{
  --let $mysql_errname = timeout in wait_show_condition.inc
  --let $functionality = DELETE LOW_PRIORITY or table locking
  --source unexpected_result.inc
}
if ($found)
{
  SELECT SLEEP(1) FROM t1;
}

--connection con1
--reap

--connection default
--reap
--sorted_result
SELECT a,b FROM t1;
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');

SET LOW_PRIORITY_UPDATES = 1;

# Normal DELETE with low_priority_updates=1

--connection con1
--send
SELECT SLEEP(1) FROM t1;

--connection default
let $field = State;
let $condition = = 'User sleep';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
--send
DELETE FROM t1;

--connection con2
let $field = Info;
let $condition =  = 'DELETE FROM t1';
let $wait_timeout = 2;
--source include/wait_show_condition.inc
if ($found)
{
  SELECT SLEEP(1) FROM t1;
}

--connection con1
--reap

--connection default
--reap
--sorted_result
SELECT a,b FROM t1;

--disconnect con1
--disconnect con2

# Cleanup
DROP TABLE t1;

--source include/wait_until_count_sessions.inc

--source cleanup_engine.inc