[Commits] Rev 3999: MDEV-5396 Assertion `Handlerton: r==0 ' failed (errno=0) on EXPLAIN with TokuDB tables in lp:~maria-captains/maria/5.5

Sergei Golubchik serg at mariadb.org
Wed Dec 11 18:11:33 EET 2013


At lp:~maria-captains/maria/5.5

------------------------------------------------------------
revno: 3999
revision-id: sergii at pisem.net-20131211161133-9vuld31jpw8guko6
parent: sergii at pisem.net-20131206142925-5efn10pjrsa7hn8p
fixes bug: https://mariadb.atlassian.net/browse/MDEV-5396
committer: Sergei Golubchik <sergii at pisem.net>
branch nick: 5.5
timestamp: Wed 2013-12-11 17:11:33 +0100
message:
  MDEV-5396 Assertion `Handlerton: r==0 ' failed (errno=0) on EXPLAIN with TokuDB tables
  
  Fix EXPLAIN and CREATE SELECT to join_free() (and, thus, ha_index_end())
  before ha_commit_trans().
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2013-11-19 12:16:25 +0000
+++ b/sql/sql_parse.cc	2013-12-11 16:11:33 +0000
@@ -4543,6 +4543,7 @@ mysql_execute_command(THD *thd)
   DBUG_ASSERT(!thd->in_active_multi_stmt_transaction() ||
                thd->in_multi_stmt_transaction_mode());
 
+  lex->unit.cleanup();
 
   if (! thd->in_sub_stmt)
   {
@@ -4575,7 +4576,6 @@ mysql_execute_command(THD *thd)
 #endif
   }
 
-  lex->unit.cleanup();
   /* Free tables */
   thd_proc_info(thd, "closing tables");
   close_thread_tables(thd);

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2013-11-25 06:10:36 +0000
+++ b/sql/sql_select.cc	2013-12-11 16:11:33 +0000
@@ -2258,6 +2258,7 @@ JOIN::exec()
         In this case JOIN::exec must check for JOIN::having_value, in the
         same way it checks for JOIN::cond_value.
       */
+      DBUG_ASSERT(error == 0);
       if (cond_value != Item::COND_FALSE &&
           having_value != Item::COND_FALSE &&
           (!conds || conds->val_int()) &&
@@ -2268,16 +2269,15 @@ JOIN::exec()
              procedure->end_of_records()) : result->send_data(fields_list)> 0))
 	  error= 1;
 	else
-	{
-	  error= (int) result->send_eof();
 	  send_records= ((select_options & OPTION_FOUND_ROWS) ? 1 :
                          thd->sent_row_count);
-	}
       }
       else
-      {
-	error=(int) result->send_eof();
         send_records= 0;
+      if (!error)
+      {
+        join_free();                      // Unlock all cursors
+        error= (int) result->send_eof();
       }
     }
     /* Single select (without union) always returns 0 or 1 row */

=== added file 'storage/tokudb/mysql-test/tokudb_mariadb/r/commit_5396.result'
--- a/storage/tokudb/mysql-test/tokudb_mariadb/r/commit_5396.result	1970-01-01 00:00:00 +0000
+++ b/storage/tokudb/mysql-test/tokudb_mariadb/r/commit_5396.result	2013-12-11 16:11:33 +0000
@@ -0,0 +1,16 @@
+CREATE TABLE t1 (a VARCHAR(8), INDEX(a)) ENGINE=TokuDB;
+INSERT INTO t1 VALUES ('foo'),('bar');
+CREATE TABLE t2 AS SELECT 'qux' IN (SELECT a FROM t1) AS f1;
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (3),(4);
+CREATE TABLE t3 (c VARCHAR(3), INDEX(c)) ENGINE=TokuDB;
+INSERT INTO t3 VALUES ('foo'),('bar');
+EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT b FROM t2) OR 'qux' IN (SELECT c FROM t3);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+3	SUBQUERY	t3	index_subquery	c	c	6	const	0	Using index; Using where
+2	MATERIALIZED	t2	ALL	NULL	NULL	NULL	NULL	2	
+DROP TABLE t1, t2, t3;

=== added file 'storage/tokudb/mysql-test/tokudb_mariadb/t/commit_5396.test'
--- a/storage/tokudb/mysql-test/tokudb_mariadb/t/commit_5396.test	1970-01-01 00:00:00 +0000
+++ b/storage/tokudb/mysql-test/tokudb_mariadb/t/commit_5396.test	2013-12-11 16:11:33 +0000
@@ -0,0 +1,18 @@
+#
+# MDEV-5396 Assertion `Handlerton: r==0 ' failed (errno=0) on EXPLAIN with TokuDB tables
+#
+
+CREATE TABLE t1 (a VARCHAR(8), INDEX(a)) ENGINE=TokuDB;
+INSERT INTO t1 VALUES ('foo'),('bar');
+CREATE TABLE t2 AS SELECT 'qux' IN (SELECT a FROM t1) AS f1;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (3),(4);
+CREATE TABLE t3 (c VARCHAR(3), INDEX(c)) ENGINE=TokuDB;
+INSERT INTO t3 VALUES ('foo'),('bar');
+EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT b FROM t2) OR 'qux' IN (SELECT c FROM t3);
+DROP TABLE t1, t2, t3;
+



More information about the commits mailing list