Crash in select_describe() on EXPLAIN with DISTINCT in nested subqueries
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
High
|
Timour Katchaounov |
Bug Description
This query:
EXPLAIN SELECT *
FROM t1
WHERE t1.a = (
SELECT SUM( c )
FROM t2
WHERE (
) > 0
);
crashes as follows:
#4 <signal handler called>
#5 0x08347fd1 in select_describe (join=0x9b130cc8, need_tmp_
#6 0x0831d997 in JOIN::exec (this=0x9b130cc8) at sql_select.cc:2181
#7 0x0831fd0a in mysql_select (thd=0xaecd1e8, rref_pointer_
group=0x0, having=0x0, proc_param=0x0, select_
#8 0x08349e9f in mysql_explain_union (thd=0xaecd1e8, unit=0xa3314ba0, result=0xa3315660) at sql_select.cc:21040
#9 0x08349b7a in select_describe (join=0xa332daa0, need_tmp_
message=
#10 0x08330ddf in return_zero_rows (join=0xa332daa0, result=0xa3315660, tables=..., fields=..., send_row=true, select_
info=0x88e931c "Impossible WHERE noticed after reading const tables", having=0x0) at sql_select.cc:10170
#11 0x0831d583 in JOIN::exec (this=0xa332daa0) at sql_select.cc:2122
#12 0x0831fd0a in mysql_select (thd=0xaecd1e8, rref_pointer_
order=0x0, group=0x0, having=0x0, proc_param=0x0, select_
at sql_select.cc:2891
#13 0x08349e9f in mysql_explain_union (thd=0xaecd1e8, unit=0xa3314278, result=0xa3315660) at sql_select.cc:21040
#14 0x08349b7a in select_describe (join=0xa3326830, need_tmp_
message=
#15 0x08330ddf in return_zero_rows (join=0xa3326830, result=0xa3315660, tables=..., fields=..., send_row=false, select_
info=0x88e931c "Impossible WHERE noticed after reading const tables", having=0x0) at sql_select.cc:10170
#16 0x0831d583 in JOIN::exec (this=0xa3326830) at sql_select.cc:2122
#17 0x0831fd0a in mysql_select (thd=0xaecd1e8, rref_pointer_
order=0x0, group=0x0, having=0x0, proc_param=0x0, select_
at sql_select.cc:2891
#18 0x08349e9f in mysql_explain_union (thd=0xaecd1e8, unit=0xaece94c, result=0xa3315660) at sql_select.cc:21040
#19 0x082b2e07 in execute_
#20 0x082a9d89 in mysql_execute_
#21 0x082b55c1 in mysql_parse (thd=0xaecd1e8,
rawbuf=
found_
#22 0x082a7a06 in dispatch_command (command=COM_QUERY, thd=0xaecd1e8, packet=0xaf258b1 "", packet_length=105) at sql_parse.cc:1211
#23 0x082a6e61 in do_command (thd=0xaecd1e8) at sql_parse.cc:906
#24 0x082a3ec9 in handle_
#25 0x00821919 in start_thread () from /lib/libpthread
#26 0x00453cce in clone () from /lib/libc.so.6
explain in other versions:
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
3 SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using temporary
optimizer switch:
index_merge=
bzr version-info
revision-id: <email address hidden>
date: 2011-08-16 15:51:40 +0300
build-date: 2011-08-16 17:45:06 +0300
revno: 3157
branch-nick: maria-5.3
DISTINCT appears to be required which makes the query partially unrealistic. Maybe it is best to ignore/filter out DISTINCT inside subqueries early in the optimization.
Repeatable on maria-5.3. Not repeatable in maria-5.2, mysql-5.5. Not influenced by any particular switches.
Related branches
Changed in maria: | |
milestone: | none → 5.3 |
Changed in maria: | |
assignee: | nobody → Timour Katchaounov (timour) |
importance: | Undecided → High |
Changed in maria: | |
status: | New → In Progress |
Changed in maria: | |
status: | In Progress → Fix Released |
Test case:
--source include/ have_innodb. inc
DROP TABLE IF EXISTS t3;
CREATE TABLE t3 ( b int) ENGINE=InnoDB;
DROP TABLE IF EXISTS t2;
CREATE TABLE t2 ( c int) ENGINE=InnoDB;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( a int NOT NULL , PRIMARY KEY (a)) ENGINE=InnoDB;
EXPLAIN SELECT *
SELECT DISTINCT b
FROM t3
FROM t1
WHERE t1.a = (
SELECT SUM( c )
FROM t2
WHERE (
) > 0
);