=== added file 'mysql-test/r/bug71720.result' --- mysql-test/r/bug71720.result 1970-01-01 00:00:00 +0000 +++ mysql-test/r/bug71720.result 2014-01-02 08:50:43 +0000 @@ -0,0 +1,8 @@ +SET debug="+d,ha_partition_end_bulk_insert_fail"; +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB PARTITION BY HASH (id) PARTITIONS 2; +INSERT INTO t2 SELECT * FROM t1; +ERROR HY000: Got error 1 from storage engine +DROP TABLE t1, t2; +SET debug=default; === added file 'mysql-test/t/bug71720.test' --- mysql-test/t/bug71720.test 1970-01-01 00:00:00 +0000 +++ mysql-test/t/bug71720.test 2014-01-02 08:50:24 +0000 @@ -0,0 +1,17 @@ +--source include/have_debug.inc +--source include/have_innodb.inc +--source include/have_partition.inc + +SET debug="+d,ha_partition_end_bulk_insert_fail"; + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3); + +CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB PARTITION BY HASH (id) PARTITIONS 2; + +--error ER_GET_ERRNO +INSERT INTO t2 SELECT * FROM t1; + +DROP TABLE t1, t2; + +SET debug=default; === modified file 'sql/ha_partition.cc' --- sql/ha_partition.cc 2013-10-30 23:22:43 +0000 +++ sql/ha_partition.cc 2014-01-02 08:22:44 +0000 @@ -4495,6 +4495,7 @@ error= tmp; } bitmap_clear_all(&m_bulk_insert_started); + DBUG_EXECUTE_IF("ha_partition_end_bulk_insert_fail", error= 1;); DBUG_RETURN(error); } === modified file 'sql/sql_class.h' --- sql/sql_class.h 2013-11-17 17:51:36 +0000 +++ sql/sql_class.h 2014-01-02 08:38:00 +0000 @@ -4388,7 +4388,7 @@ */ List *fields; protected: - /// ha_start_bulk_insert has been called. Never cleared. + /// ha_start_bulk_insert has been called. bool bulk_insert_started; public: ulonglong autoinc_value_of_last_inserted_row; // autogenerated or not === modified file 'sql/sql_insert.cc' --- sql/sql_insert.cc 2013-10-30 23:22:43 +0000 +++ sql/sql_insert.cc 2014-01-02 09:07:53 +0000 @@ -3775,6 +3775,7 @@ error= (bulk_insert_started ? table->file->ha_end_bulk_insert() : 0); + bulk_insert_started= false; if (!error && thd->is_error()) error= thd->get_stmt_da()->sql_errno();