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().
This commit is contained in:
Sergei Golubchik 2013-12-17 17:26:54 +01:00
parent dc407270a1
commit 50808b30d2
4 changed files with 40 additions and 6 deletions

View File

@ -4543,6 +4543,7 @@ finish:
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 @@ finish:
#endif
}
lex->unit.cleanup();
/* Free tables */
thd_proc_info(thd, "closing tables");
close_thread_tables(thd);

View File

@ -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 */

View File

@ -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;

View File

@ -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;