summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Nozdrin <alik@sun.com>2010-01-28 00:32:29 +0300
committerAlexander Nozdrin <alik@sun.com>2010-01-28 00:32:29 +0300
commitf928e0b03d7b235abc42fc3710aae97515203c68 (patch)
tree87afeb670875ae174fc0d56a4066bd140a34b786
parent547269cf380a2ae0decd4990f2de2c5cfad1433a (diff)
parentd2f61748cd0a63d0c9df989d92cb36fc1c7583c5 (diff)
downloadmariadb-git-f928e0b03d7b235abc42fc3710aae97515203c68.tar.gz
Auto-merge from mysql-trunk-merge.
-rw-r--r--mysql-test/r/subselect.result13
-rw-r--r--mysql-test/t/subselect.test15
-rw-r--r--sql/sql_select.cc1
3 files changed, 29 insertions, 0 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 615ba21c811..cd7af9651b9 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -4873,4 +4873,17 @@ SELECT 1 FROM t1 GROUP BY
1
1
DROP TABLE t1;
+#
+# Bug #49512 : subquery with aggregate function crash
+# subselect_single_select_engine::exec()
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES();
+# should not crash
+SELECT 1 FROM t1 WHERE a <> SOME
+(
+SELECT MAX((SELECT a FROM t1 LIMIT 1)) AS d
+FROM t1,t1 a
+);
+1
+DROP TABLE t1;
End of 5.1 tests.
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 8366b6b890d..bb4e7d623f8 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -3805,4 +3805,19 @@ SELECT 1 FROM t1 GROUP BY
(SELECT LAST_INSERT_ID() FROM t1 ORDER BY MIN(a) ASC LIMIT 1);
DROP TABLE t1;
+--echo #
+--echo # Bug #49512 : subquery with aggregate function crash
+--echo # subselect_single_select_engine::exec()
+
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES();
+
+--echo # should not crash
+SELECT 1 FROM t1 WHERE a <> SOME
+(
+ SELECT MAX((SELECT a FROM t1 LIMIT 1)) AS d
+ FROM t1,t1 a
+);
+DROP TABLE t1;
+
--echo End of 5.1 tests.
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 1f8bb11967a..5cef405fe53 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -945,6 +945,7 @@ JOIN::optimize()
DBUG_PRINT("info",("Select tables optimized away"));
zero_result_cause= "Select tables optimized away";
tables_list= 0; // All tables resolved
+ const_tables= tables;
/*
Extract all table-independent conditions and replace the WHERE
clause with them. All other conditions were computed by opt_sum_query