summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMySQL Build Team <build@mysql.com>2009-11-25 18:04:39 +0100
committerMySQL Build Team <build@mysql.com>2009-11-25 18:04:39 +0100
commit656729ecef932d7efd7845249537349850639e3c (patch)
tree03d987265698bf794bdcde58ac1d4d6086f7e2f7
parentcb19889a12ebf24a77f8748e3b742a715b0e5207 (diff)
downloadmariadb-git-656729ecef932d7efd7845249537349850639e3c.tar.gz
Backport into build-200911241145-5.1.40sp1
> ------------------------------------------------------------ > revno: 3148.9.3 > revision-id: azundris@mysql.com-20091029230154-jp2xqvzw2nhj9q41 > parent: azundris@mysql.com-20091027095316-54lwjr9vqkscq1ik > committer: Tatiana A. Nurnberg <azundris@mysql.com> > branch nick: 51-48295 > timestamp: Thu 2009-10-29 16:01:54 -0700 > message: > Bug#48295: explain extended crash with subquery and ONLY_FULL_GROUP_BY sql_mode > > 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).
-rw-r--r--mysql-test/r/explain.result16
-rw-r--r--mysql-test/t/explain.test20
-rw-r--r--sql/item_subselect.cc11
3 files changed, 44 insertions, 3 deletions
diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result
index 96fcbc33d3f..5a1bf1a1290 100644
--- a/mysql-test/r/explain.result
+++ b/mysql-test/r/explain.result
@@ -194,4 +194,20 @@ dt
2001-01-01 01:01:01
2001-01-01 01:01:01
drop tables t1, t2;
+#
+# 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.1 tests.
diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test
index 18f1145a25d..77b49a8b1a5 100644
--- a/mysql-test/t/explain.test
+++ b/mysql-test/t/explain.test
@@ -167,4 +167,24 @@ flush tables;
SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' );
drop tables t1, t2;
+--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.1 tests.
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index da651cec70c..29db9eb0903 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -311,9 +311,14 @@ void Item_subselect::update_used_tables()
void Item_subselect::print(String *str, enum_query_type query_type)
{
- str->append('(');
- engine->print(str, query_type);
- str->append(')');
+ if (engine)
+ {
+ str->append('(');
+ engine->print(str, query_type);
+ str->append(')');
+ }
+ else
+ str->append("(...)");
}