Bug #37460 Assertion failed: !table->file || table->file->inited == handler::NONE
Submitted: 17 Jun 2008 20:25 Modified: 8 Dec 2008 16:58
Reporter: Tim Clark Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1.24/5.0/6.0 OS:Any
Assigned to: Sergei Glukhov CPU Architecture:Any
Tags: handler, inited, rnd_init

[17 Jun 2008 20:25] Tim Clark
Description:
An assertion crashes the server when executing the following query with a debug build of the server.

CREATE TABLE t1 (id int);
CREATE TABLE t2 (id int, c int);
INSERT INTO t1 (id) VALUES (1);
INSERT INTO t2 (id) VALUES (1);
INSERT INTO t1 (id) VALUES (1);
INSERT INTO t2 (id) VALUES (1);
CREATE VIEW v1 AS
  SELECT t2.c FROM t1,t2
    WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
UPDATE v1 SET c=1;

Assertion failed: !table->file || table->file->inited == handler::NONE, file  /mysql-5.1.24-rc/sql/sql_base.cc, line 1426

This happens with both MyISAM and InnoDB storage engines.

How to repeat:
See description.

Suggested fix:
Fix the bug that is causing the assertion, or remove the assertion.
[17 Jun 2008 20:48] MySQL Verification Team
On Fedora Core 8 64-bit:

080617 17:43:54 [Note] Event Scheduler: Loaded 0 events
080617 17:43:54 [Note] /home/miguel/dbs/5.1/libexec/mysqld: ready for connections.
Version: '5.1.26-rc-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
[New Thread 1158191440 (LWP 2848)]
[Thread 1158191440 (LWP 2848) exited]
[New Thread 1158191440 (LWP 2850)]
mysqld: sql_base.cc:1342: bool close_thread_table(THD*, TABLE**): Assertion `!table->file || table->file->inited == handler::NONE' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread 1158191440 (LWP 2850)]
0x000000315b030ec5 in raise () from /lib64/libc.so.6
(gdb)
[17 Jun 2008 20:55] MySQL Verification Team
Thank you for the bug report. Verified as described on 5.0/6.0 versions too.
[5 Aug 2008 9:37] Sergei Glukhov
Can not repeat on 32bit FC8, Is it repeatable on 64bit box only?
[6 Aug 2008 16:46] 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/51028

2647 Sergey Glukhov	2008-08-06
      Bug#37460 Assertion failed: !table->file || table->file->inited == handler::NONE
      The problem:
      subselect_single_select_engine on optimization stage is executed and
      sets the 'executed' variable value to 'true'.
      Because of that we call cleanup_all_joins() with 'true' argument in JOIN::join_free
      and upper join sets lower join field 'table' to 0.
      Next subquery calls do not execute 'file->ha_index_or_rnd_end()
      (see  JOIN::cleanup func). It leads to assertion failure.
      
      The fix: Save join->table value for subquery and restore it on each execution.
[7 Aug 2008 8:36] 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/51076

2647 Sergey Glukhov	2008-08-07
      The Bug#37460 Assertion failed: !table->file || table->file->inited ==handler::NONE(2nd version)
      The problem:
      subselect_single_select_engine on optimization stage is executed and
      sets the 'executed' variable value to 'true'.
      Because of that we call cleanup_all_joins() with 'true' argument in JOIN::join_free
      and upper join sets lower join field 'table' to 0.
      Next subquery calls do not execute 'file->ha_index_or_rnd_end()
      (see  JOIN::cleanup func). It leads to assertion failure.
      The fix:
      Set 'table' to 0 only for the current join and
      do not touch underlying join 'table' values.
[26 Aug 2008 11:25] 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/52543

2647 Sergey Glukhov	2008-08-26
      The Bug#37460 Assertion failed: !table->file || table->file->inited==handler::NONE(3rd version)
      The problem:
      subselect_single_select_engine on optimization stage is executed and
      sets the 'executed' variable value to 'true'.
      Because of that we call cleanup_all_joins() with 'true' argument in JOIN::join_free
      and upper join sets lower join field 'table' to 0.
      Next subquery calls do not execute 'file->ha_index_or_rnd_end()
      (see  JOIN::cleanup func). It leads to assertion failure.
      The fix:
      Call cleanup_all_joins() with 'false' argument.
[28 Aug 2008 12: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/52838

2647 Sergey Glukhov	2008-08-28
      The Bug#37460 Assertion failed: !table->file || table->file->inited==handler::NONE
      The problem:
      subselect_single_select_engine on optimization stage is executed and
      sets the 'executed' variable value to 'true'.
      Because of that we call cleanup_all_joins() with 'true' argument in JOIN::join_free
      and upper join sets lower join field 'table' to 0.
      Next subquery calls do not execute 'file->ha_index_or_rnd_end()
      (see  JOIN::cleanup func). It leads to assertion failure.
      The fix:
      Call cleanup_all_joins() with 'false' argument.
[18 Sep 2008 15:53] 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/54317

2682 Sergey Glukhov	2008-09-18
      Bug #37460 Assertion failed: !table->file || table->file->inited == handler::NONE
      The problem:
      At the end of execution top level join execution
      we cleanup this join with true argument.
      It leads to underlying join cleanup(subquery) with true argument too and
      sets join->table to 0 for underlying join.
      Next subquery calls do not execute 'file->ha_index_or_rnd_end()
      (see  JOIN::cleanup func). It leads to assertion failure.
      The fix:
      Call cleanup_all_joins() for with 'true' argument only if
      subquery->is_uncacheable is false.
[8 Oct 2008 13:16] 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/55764

2702 Sergey Glukhov	2008-10-08
      Bug#37460 Assertion failed: !table->file || table->file->inited == handler::NONE
      enable uncacheable flag if we update a view with check option
      and check option has a subselect, the reason is that check option
      can be evaluated after top level join is freed.
      It leads to assertion failure(JOIN::join_free)
[13 Oct 2008 9:30] 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/56098

2702 Sergey Glukhov	2008-10-13
      Bug#37460 Assertion failed: !table->file || table->file->inited == handler::NONE
      enable uncacheable flag if we update a view with check option
      and check option has a subselect, otherwise, the check option
      can be evaluated after the subselect was freed as independent
      (See full_local in JOIN::join_free())
[17 Oct 2008 8:43] 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/56443

2702 Sergey Glukhov	2008-10-17
      Bug#37460 Assertion failed: !table->file || table->file->inited == handler::NONE
      enable uncacheable flag if we update a view with check option
      and check option has a subselect, otherwise, the check option
      can be evaluated after the subselect was freed as independent
      (See full_local in JOIN::join_free())
[27 Nov 2008 13:59] 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/60045

2716 Sergey Glukhov	2008-11-27
      Bug#37460 Assertion failed: !table->file || table->file->inited == handler::NONE
      enable uncacheable flag if we update a view with check option
      and check option has a subselect, otherwise, the check option
      can be evaluated after the subselect was freed as independent
      (See full_local in JOIN::join_free())
[2 Dec 2008 13:01] Bugs System
Pushed into 5.0.74  (revid:sergey.glukhov@sun.com-20081127135734-rtgiriffo30w7s3e) (version source revid:matthias.leich@sun.com-20081128184708-uyjg2dfrj2va5o3d) (pib:5)
[3 Dec 2008 20:27] Paul DuBois
Noted in 5.0.74 changelog.

Updating a view with a subquery in the CHECK option could cause an
assertion failure.

Resetting report to NDI pending push in to 5.1.x, 6.0.x
[8 Dec 2008 10:22] Bugs System
Pushed into 5.1.31  (revid:sergey.glukhov@sun.com-20081127135734-rtgiriffo30w7s3e) (version source revid:ingo.struewing@sun.com-20081127152850-iwzy1vh9gqpg3s3x) (pib:5)
[8 Dec 2008 11:32] Bugs System
Pushed into 6.0.9-alpha  (revid:sergey.glukhov@sun.com-20081127135734-rtgiriffo30w7s3e) (version source revid:ingo.struewing@sun.com-20081127214152-x1avx1b1cyfshx1a) (pib:5)
[8 Dec 2008 16:58] Paul DuBois
Noted in 5.1.31, 6.0.9 changelogs.
[19 Jan 2009 11:33] Bugs System
Pushed into 5.1.31-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090119095303-uwwvxiibtr38djii) (version source revid:tomas.ulin@sun.com-20090108105244-8opp3i85jw0uj5ib) (merge vers: 5.1.31-ndb-6.2.17) (pib:6)
[19 Jan 2009 13:09] Bugs System
Pushed into 5.1.31-ndb-6.3.21 (revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (version source revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (merge vers: 5.1.31-ndb-6.3.21) (pib:6)
[19 Jan 2009 16:15] Bugs System
Pushed into 5.1.31-ndb-6.4.1 (revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (version source revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (merge vers: 5.1.31-ndb-6.4.1) (pib:6)