From 41208f6e5b53db6fda2c9b6a6cfd6158c85e46b8 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 21 Jan 2014 14:02:56 +0400 Subject: [PATCH] MDEV-5426: Assertion `toku_ft_needed_unlocked(src_h)' failed (errno=11) ... - the problem was caused by EXPLAIN INSERT SELECT. For that statement, the code would call select_insert::prepare2(), which would call handler->ha_start_bulk_insert(). The corresponding handler->end_bulk_insert() call is made from select_insert::send_eof or select_insert::abort_result_set which are never called for EXPLAIN INSERT SELECT. - Fixed by re-using approach of mysql-5.6: don't call ha_start_bulk_insert() if we are in EXPLAIN. --- sql/sql_insert.cc | 3 ++- .../tokudb/mysql-test/tokudb_mariadb/r/mdev5426.result | 6 ++++++ .../tokudb/mysql-test/tokudb_mariadb/t/mdev5426.test | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 storage/tokudb/mysql-test/tokudb_mariadb/r/mdev5426.result create mode 100644 storage/tokudb/mysql-test/tokudb_mariadb/t/mdev5426.test diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 0acb7e747ad..b764263265e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3555,7 +3555,8 @@ int select_insert::prepare2(void) { DBUG_ENTER("select_insert::prepare2"); if (thd->lex->current_select->options & OPTION_BUFFER_RESULT && - thd->locked_tables_mode <= LTM_LOCK_TABLES) + thd->locked_tables_mode <= LTM_LOCK_TABLES && + !thd->lex->describe) table->file->ha_start_bulk_insert((ha_rows) 0); DBUG_RETURN(0); } diff --git a/storage/tokudb/mysql-test/tokudb_mariadb/r/mdev5426.result b/storage/tokudb/mysql-test/tokudb_mariadb/r/mdev5426.result new file mode 100644 index 00000000000..086c4f4cc18 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_mariadb/r/mdev5426.result @@ -0,0 +1,6 @@ +CREATE TABLE t1 (i INT) ENGINE=TokuDB; +EXPLAIN INSERT INTO t1 SELECT * FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using temporary +INSERT INTO t1 SELECT * FROM t1; +DROP TABLE t1; diff --git a/storage/tokudb/mysql-test/tokudb_mariadb/t/mdev5426.test b/storage/tokudb/mysql-test/tokudb_mariadb/t/mdev5426.test new file mode 100644 index 00000000000..b16e81353ff --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_mariadb/t/mdev5426.test @@ -0,0 +1,10 @@ + +CREATE TABLE t1 (i INT) ENGINE=TokuDB; +EXPLAIN INSERT INTO t1 SELECT * FROM t1; + +--connect con1,localhost,root,,test +INSERT INTO t1 SELECT * FROM t1; + +--connection default +--disconnect con1 +DROP TABLE t1;