#At file:///export/home/didrik/mysqldev-next-mr/next-mr-opt-backporting-br1/ based on revid:olav@stripped
3071 Tor Didriksen 2010-04-13
Bug #46860 Crash/segfault using EXPLAIN EXTENDED on query using UNION in subquery
Backport of tor.didriksen@stripped
EXPLAIN EXTENDED <query> will not generate a Note with extended information
if EXPLAIN <query> returns an error.
@ mysql-test/r/explain.result
Add testcase based on bug report.
@ mysql-test/r/subselect3.result
Remove the extended Note, since explain returns error.
@ mysql-test/t/explain.test
Add testcase based on bug report.
@ sql/sql_parse.cc
Skip the extended description if we have an error.
modified:
mysql-test/r/explain.result
mysql-test/r/subselect3.result
mysql-test/t/explain.test
sql/sql_parse.cc
=== modified file 'mysql-test/r/explain.result'
--- a/mysql-test/r/explain.result 2010-03-22 13:01:49 +0000
+++ b/mysql-test/r/explain.result 2010-04-13 11:57:31 +0000
@@ -207,7 +207,6 @@ ERROR 42000: Mixing of GROUP columns (MI
SHOW WARNINGS;
Level Code Message
Error 1140 Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
-Note 1003 select 1 AS `1` from `test`.`t1` where <not>(<exists>(...))
SET SESSION sql_mode=@old_sql_mode;
DROP TABLE t1;
#
@@ -231,3 +230,14 @@ Warnings:
Note 1003 select '1' AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` = 1)
drop table t1,t2;
End of 5.1 tests.
+#
+# Bug#46860:
+# Crash/segfault using EXPLAIN EXTENDED on query using UNION in subquery.
+#
+drop table if exists t1;
+create table `t1` (`a` int);
+explain extended select 1 from `t1`, `t1` as `t2`
+where `t1`.`a` > all ( (select `a` from `t1` ) union (select `a`) );
+ERROR 23000: Column 'a' in field list is ambiguous
+drop table t1;
+End of 6.0 tests.
=== modified file 'mysql-test/r/subselect3.result'
--- a/mysql-test/r/subselect3.result 2010-03-25 11:08:24 +0000
+++ b/mysql-test/r/subselect3.result 2010-04-13 11:57:31 +0000
@@ -864,9 +864,6 @@ Level Code Message
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2
Note 1276 Field or reference 'test.t1.c' of SELECT #3 was resolved in SELECT #2
Error 1054 Unknown column 'c' in 'field list'
-Note 1003 select `c` AS `c` from (select (select count(`test`.`t1`.`a`) AS `COUNT(a)` from dual group by `c`) AS `(SELECT COUNT(a) FROM
-(SELECT COUNT(b) FROM t1) AS x GROUP BY c
-)` from `test`.`t1` group by `test`.`t1`.`b`) `y`
DROP TABLE t1;
End of 5.0 tests
create table t0 (a int);
=== modified file 'mysql-test/t/explain.test'
--- a/mysql-test/t/explain.test 2009-12-11 09:39:38 +0000
+++ b/mysql-test/t/explain.test 2010-04-13 11:57:31 +0000
@@ -1,5 +1,5 @@
#
-# Test of different EXPLAIN's
+# Test of different EXPLAINs
--disable_warnings
drop table if exists t1;
@@ -177,7 +177,7 @@ CREATE TABLE t1 (f1 INT);
SELECT @@session.sql_mode INTO @old_sql_mode;
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
-# EXPLAIN EXTENDED (with subselect). used to crash. should give NOTICE.
+# EXPLAIN EXTENDED (with subselect). used to crash.
--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS
EXPLAIN EXTENDED SELECT 1 FROM t1
WHERE f1 > ALL( SELECT t.f1 FROM t1,t1 AS t );
@@ -200,3 +200,18 @@ explain extended select * from t1 join t
drop table t1,t2;
--echo End of 5.1 tests.
+
+--echo #
+--echo # Bug#46860:
+--echo # Crash/segfault using EXPLAIN EXTENDED on query using UNION in subquery.
+--echo #
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table `t1` (`a` int);
+--error ER_NON_UNIQ_ERROR
+explain extended select 1 from `t1`, `t1` as `t2`
+where `t1`.`a` > all ( (select `a` from `t1` ) union (select `a`) );
+drop table t1;
+
+--echo End of 6.0 tests.
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2010-03-25 11:14:23 +0000
+++ b/sql/sql_parse.cc 2010-04-13 11:57:31 +0000
@@ -4680,7 +4680,11 @@ static bool execute_sqlcom_select(THD *t
return 1; /* purecov: inspected */
thd->send_explain_fields(result);
res= mysql_explain_union(thd, &thd->lex->unit, result);
- if (lex->describe & DESCRIBE_EXTENDED)
+ /*
+ The code which prints the extended description is not robust
+ against malformed queries, so skip it if we have an error.
+ */
+ if (!res && (lex->describe & DESCRIBE_EXTENDED))
{
char buff[1024];
String str(buff,(uint32) sizeof(buff), system_charset_info);
Attachment: [text/bzr-bundle] bzr/tor.didriksen@sun.com-20100413115731-vm2si1g7zefmi5mr.bundle
| Thread |
|---|
| • bzr commit into mysql-next-mr-bugfixing branch (tor.didriksen:3071) Bug#46860 | Tor Didriksen | 13 Apr |