summaryrefslogtreecommitdiff
path: root/mysql-test/t/explain.test
diff options
context:
space:
mode:
authorTatiana A. Nurnberg <azundris@mysql.com>2009-10-29 16:01:54 -0700
committerTatiana A. Nurnberg <azundris@mysql.com>2009-10-29 16:01:54 -0700
commiteaad6119dadcdfeea4f71fab6401a19b648b5fa6 (patch)
tree5d852e78a9054234478082d04c01044d9749c4b3 /mysql-test/t/explain.test
parent6ceaf234bb9fa2e521c67568e1bd6f76ac890ee2 (diff)
downloadmariadb-git-eaad6119dadcdfeea4f71fab6401a19b648b5fa6.tar.gz
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). 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.
Diffstat (limited to 'mysql-test/t/explain.test')
-rw-r--r--mysql-test/t/explain.test20
1 files changed, 20 insertions, 0 deletions
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.