diff options
author | Georgi Kodinov <joro@sun.com> | 2009-12-23 17:11:22 +0200 |
---|---|---|
committer | Georgi Kodinov <joro@sun.com> | 2009-12-23 17:11:22 +0200 |
commit | d2f61748cd0a63d0c9df989d92cb36fc1c7583c5 (patch) | |
tree | 6ce703361253e286fb526ef5923033cf754fb8f5 /mysql-test/t/subselect.test | |
parent | 2fa49930cab5e070b5abaadbc2ab2b0899bc41b5 (diff) | |
download | mariadb-git-d2f61748cd0a63d0c9df989d92cb36fc1c7583c5.tar.gz |
Bug #49512 : subquery with aggregate function crash
subselect_single_select_engine::exec()
When a subquery doesn't need to be evaluated because
it returns only aggregate functions and these aggregates
can be calculated from the metadata about the table it
was not updating all the relevant members of the JOIN
structure to reflect that this is a constant query.
This caused problems to the enclosing subquery
('<> SOME' in the test case above) trying to read some
data about the tables.
Fixed by setting const_tables to the number of tables
when the SELECT is optimized away.
Diffstat (limited to 'mysql-test/t/subselect.test')
-rw-r--r-- | mysql-test/t/subselect.test | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index a4314c45cba..027578fc6bd 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -3585,4 +3585,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. |