diff options
author | unknown <gshchepa/uchum@host.loc> | 2008-04-23 02:27:23 +0500 |
---|---|---|
committer | unknown <gshchepa/uchum@host.loc> | 2008-04-23 02:27:23 +0500 |
commit | 73f7de59c2739a66dcf1a7d1d4c89a1e19fddcd1 (patch) | |
tree | aabf58dec7cdd1b951b6c9d378efa2e54c68ac84 /mysql-test/t/subselect3.test | |
parent | 1c1f0a62e1f68fd39ae7440042699faaffaaf7fe (diff) | |
download | mariadb-git-73f7de59c2739a66dcf1a7d1d4c89a1e19fddcd1.tar.gz |
Fixed bug#36005: server crashes inside NOT IN clause subquery with
impossible WHERE/HAVING clause
(subselect_single_select_engine::exec).
Allocation and initialization of joined table list t1, t2... of
subqueries like:
NOT IN (SELECT ... FROM t1,t2,... WHERE 0)
is optimized out, however server tries to traverse this list.
mysql-test/r/subselect3.result:
Added test case for bug#36005.
mysql-test/t/subselect3.test:
Added test case for bug#36005.
sql/sql_select.cc:
Fixed bug#36005.
1. JOIN::prepare initializes JOIN::table counter (actually a size
of the JOIN::join_tab array) and sets it to a number of joined tables.
2. The make_join_statistics function (when called from JOIN::optimize)
allocates and fills the JOIN::join_tab array.
However, when optimizing subselect has impossible (definite false)
WHERE or HAVING clause, optimizer skips call to make_join_statistics
and leaves JOIN::join_tab == NULL.
3. subselect_single_select_engine::exec does traversal of the JOIN::join_tab
array and the server dies because array is not allocated but array
counter is greater than 0.
The JOIN::optimize method has been modified to reset the JOIN::table
counter to 0 in cause of impossible WHERE/HAVING clause.
Diffstat (limited to 'mysql-test/t/subselect3.test')
-rw-r--r-- | mysql-test/t/subselect3.test | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test index cfbde8c29cd..d7bb1f7186a 100644 --- a/mysql-test/t/subselect3.test +++ b/mysql-test/t/subselect3.test @@ -605,4 +605,17 @@ SELECT ROW(1, 2) IN (SELECT t1.a, 2 FROM t2) FROM t1 GROUP BY t1.a; DROP TABLE t1, t2; +# +# Bug #36005: crash in subselect with single row +# (subselect_single_select_engine::exec) +# + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 SELECT * FROM t1; + +SELECT 1 FROM t1 WHERE t1.a NOT IN (SELECT 1 FROM t1, t2 WHERE 0); + +DROP TABLE t1, t2; + --echo End of 5.0 tests |