#At file:///Users/tnurnberg/forest/48295_/50-48295_/ based on revid:joro@stripped
2847 Tatiana A. Nurnberg 2010-03-02
Bug#48295: explain extended crash with subquery and ONLY_FULL_GROUP_BY sql
If an outer query is broken, a subquery might not even get set up.
EXPLAIN EXTENDED did not expect this and merrily tried to de-ref all
of the half-setup info.
We now catch this case and print as much as we have, as it doesn't cost us
anything (doesn't make regular execution slower).
backport from 5.1
@ mysql-test/r/explain.result
Show that EXPLAIN EXTENDED with subquery and illegal out query doesn't crash.
Show also that SHOW WARNINGS will render an additional Note in the hope of
being, well, helpful.
@ mysql-test/t/explain.test
If we have only half a query for EXPLAIN EXTENDED to print (i.e.,
incomplete subquery info as outer query is illegal), we should
provide the user with as much info as we easily can if they ask
for it. What we should not do is crash when they come asking for
help, that violates etiquette in some countries.
@ sql/item_subselect.cc
If the sub-query's actually set up, print it. Otherwise, elide.
modified:
mysql-test/r/explain.result
mysql-test/t/explain.test
sql/item_subselect.cc
=== modified file 'mysql-test/r/explain.result'
--- a/mysql-test/r/explain.result 2009-09-04 07:20:53 +0000
+++ b/mysql-test/r/explain.result 2010-03-02 18:00:53 +0000
@@ -167,3 +167,20 @@ EXPLAIN SELECT DISTINCT 1 FROM t1,
WHERE t1.a = d1.a;
ERROR 42S22: Unknown column 'd1.a' in 'where clause'
DROP TABLE t1;
+#
+# Bug#48295:
+# explain extended crash with subquery and ONLY_FULL_GROUP_BY sql_mode
+#
+CREATE TABLE t1 (f1 INT);
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+EXPLAIN EXTENDED SELECT 1 FROM t1
+WHERE f1 > ALL( SELECT t.f1 FROM t1,t1 AS t );
+ERROR 42000: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
+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;
+End of 5.0 tests.
=== modified file 'mysql-test/t/explain.test'
--- a/mysql-test/t/explain.test 2009-09-04 07:20:53 +0000
+++ b/mysql-test/t/explain.test 2010-03-02 18:00:53 +0000
@@ -147,4 +147,24 @@ EXPLAIN SELECT DISTINCT 1 FROM t1,
WHERE t1.a = d1.a;
DROP TABLE t1;
-# End of 5.0 tests.
+--echo #
+--echo # Bug#48295:
+--echo # explain extended crash with subquery and ONLY_FULL_GROUP_BY sql_mode
+--echo #
+
+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.
+--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 );
+SHOW WARNINGS;
+
+SET SESSION sql_mode=@old_sql_mode;
+
+DROP TABLE t1;
+
+--echo End of 5.0 tests.
=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc 2009-11-03 16:58:54 +0000
+++ b/sql/item_subselect.cc 2010-03-02 18:00:53 +0000
@@ -262,9 +262,14 @@ void Item_subselect::update_used_tables(
void Item_subselect::print(String *str)
{
- str->append('(');
- engine->print(str);
- str->append(')');
+ if (engine)
+ {
+ str->append('(');
+ engine->print(str);
+ str->append(')');
+ }
+ else
+ str->append("(...)");
}
Attachment: [text/bzr-bundle] bzr/azundris@mysql.com-20100302180053-pyebi9ip52ewkq7a.bundle
| Thread |
|---|
| • bzr commit into mysql-5.0-bugteam branch (azundris:2847) Bug#48295 | Tatiana A. Nurnberg | 2 Mar |