Bug #35550 | Semi-join subquery in ON clause and no WHERE crashes the server | ||
---|---|---|---|
Submitted: | 25 Mar 2008 12:40 | Modified: | 23 Nov 2010 3:34 |
Reporter: | Sergey Petrunya | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 6.0-bk | OS: | Any |
Assigned to: | Sergey Petrunya | CPU Architecture: | Any |
[25 Mar 2008 12:40]
Sergey Petrunya
[25 Mar 2008 13:02]
MySQL Verification Team
Thank you for the bug report. I tried with latest source tree and could not repeat. I tested on FC 6.0 32-bit which one have you tested?. [miguel@amanhecer dbs]$ 5.1/bin/mysqladmin -uroot shutdown [miguel@amanhecer dbs]$ 6.0/bin/mysql -uroot test Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 6.0.5-alpha-debug Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create table t0 (a int); Query OK, 0 rows affected (0.04 sec) mysql> insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); Query OK, 10 rows affected (0.00 sec) Records: 10 Duplicates: 0 Warnings: 0 mysql> mysql> create table t1(a int, b int); Query OK, 0 rows affected (0.01 sec) mysql> insert into t1 values (0,0),(1,1),(2,2); Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> create table t2 as select * from t1; Query OK, 3 rows affected (0.02 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> mysql> create table t11(a int, b int); Query OK, 0 rows affected (0.00 sec) mysql> mysql> create table t10 (pk int, a int, primary key(pk)); Query OK, 0 rows affected (0.01 sec) mysql> insert into t10 select a,a from t0; Query OK, 10 rows affected (0.00 sec) Records: 10 Duplicates: 0 Warnings: 0 mysql> create table t12 like t10; Query OK, 0 rows affected (0.00 sec) mysql> insert into t12 select * from t10; Query OK, 10 rows affected (0.00 sec) Records: 10 Duplicates: 0 Warnings: 0 mysql> mysql> explain extended select * from t1 where a in (select t10.pk from t10, t12 where -> t12.pk=t10.a); +----+-------------+-------+--------+---------------+---------+---------+------------+------+----------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+--------+---------------+---------+---------+------------+------+----------+-------------+ | 1 | PRIMARY | t1 | ALL | NULL | NULL | NULL | NULL | 3 | 100.00 | | | 1 | PRIMARY | t10 | eq_ref | PRIMARY | PRIMARY | 4 | test.t1.a | 1 | 100.00 | | | 1 | PRIMARY | t12 | eq_ref | PRIMARY | PRIMARY | 4 | test.t10.a | 1 | 100.00 | Using index | +----+-------------+-------+--------+---------------+---------+---------+------------+------+----------+-------------+ 3 rows in set, 1 warning (0.01 sec) Thanks in advance.
[25 Mar 2008 18:47]
Sergey Petrunya
Sorry, pasted the wrong query. Instead of explain extended select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); it should be explain extended select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10));
[1 May 2008 3:54]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/46254 ChangeSet@1.2628, 2008-05-01 07:53:36+04:00, sergefp@mysql.com +7 -0 BUG#35550 "Semi-join subquery in ON clause and no WHERE crashes the server" The bug was a bunch of interrelated issues caused by failure to do the below: - Let Item_in_subselect store the clause (WHERE/ON) where it is located, so we can walk that clause and remove the subselect predicate from there if we convert it to a semi-join. - Let pull_out_semijoin_tables() use statement's MEM_ROOT when operating on TABLE_LIST structures, as the changes it makes should remain there for subsequent statement re-executions. - Let make_join_statistics() do constant table processing for tables that are within a semi-join nest (but not within an outer join nest).
[28 May 2008 10:01]
Bugs System
Pushed into 6.0.6-alpha
[30 May 2008 18:38]
Paul DuBois
Noted in 6.0.6 changelog. A semi-join subquery in the ON clause in the absence of a WHERE clause caused a server crash.
[16 Aug 2010 6:41]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100816062819-bluwgdq8q4xysmlg) (version source revid:alik@sun.com-20100816062612-enatdwnv809iw3s9) (pib:20)
[13 Nov 2010 16:20]
Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (merge vers: 5.6.99-m4) (pib:21)
[23 Nov 2010 3:34]
Paul DuBois
Bug does not appear in any released 5.6.x version. No 5.6.1 changelog entry needed.