Skip to content

Commit 16e5bc4

Browse files
committed
Merge branch '10.9' into 10.10
2 parents 13a294a + d7fae79 commit 16e5bc4

17 files changed

+1636
-355
lines changed

mysql-test/main/derived_split_innodb.result

Lines changed: 537 additions & 0 deletions
Large diffs are not rendered by default.

mysql-test/main/derived_split_innodb.test

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,216 @@ drop table t3, t4;
233233

234234
--echo # End of 10.3 tests
235235

236+
237+
--echo #
238+
--echo # MDEV-26301: Split optimization refills temporary table too many times
239+
--echo #
240+
241+
# 5 values
242+
create table t1(a int, b int);
243+
insert into t1 select seq,seq from seq_1_to_5;
244+
245+
# 5 value groups of size 2 each
246+
create table t2(a int, b int, key(a));
247+
insert into t2
248+
select A.seq,B.seq from seq_1_to_25 A, seq_1_to_2 B;
249+
250+
# 5 value groups of size 3 each
251+
create table t3(a int, b int, key(a));
252+
insert into t3
253+
select A.seq,B.seq from seq_1_to_5 A, seq_1_to_3 B;
254+
255+
analyze table t1,t2,t3 persistent for all;
256+
257+
explain
258+
select * from
259+
(t1 left join t2 on t2.a=t1.b) left join t3 on t3.a=t1.b;
260+
261+
# Now, create tables for Groups.
262+
263+
create table t10 (
264+
grp_id int,
265+
col1 int,
266+
key(grp_id)
267+
);
268+
269+
# 100 groups of 100 values each
270+
insert into t10
271+
select
272+
A.seq,
273+
B.seq
274+
from
275+
seq_1_to_100 A,
276+
seq_1_to_100 B;
277+
278+
# and X10 multiplier
279+
280+
create table t11 (
281+
col1 int,
282+
col2 int
283+
);
284+
insert into t11
285+
select A.seq, A.seq from seq_1_to_10 A;
286+
287+
analyze table t10,t11 persistent for all;
288+
289+
let $q1=
290+
select * from
291+
(
292+
(t1 left join t2 on t2.a=t1.b)
293+
left join t3 on t3.a=t1.b
294+
) left join (select grp_id, count(*)
295+
from t10 left join t11 on t11.col1=t10.col1
296+
group by grp_id) T on T.grp_id=t1.b;
297+
298+
eval
299+
explain $q1;
300+
301+
--echo # The important part in the below output is:
302+
--echo # "lateral": 1,
303+
--echo # "query_block": {
304+
--echo # "select_id": 2,
305+
--echo # "r_loops": 5, <-- must be 5, not 30.
306+
--source include/analyze-format.inc
307+
308+
eval
309+
analyze format=json $q1;
310+
311+
create table t21 (pk int primary key);
312+
insert into t21 values (1),(2),(3);
313+
314+
create table t22 (pk int primary key);
315+
insert into t22 values (1),(2),(3);
316+
317+
# Same as above but throw in a couple of const tables.
318+
explain
319+
select * from
320+
t21, t22,
321+
(
322+
(t1 left join t2 on t2.a=t1.b)
323+
left join t3 on t3.a=t1.b
324+
) left join (select grp_id, count(*)
325+
from t10 left join t11 on t11.col1=t10.col1
326+
group by grp_id) T on T.grp_id=t1.b
327+
where
328+
t21.pk=1 and t22.pk=2;
329+
330+
explain
331+
select * from
332+
t21,
333+
(
334+
(t1 left join t2 on t2.a=t1.b)
335+
left join t3 on t3.a=t1.b
336+
) left join (select grp_id, count(*)
337+
from
338+
t22 join t10 left join t11 on t11.col1=t10.col1
339+
where
340+
t22.pk=1
341+
group by grp_id) T on T.grp_id=t1.b
342+
where
343+
t21.pk=1;
344+
345+
# And also add a non-const table
346+
347+
create table t5 (
348+
pk int primary key
349+
);
350+
insert into t5 select seq from seq_1_to_1000;
351+
352+
explain
353+
select * from
354+
t21,
355+
(
356+
(((t1 join t5 on t5.pk=t1.b)) left join t2 on t2.a=t1.b)
357+
left join t3 on t3.a=t1.b
358+
) left join (select grp_id, count(*)
359+
from
360+
t22 join t10 left join t11 on t11.col1=t10.col1
361+
where
362+
t22.pk=1
363+
group by grp_id) T on T.grp_id=t1.b
364+
where
365+
t21.pk=1;
366+
367+
drop table t1,t2,t3,t5, t10, t11, t21, t22;
368+
369+
# 5 values
370+
create table t1(a int, b int);
371+
insert into t1 select seq,seq from seq_1_to_5;
372+
373+
# 5 value groups of size 2 each
374+
create table t2(a int, b int, key(a));
375+
insert into t2
376+
select A.seq,B.seq from seq_1_to_25 A, seq_1_to_2 B;
377+
378+
# 5 value groups of size 3 each
379+
create table t3(a int, b int, key(a));
380+
insert into t3
381+
select A.seq,B.seq from seq_1_to_5 A, seq_1_to_3 B;
382+
383+
analyze table t1,t2,t3 persistent for all;
384+
385+
create table t10 (
386+
grp_id int,
387+
col1 int,
388+
key(grp_id)
389+
);
390+
391+
# 100 groups of 100 values each
392+
insert into t10
393+
select
394+
A.seq,
395+
B.seq
396+
from
397+
seq_1_to_100 A,
398+
seq_1_to_100 B;
399+
400+
# and X10 multiplier
401+
402+
create table t11 (
403+
col1 int,
404+
col2 int
405+
);
406+
insert into t11
407+
select A.seq, A.seq from seq_1_to_10 A;
408+
409+
analyze table t10,t11 persistent for all;
410+
411+
let $q=
412+
select *
413+
from
414+
(
415+
(t1 left join t2 on t2.a=t1.b)
416+
left join
417+
t3
418+
on t3.a=t1.b
419+
)
420+
left join
421+
(
422+
select grp_id, count(*)
423+
from t10 left join t11 on t11.col1=t10.col1
424+
group by grp_id
425+
)dt
426+
on dt.grp_id=t1.b;
427+
428+
eval explain $q;
429+
eval $q;
430+
431+
set join_cache_level=4;
432+
eval explain $q;
433+
eval $q;
434+
435+
set join_cache_level=default;
436+
437+
drop index a on t2;
438+
drop index a on t3;
439+
440+
eval explain $q;
441+
eval $q;
442+
443+
drop table t1,t2,t3;
444+
drop table t10, t11;
445+
446+
--echo # End of 10.4 tests
447+
236448
SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent;

mysql-test/main/explain_innodb.result

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,21 @@ id select_type table type possible_keys key key_len ref rows Extra
1818
2 DERIVED t1 range NULL id 53 NULL 2 Using index for group-by
1919
SET GLOBAL slow_query_log = @sql_tmp;
2020
drop table t1;
21+
#
22+
# MDEV-31181: Server crash in subselect_uniquesubquery_engine::print
23+
# upon EXPLAIN EXTENDED DELETE
24+
#
25+
CREATE TABLE t1 (a INT);
26+
INSERT INTO t1 VALUES (1),(2);
27+
CREATE TABLE t2 (pk INT PRIMARY KEY);
28+
INSERT INTO t2 VALUES (1),(2);
29+
EXPLAIN EXTENDED DELETE FROM t1 WHERE a IN (SELECT pk FROM t2);
30+
id select_type table type possible_keys key key_len ref rows filtered Extra
31+
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
32+
2 DEPENDENT SUBQUERY t2 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
33+
Warnings:
34+
Note 1003 /* select#1 */ delete from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`a`))))
35+
drop table t1, t2;
36+
#
37+
# End of 10.4 tests
38+
#

mysql-test/main/explain_innodb.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,22 @@ SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt WHERE 1=0;
1818

1919
SET GLOBAL slow_query_log = @sql_tmp;
2020
drop table t1;
21+
22+
23+
--echo #
24+
--echo # MDEV-31181: Server crash in subselect_uniquesubquery_engine::print
25+
--echo # upon EXPLAIN EXTENDED DELETE
26+
--echo #
27+
28+
CREATE TABLE t1 (a INT);
29+
INSERT INTO t1 VALUES (1),(2);
30+
CREATE TABLE t2 (pk INT PRIMARY KEY);
31+
INSERT INTO t2 VALUES (1),(2);
32+
33+
EXPLAIN EXTENDED DELETE FROM t1 WHERE a IN (SELECT pk FROM t2);
34+
35+
drop table t1, t2;
36+
37+
--echo #
38+
--echo # End of 10.4 tests
39+
--echo #

0 commit comments

Comments
 (0)