summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/innodb/r/partition_locking.result
blob: b5e96f965b36b5ec18a648ef7de0ad80c84cf885 (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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
set @start_read_only= @@global.read_only;
set @start_autocommit= @@global.autocommit;
set default_storage_engine= innodb;
set @@global.autocommit= 0;
CREATE USER test@localhost;
grant CREATE, SELECT, UPDATE, INSERT on *.* to test@localhost;
CREATE USER test2@localhost;
grant CREATE, SELECT, UPDATE on *.* to test2@localhost;
CREATE TABLE t1 (
a char(2) NOT NULL,
b char(2) NOT NULL,
c int(10) unsigned NOT NULL,
d varchar(255) DEFAULT NULL,
e varchar(1000) DEFAULT NULL,
PRIMARY KEY (a, b, c),
KEY (a),
KEY (a, b)
) charset latin1 PARTITION BY KEY (a) PARTITIONS 20;
INSERT INTO t1 (a, b, c, d, e) VALUES
('07', '03', 343, '1', '07_03_343'),
('01', '04', 343, '2', '01_04_343'),
('01', '06', 343, '3', '01_06_343'),
('01', '07', 343, '4', '01_07_343'),
('01', '08', 343, '5', '01_08_343'),
('01', '09', 343, '6', '01_09_343'),
('03', '03', 343, '7', '03_03_343'),
('03', '06', 343, '8', '03_06_343'),
('03', '07', 343, '9', '03_07_343'),
('04', '03', 343, '10', '04_03_343'),
('04', '06', 343, '11', '04_06_343'),
('05', '03', 343, '12', '05_03_343'),
('11', '03', 343, '13', '11_03_343'),
('11', '04', 343, '14', '11_04_343')
;
CREATE TABLE t2 (a int, name VARCHAR(50), purchased DATE)
PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (3),
PARTITION p1 VALUES LESS THAN (7),
PARTITION p2 VALUES LESS THAN (9),
PARTITION p3 VALUES LESS THAN (11));
INSERT INTO t2 VALUES
(1, 'desk organiser', '2003-10-15'),
(2, 'CD player', '1993-11-05'),
(3, 'TV set', '1996-03-10'),
(4, 'bookcase', '1982-01-10'),
(5, 'exercise bike', '2004-05-09'),
(6, 'sofa', '1987-06-05'),
(7, 'popcorn maker', '2001-11-22'),
(8, 'acquarium', '1992-08-04'),
(9, 'study desk', '1984-09-16'),
(10, 'lava lamp', '1998-12-25');
CREATE TABLE t3 SELECT * FROM t1;
ALTER TABLE t3 ADD PRIMARY KEY (d);
ALTER TABLE t3 ADD KEY (a);
ALTER TABLE t3 ADD KEY (a, b);
ANALYZE TABLE t3;
Table	Op	Msg_type	Msg_text
test.t3	analyze	status	Engine-independent statistics collected
test.t3	analyze	status	OK
########################################################################
connect  con1,localhost,test,,test;
BEGIN;
SELECT d,a,b,c FROM t1 partition (p0);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p1);
d	a	b	c
7	03	03	343
8	03	06	343
9	03	07	343
SELECT d,a,b,c FROM t1 partition (p2);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p3);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p4);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p5);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p6);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p7);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p8);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p9);
d	a	b	c
2	01	04	343
3	01	06	343
4	01	07	343
5	01	08	343
6	01	09	343
10	04	03	343
11	04	06	343
12	05	03	343
SELECT d,a,b,c FROM t1 partition (p10);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p11);
d	a	b	c
13	11	03	343
14	11	04	343
SELECT d,a,b,c FROM t1 partition (p12);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p13);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p14);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p15);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p16);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p17);
d	a	b	c
1	07	03	343
SELECT d,a,b,c FROM t1 partition (p18);
d	a	b	c
SELECT d,a,b,c FROM t1 partition (p19);
d	a	b	c
SELECT * FROM t1 WHERE a='01' FOR UPDATE ;
a	b	c	d	e
01	04	343	2	01_04_343
01	06	343	3	01_06_343
01	07	343	4	01_07_343
01	08	343	5	01_08_343
01	09	343	6	01_09_343
SELECT * FROM t3 FORCE INDEX(a) WHERE a='01' FOR UPDATE ;
a	b	c	d	e
01	04	343	2	01_04_343
01	06	343	3	01_06_343
01	07	343	4	01_07_343
01	08	343	5	01_08_343
01	09	343	6	01_09_343
connect  con2,localhost,test,,test;
BEGIN;
SET SESSION innodb_lock_wait_timeout=1;
#
#  SHARE ...
SELECT * FROM t1 LOCK IN SHARE MODE;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SELECT * FROM t1 LOCK IN SHARE MODE NOWAIT;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SELECT * FROM t1 ORDER BY d LOCK IN SHARE MODE SKIP LOCKED;
a	b	c	d	e
07	03	343	1	07_03_343
04	03	343	10	04_03_343
04	06	343	11	04_06_343
05	03	343	12	05_03_343
11	03	343	13	11_03_343
11	04	343	14	11_04_343
03	03	343	7	03_03_343
03	06	343	8	03_06_343
03	07	343	9	03_07_343
SELECT a,count(b) FROM t1 force index (a) GROUP BY a ORDER BY a LOCK IN SHARE MODE SKIP LOCKED;
a	count(b)
01	5
03	3
04	2
05	1
07	1
11	2
SELECT d,a,b,c FROM t1 partition (p1,p9,p11,p17) ORDER BY d 
LOCK IN SHARE MODE SKIP LOCKED;
d	a	b	c
1	07	03	343
10	04	03	343
11	04	06	343
12	05	03	343
13	11	03	343
14	11	04	343
7	03	03	343
8	03	06	343
9	03	07	343
SELECT d,a,b,c FROM t1 ORDER BY d LOCK IN SHARE MODE SKIP LOCKED;
d	a	b	c
1	07	03	343
10	04	03	343
11	04	06	343
12	05	03	343
13	11	03	343
14	11	04	343
7	03	03	343
8	03	06	343
9	03	07	343
ANALYZE TABLE t3;
Table	Op	Msg_type	Msg_text
test.t3	analyze	status	Engine-independent statistics collected
test.t3	analyze	status	OK
SELECT d,a,b,c FROM t3 ORDER BY d LOCK IN SHARE MODE SKIP LOCKED;
d	a	b	c
1	07	03	343
10	04	03	343
11	04	06	343
12	05	03	343
13	11	03	343
14	11	04	343
7	03	03	343
8	03	06	343
9	03	07	343
explain SELECT d,a,b,c FROM t3 ORDER BY d 
LOCK IN SHARE MODE SKIP LOCKED;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t3	index	NULL	PRIMARY	257	NULL	14	
#
#  UPDATE ...
SELECT * FROM t1 FOR UPDATE;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SELECT * FROM t1 FOR UPDATE NOWAIT;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SELECT * FROM t1 ORDER BY a FOR UPDATE SKIP LOCKED;
a	b	c	d	e
03	03	343	7	03_03_343
03	06	343	8	03_06_343
03	07	343	9	03_07_343
04	03	343	10	04_03_343
04	06	343	11	04_06_343
05	03	343	12	05_03_343
07	03	343	1	07_03_343
11	03	343	13	11_03_343
11	04	343	14	11_04_343
SELECT a,count(b) FROM t1 GROUP BY a ORDER BY a FOR UPDATE SKIP LOCKED;
a	count(b)
03	3
04	2
05	1
07	1
11	2
SELECT d,a,b,c FROM t1 partition (p1,p9,p11,p17) ORDER BY d 
FOR UPDATE SKIP LOCKED;
d	a	b	c
1	07	03	343
10	04	03	343
11	04	06	343
12	05	03	343
13	11	03	343
14	11	04	343
7	03	03	343
8	03	06	343
9	03	07	343
SELECT d,a,b,c FROM t1 ORDER BY d FOR UPDATE SKIP LOCKED;
d	a	b	c
1	07	03	343
10	04	03	343
11	04	06	343
12	05	03	343
13	11	03	343
14	11	04	343
7	03	03	343
8	03	06	343
9	03	07	343
SELECT d,a,b,c FROM t3 ORDER BY d FOR UPDATE SKIP LOCKED;
d	a	b	c
1	07	03	343
10	04	03	343
11	04	06	343
12	05	03	343
13	11	03	343
14	11	04	343
7	03	03	343
8	03	06	343
9	03	07	343
connection con1;
COMMIT;
connection con1;
BEGIN;
SELECT * FROM t1 WHERE a='01' LOCK IN SHARE MODE ;
a	b	c	d	e
01	04	343	2	01_04_343
01	06	343	3	01_06_343
01	07	343	4	01_07_343
01	08	343	5	01_08_343
01	09	343	6	01_09_343
SELECT * FROM t3 FORCE INDEX(a) WHERE a='01' LOCK IN SHARE MODE ;
a	b	c	d	e
01	04	343	2	01_04_343
01	06	343	3	01_06_343
01	07	343	4	01_07_343
01	08	343	5	01_08_343
01	09	343	6	01_09_343
connection con2;
BEGIN;
SET SESSION innodb_lock_wait_timeout=1;
#
#  SHARE ...
SELECT * FROM t1 LOCK IN SHARE MODE;
a	b	c	d	e
03	03	343	7	03_03_343
03	06	343	8	03_06_343
03	07	343	9	03_07_343
01	04	343	2	01_04_343
01	06	343	3	01_06_343
01	07	343	4	01_07_343
01	08	343	5	01_08_343
01	09	343	6	01_09_343
04	03	343	10	04_03_343
04	06	343	11	04_06_343
05	03	343	12	05_03_343
11	03	343	13	11_03_343
11	04	343	14	11_04_343
07	03	343	1	07_03_343
SELECT * FROM t1 LOCK IN SHARE MODE NOWAIT;
a	b	c	d	e
03	03	343	7	03_03_343
03	06	343	8	03_06_343
03	07	343	9	03_07_343
01	04	343	2	01_04_343
01	06	343	3	01_06_343
01	07	343	4	01_07_343
01	08	343	5	01_08_343
01	09	343	6	01_09_343
04	03	343	10	04_03_343
04	06	343	11	04_06_343
05	03	343	12	05_03_343
11	03	343	13	11_03_343
11	04	343	14	11_04_343
07	03	343	1	07_03_343
SELECT * FROM t1 ORDER BY d LOCK IN SHARE MODE SKIP LOCKED;
a	b	c	d	e
07	03	343	1	07_03_343
04	03	343	10	04_03_343
04	06	343	11	04_06_343
05	03	343	12	05_03_343
11	03	343	13	11_03_343
11	04	343	14	11_04_343
01	04	343	2	01_04_343
01	06	343	3	01_06_343
01	07	343	4	01_07_343
01	08	343	5	01_08_343
01	09	343	6	01_09_343
03	03	343	7	03_03_343
03	06	343	8	03_06_343
03	07	343	9	03_07_343
SELECT a,count(b) FROM t1 GROUP BY a ORDER BY a LOCK IN SHARE MODE SKIP LOCKED;
a	count(b)
01	5
03	3
04	2
05	1
07	1
11	2
SELECT d,a,b,c FROM t1 partition (p1,p9,p11,p17) ORDER BY d 
LOCK IN SHARE MODE SKIP LOCKED;
d	a	b	c
1	07	03	343
10	04	03	343
11	04	06	343
12	05	03	343
13	11	03	343
14	11	04	343
2	01	04	343
3	01	06	343
4	01	07	343
5	01	08	343
6	01	09	343
7	03	03	343
8	03	06	343
9	03	07	343
SELECT d,a,b,c FROM t1 ORDER BY d LOCK IN SHARE MODE SKIP LOCKED;
d	a	b	c
1	07	03	343
10	04	03	343
11	04	06	343
12	05	03	343
13	11	03	343
14	11	04	343
2	01	04	343
3	01	06	343
4	01	07	343
5	01	08	343
6	01	09	343
7	03	03	343
8	03	06	343
9	03	07	343
ANALYZE TABLE t3;
Table	Op	Msg_type	Msg_text
test.t3	analyze	status	Engine-independent statistics collected
test.t3	analyze	status	OK
SELECT d,a,b,c FROM t3 ORDER BY d LOCK IN SHARE MODE SKIP LOCKED;
d	a	b	c
1	07	03	343
10	04	03	343
11	04	06	343
12	05	03	343
13	11	03	343
14	11	04	343
2	01	04	343
3	01	06	343
4	01	07	343
5	01	08	343
6	01	09	343
7	03	03	343
8	03	06	343
9	03	07	343
explain SELECT d,a,b,c FROM t3 ORDER BY d 
LOCK IN SHARE MODE SKIP LOCKED;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t3	index	NULL	PRIMARY	257	NULL	14	
#
#  UPDATE ...
SELECT * FROM t1 FOR UPDATE;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SELECT * FROM t1 FOR UPDATE NOWAIT;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SELECT * FROM t1 ORDER BY a FOR UPDATE SKIP LOCKED;
a	b	c	d	e
03	03	343	7	03_03_343
03	06	343	8	03_06_343
03	07	343	9	03_07_343
04	03	343	10	04_03_343
04	06	343	11	04_06_343
05	03	343	12	05_03_343
07	03	343	1	07_03_343
11	03	343	13	11_03_343
11	04	343	14	11_04_343
SELECT a,count(b) FROM t1 GROUP BY a ORDER BY a FOR UPDATE SKIP LOCKED;
a	count(b)
03	3
04	2
05	1
07	1
11	2
SELECT d,a,b,c FROM t1 partition (p1,p9,p11,p17) ORDER BY d 
FOR UPDATE SKIP LOCKED;
d	a	b	c
1	07	03	343
10	04	03	343
11	04	06	343
12	05	03	343
13	11	03	343
14	11	04	343
7	03	03	343
8	03	06	343
9	03	07	343
SELECT d,a,b,c FROM t1 ORDER BY d FOR UPDATE SKIP LOCKED;
d	a	b	c
1	07	03	343
10	04	03	343
11	04	06	343
12	05	03	343
13	11	03	343
14	11	04	343
7	03	03	343
8	03	06	343
9	03	07	343
SELECT d,a,b,c FROM t3 ORDER BY d FOR UPDATE SKIP LOCKED;
d	a	b	c
1	07	03	343
10	04	03	343
11	04	06	343
12	05	03	343
13	11	03	343
14	11	04	343
7	03	03	343
8	03	06	343
9	03	07	343
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t1, t2, t3;
DROP USER test@localhost;
DROP USER test2@localhost;
set @@global.read_only= @start_read_only;
set @@global.autocommit= @start_autocommit;
set default_storage_engine= default;