Crash in fix_semijoin_strategies_for_picked_join_order with nested subqueries and LooseScan=ON
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| MariaDB |
Fix Released
|
Critical
|
Timour Katchaounov | ||
Bug Description
The following query:
SELECT *
FROM v3
WHERE v3.b > ALL (
SELECT c
FROM t4
WHERE t4.a >= v3.b
AND a = SOME (
)
);
causes the following backtrace:
#4 <signal handler called>
#5 0x083df730 in fix_semijoin_
#6 0x08329c00 in get_best_
#7 0x08322566 in make_join_
#8 0x0831a151 in JOIN::optimize (this=0xae53a508) at sql_select.cc:1113
#9 0x081b5e0c in st_select_
#10 0x083e2867 in JOIN::optimize_
#11 0x0831b734 in JOIN::optimize (this=0xae52dfa0) at sql_select.cc:1504
#12 0x0831ff2b in mysql_select (thd=0x9f046b8, rref_pointer_
order=0x0, group=0x0, having=0x0, proc_param=0x0, select_
at sql_select.cc:2887
#13 0x08317da3 in handle_select (thd=0x9f046b8, lex=0x9f05dc0, result=0xae5144e8, setup_tables_
#14 0x082b3171 in execute_
#15 0x082a9f75 in mysql_execute_
#16 0x082b57ad in mysql_parse (thd=0x9f046b8,
rawbuf=
found_
#17 0x082a7bf2 in dispatch_command (command=COM_QUERY, thd=0x9f046b8,
packet=
packet_
#18 0x082a704d in do_command (thd=0x9f046b8) at sql_parse.cc:906
#19 0x082a40b5 in handle_
#20 0x00821919 in start_thread () from /lib/libpthread
#21 0x0076acce in clone () from /lib/libc.so.6
explain:
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t5 index c c 10 NULL 2 Using where; Using index; Start temporary
2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t5.b 1 Using where; End temporary
minimal optimizer switch:
semijoin=
full optimizer switch:
index_merge=
bzr version-info
revision-id: <email address hidden>
date: 2011-08-23 15:51:47 +0300
build-date: 2011-08-26 11:02:59 +0300
revno: 3166
branch-nick: maria-5.3
test case:
CREATE TABLE t3 (b int) ;
INSERT INTO t3 VALUES (0),(0);
CREATE OR REPLACE VIEW v3 AS SELECT * FROM t3;
CREATE TABLE t4 (a int, b int, c int, d int, PRIMARY KEY (a)) ;
INSERT INTO t4 VALUES (28,0,0,
CREATE TABLE t5 (a int, b int, c int, d int, KEY (c,b)) ;
INSERT INTO t5 VALUES (28,0,0,
SET SESSION optimizer_
SELECT *
FROM v3
WHERE v3.b > ALL (
SELECT c
FROM t4
WHERE t4.a >= v3.b
AND a = SOME (
)
);
Related branches
| Changed in maria: | |
| milestone: | none → 5.3 |
| assignee: | nobody → Sergey Petrunia (sergefp) |
| Changed in maria: | |
| importance: | Undecided → High |
| Changed in maria: | |
| importance: | High → Critical |
| Changed in maria: | |
| assignee: | Sergey Petrunia (sergefp) → Timour Katchaounov (timour) |
| Changed in maria: | |
| status: | New → In Progress |
| Changed in maria: | |
| status: | In Progress → Fix Committed |
| Changed in maria: | |
| status: | Fix Committed → Fix Released |

The problem is repeatable without use of VIEWs: here's a simplified testcase that crashes in the same way:
CREATE TABLE t3 (b int) ;
INSERT INTO t3 VALUES (0),(0);
CREATE TABLE t4 (a int, b int, c int, d int, PRIMARY KEY (a)) ; 0),(29, 3,0,0);
INSERT INTO t4 VALUES (28,0,0,
CREATE TABLE t5 (a int, b int, c int, d int, KEY (c,b)) ; 0),(29, 3,0,0);
INSERT INTO t5 VALUES (28,0,0,
SET SESSION optimizer_ switch= 'semijoin= ON,loosescan= ON,firstmatch= OFF,materializa tion=OFF' ;
SELECT *
SELECT b
FROM t5
FROM t3
WHERE t3.b > ALL (
SELECT c
FROM t4
WHERE t4.a >= t3.b
AND a = SOME (
)
);