Bug #46791 | Assertion failed:(table->key_read==0),function unknown function,file sql_base.cc | ||
---|---|---|---|
Submitted: | 18 Aug 2009 17:40 | Modified: | 18 Dec 2009 13:18 |
Reporter: | Patrick Crews | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.0.82, 5.1, 5.4/6.0 | OS: | Any |
Assigned to: | Georgi Kodinov | CPU Architecture: | Any |
Tags: | crashing bug, subqueries |
[18 Aug 2009 17:40]
Patrick Crews
[18 Aug 2009 17:41]
Patrick Crews
Full crash output
Attachment: bug46791_crash_output.txt (text/plain), 15.68 KiB.
[18 Aug 2009 17:41]
Patrick Crews
MTR test case to repeat the crash
Attachment: bug46791_test.txt (text/plain), 19.78 KiB.
[18 Aug 2009 17:42]
Patrick Crews
NOTE - Will post a simplified test case when it is available. Something here is complicating query simplification tools from running smoothly.
[18 Aug 2009 20:38]
Patrick Crews
Have attached a simplified version of the test case to the bug. It includes this query and the original, longer query. Please note, that I think this is failing because of the following part: IN ( SELECT `varchar_key` , MIN( SUBQUERY1_t1 .`varchar_key` ) FROM A ) We have already defined SUBQUERY1_t1 in a separate, earlier subquery. SELECT table2 .`pk` FROM D table1 STRAIGHT_JOIN ( B table2 JOIN CC table3 ON table3 .`varchar_key` ) ON table3 .`varchar_key` WHERE ( SELECT SUBQUERY1_t1 .`varchar_key` FROM D SUBQUERY1_t1 JOIN B ON ( 'a' , 'v' ) IN ( SELECT `varchar_key` , MIN( SUBQUERY1_t1 .`varchar_key` ) FROM A ) ) OR table2 .`pk` ORDER BY table1 .`pk` ;
[18 Aug 2009 20:39]
Patrick Crews
Full MTR test case with simplified and original queries
Attachment: bug46791_full_test.txt (text/plain), 39.58 KiB.
[19 Aug 2009 5:36]
MySQL Verification Team
this crashed my 5.0.82-debug and 5.1.37-debug: drop table if exists `a`,`d`; create table `a` (`pk` int) engine=myisam; create table `d` (`pk` int,`b` int,key(`pk`)) engine=myisam; insert into d values (1,1),(2,2); select count(`pk`) as `field1` from `d` where not exists ( select 1 from `d`,`a` where 1 = (select min(`d`.`b`) from `a`) ) order by `pk`, `field1`;
[27 Aug 2009 9:56]
Georgi Kodinov
Shane's test case haven't crashed for me with the latest 5.1-bugteam.
[3 Sep 2009 15:15]
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/82338 2804 Georgi Kodinov 2009-09-03 Bug #46791: Assertion failed:(table->key_read==0),function unknown function,file sql_base.cc When uncacheable queries are written to a temp table the optimizer must preserve the original JOIN structure, because it is re-using the JOIN structure to read from the resulting temporary table. This was done only for uncacheable sub-queries. But top level queries can also benefit from this mechanism, specially if they're using index access and need a reset. Fixed by not limiting the saving of JOIN structure to subqueries exclusively. Added a new test file to extend the existing (large) subquery.test.
[8 Sep 2009 9:27]
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/82650 2809 Georgi Kodinov 2009-09-03 Bug #46791: Assertion failed:(table->key_read==0),function unknown function,file sql_base.cc When uncacheable queries are written to a temp table the optimizer must preserve the original JOIN structure, because it is re-using the JOIN structure to read from the resulting temporary table. This was done only for uncacheable sub-queries. But top level queries can also benefit from this mechanism, specially if they're using index access and need a reset. Fixed by not limiting the saving of JOIN structure to subqueries exclusively. Added a new test file to extend the existing (large) subquery.test.
[14 Sep 2009 16:04]
Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090914155317-m1g9wodmndzdj4l1) (version source revid:alik@sun.com-20090914155317-m1g9wodmndzdj4l1) (merge vers: 5.4.4-alpha) (pib:11)
[6 Oct 2009 8:57]
Bugs System
Pushed into 5.0.87 (revid:joro@sun.com-20091006073202-rj21ggvo2gw032ks) (version source revid:kristofer.pettersson@sun.com-20090929151855-gvpblm4dnnubypdv) (merge vers: 5.0.87) (pib:11)
[6 Oct 2009 9:00]
Bugs System
Pushed into 5.1.40 (revid:joro@sun.com-20091006073316-lea2cpijh9r6on7c) (version source revid:ingo.struewing@sun.com-20090916070128-6053el2ucp5z7pyn) (merge vers: 5.1.39) (pib:11)
[6 Oct 2009 23:08]
Paul DuBois
Noted in 5.0.87, 5.1.40, 5.4.3 changelogs. The server crashed when re-using outer column references in correlated subqueries when the enclosing query used a temp table.
[18 Dec 2009 10:32]
Bugs System
Pushed into 5.1.41-ndb-7.1.0 (revid:jonas@mysql.com-20091218102229-64tk47xonu3dv6r6) (version source revid:jonas@mysql.com-20091218095730-26gwjidfsdw45dto) (merge vers: 5.1.41-ndb-7.1.0) (pib:15)
[18 Dec 2009 10:48]
Bugs System
Pushed into 5.1.41-ndb-6.2.19 (revid:jonas@mysql.com-20091218100224-vtzr0fahhsuhjsmt) (version source revid:jonas@mysql.com-20091217101452-qwzyaig50w74xmye) (merge vers: 5.1.41-ndb-6.2.19) (pib:15)
[18 Dec 2009 11:03]
Bugs System
Pushed into 5.1.41-ndb-6.3.31 (revid:jonas@mysql.com-20091218100616-75d9tek96o6ob6k0) (version source revid:jonas@mysql.com-20091217154335-290no45qdins5bwo) (merge vers: 5.1.41-ndb-6.3.31) (pib:15)
[18 Dec 2009 11:17]
Bugs System
Pushed into 5.1.41-ndb-7.0.11 (revid:jonas@mysql.com-20091218101303-ga32mrnr15jsa606) (version source revid:jonas@mysql.com-20091218064304-ezreonykd9f4kelk) (merge vers: 5.1.41-ndb-7.0.11) (pib:15)
[18 Dec 2009 13:18]
MC Brown
Already noted in earlier changelogs.