Commit 50808b30 authored by Sergei Golubchik's avatar Sergei Golubchik

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().
parent dc407270
...@@ -4543,6 +4543,7 @@ case SQLCOM_PREPARE: ...@@ -4543,6 +4543,7 @@ case SQLCOM_PREPARE:
DBUG_ASSERT(!thd->in_active_multi_stmt_transaction() || DBUG_ASSERT(!thd->in_active_multi_stmt_transaction() ||
thd->in_multi_stmt_transaction_mode()); thd->in_multi_stmt_transaction_mode());
lex->unit.cleanup();
if (! thd->in_sub_stmt) if (! thd->in_sub_stmt)
{ {
...@@ -4575,7 +4576,6 @@ case SQLCOM_PREPARE: ...@@ -4575,7 +4576,6 @@ case SQLCOM_PREPARE:
#endif #endif
} }
lex->unit.cleanup();
/* Free tables */ /* Free tables */
thd_proc_info(thd, "closing tables"); thd_proc_info(thd, "closing tables");
close_thread_tables(thd); close_thread_tables(thd);
......
...@@ -2258,6 +2258,7 @@ JOIN::exec() ...@@ -2258,6 +2258,7 @@ JOIN::exec()
In this case JOIN::exec must check for JOIN::having_value, in the In this case JOIN::exec must check for JOIN::having_value, in the
same way it checks for JOIN::cond_value. same way it checks for JOIN::cond_value.
*/ */
DBUG_ASSERT(error == 0);
if (cond_value != Item::COND_FALSE && if (cond_value != Item::COND_FALSE &&
having_value != Item::COND_FALSE && having_value != Item::COND_FALSE &&
(!conds || conds->val_int()) && (!conds || conds->val_int()) &&
...@@ -2268,16 +2269,15 @@ JOIN::exec() ...@@ -2268,16 +2269,15 @@ JOIN::exec()
procedure->end_of_records()) : result->send_data(fields_list)> 0)) procedure->end_of_records()) : result->send_data(fields_list)> 0))
error= 1; error= 1;
else else
{
error= (int) result->send_eof();
send_records= ((select_options & OPTION_FOUND_ROWS) ? 1 : send_records= ((select_options & OPTION_FOUND_ROWS) ? 1 :
thd->sent_row_count); thd->sent_row_count);
} }
}
else else
{
error=(int) result->send_eof();
send_records= 0; 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 */ /* Single select (without union) always returns 0 or 1 row */
......
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;
#
# 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;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment