From: Date: October 6 2008 1:01pm Subject: bzr commit into mysql-5.1 branch (tomas.ulin:2687) Bug#39872 List-Archive: http://lists.mysql.com/commits/55436 X-Bug: 39872 Message-Id: <20081006110116.5A3B6440D3@linux.local> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/tomas/mysql_src/cge-6.2-global-schema-lock/ 2687 Tomas Ulin 2008-10-06 bug #39872 - explain causes segv modified: mysql-test/suite/ndb/r/ndb_basic.result mysql-test/suite/ndb/t/ndb_basic.test sql/ha_ndbcluster.cc === modified file 'mysql-test/suite/ndb/r/ndb_basic.result' --- a/mysql-test/suite/ndb/r/ndb_basic.result 2008-04-09 19:43:15 +0000 +++ b/mysql-test/suite/ndb/r/ndb_basic.result 2008-10-06 11:01:04 +0000 @@ -923,4 +923,24 @@ create table if not exists t1 (a int not create table t2 like t1; rename table t1 to t10, t2 to t20; drop table t10,t20; +# +# bug #39872 - explain causes segv +# (ndb_index_stat_enable=1 must be set to trigger bug) +# +set ndb_index_stat_enable=1; +CREATE TABLE `t1` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (`id`) +) ENGINE=ndbcluster DEFAULT CHARSET=utf8; +CREATE TABLE `t2` ( +`id` int(11) NOT NULL, +`obj_id` int(11) DEFAULT NULL, +UNIQUE KEY `id` (`id`), +KEY `obj_id` (`obj_id`) +) ENGINE=ndbcluster DEFAULT CHARSET=utf8; +# here we used to segv +explain SELECT t1.id FROM t1 INNER JOIN t2 ON t1.id = t2.id WHERE t2.obj_id=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +drop table t1, t2; End of 5.1 tests === modified file 'mysql-test/suite/ndb/t/ndb_basic.test' --- a/mysql-test/suite/ndb/t/ndb_basic.test 2007-11-08 09:24:31 +0000 +++ b/mysql-test/suite/ndb/t/ndb_basic.test 2008-10-06 11:01:04 +0000 @@ -858,4 +858,23 @@ create table t2 like t1; rename table t1 to t10, t2 to t20; drop table t10,t20; +--echo # +--echo # bug #39872 - explain causes segv +--echo # (ndb_index_stat_enable=1 must be set to trigger bug) +--echo # +set ndb_index_stat_enable=1; +CREATE TABLE `t1` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`) +) ENGINE=ndbcluster DEFAULT CHARSET=utf8; +CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `obj_id` int(11) DEFAULT NULL, + UNIQUE KEY `id` (`id`), + KEY `obj_id` (`obj_id`) +) ENGINE=ndbcluster DEFAULT CHARSET=utf8; +--echo # here we used to segv +explain SELECT t1.id FROM t1 INNER JOIN t2 ON t1.id = t2.id WHERE t2.obj_id=1; +drop table t1, t2; + --echo End of 5.1 tests === modified file 'sql/ha_ndbcluster.cc' --- a/sql/ha_ndbcluster.cc 2008-10-02 15:53:21 +0000 +++ b/sql/ha_ndbcluster.cc 2008-10-06 11:01:04 +0000 @@ -3811,6 +3811,14 @@ int ha_ndbcluster::rnd_init(bool scan) int ha_ndbcluster::close_scan() { + /* + workaround for bug #39872 - explain causes segv + - rnd_end/close_scan is called on unlocked table + - should be fixed in server code, but this will + not be done until 6.0 as it is too intrusive + */ + if (m_thd_ndb == NULL) + return 0; NdbTransaction *trans= m_thd_ndb->trans; int error; DBUG_ENTER("close_scan");