From e6718df34558482ff3e6efc9318c5e0f75624b61 Mon Sep 17 00:00:00 2001 From: "cbell/Chuck@mysql_cab." <> Date: Tue, 8 May 2007 10:17:00 -0400 Subject: [PATCH] BUG#17233 : LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed This patch corrects a bug involving a LOAD DATA INFILE operation on a transactional table. It corrects a problem in the error handler by moving the transactional table check and autocommit_or_rollback operation to the end of the error handler. The problem was an assert was thrown after the operation completed. The assert found a non-sunk event in the transaction cache. The events in the transaction cache were added after commit_or_rollack and thereafter nothing removed them. An additional test case was added to detect this condition. --- mysql-test/extra/rpl_tests/rpl_loaddata.test | 12 ++++++++++++ mysql-test/r/rpl_loaddata.result | 4 ++++ sql/sql_load.cc | 6 +++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_loaddata.test b/mysql-test/extra/rpl_tests/rpl_loaddata.test index 111b66ff7f..dea83f6589 100644 --- a/mysql-test/extra/rpl_tests/rpl_loaddata.test +++ b/mysql-test/extra/rpl_tests/rpl_loaddata.test @@ -15,6 +15,7 @@ # Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986) -- source include/master-slave.inc +source include/have_innodb.inc; connection slave; reset master; @@ -156,4 +157,15 @@ drop table t2; connection master; drop table t2; drop table t1; + +# BUG#17233 LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed +CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; + +--error ER_DUP_ENTRY_WITH_KEY_NAME +LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1; + +--disable warnings +DROP TABLE IF EXISTS t1; +--enable warnings + # End of 4.1 tests diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index cabc20b705..680796a4be 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -86,3 +86,7 @@ ERROR 23000: Duplicate entry '2003-03-22' for key 'day' drop table t2; drop table t2; drop table t1; +CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; +LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1; +ERROR 23000: Duplicate entry 'Aarhus' for key 'PRIMARY' +DROP TABLE IF EXISTS t1; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 71cc4c0507..40962d82bc 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -413,9 +413,6 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, if (error) { - if (transactional_table) - ha_autocommit_or_rollback(thd,error); - if (read_file_from_client) while (!read_info.next_line()) ; @@ -463,6 +460,9 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, } } #endif /*!EMBEDDED_LIBRARY*/ + if (transactional_table) + ha_autocommit_or_rollback(thd,error); + error= -1; // Error on read goto err; } -- 2.30.9