From e0a48a8c40e735d4a10ae0ac11a5f2757b50dbca Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 28 Mar 2006 17:15:45 -0500 Subject: [PATCH] Bug#11151: LOAD DATA INFILE commits transaction in 5.0 No longer create or commit transactions within the loading of files. mysql-test/r/loaddata.result: Add test result. mysql-test/t/loaddata.test: Add test case. sql/sql_load.cc: Loading data from a table should neither create new transactions nor destroy (by committing or rolling-back) existing transactions. --- mysql-test/r/loaddata.result | 15 +++++++++++++++ mysql-test/t/loaddata.test | 22 ++++++++++++++++++++++ sql/sql_load.cc | 7 +------ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index 17e1966dbc9..9d3c5e5d506 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -139,3 +139,18 @@ a b c 10 NULL Ten 15 NULL Fifteen drop table t1, t2; +create table bug11151 (a int, b int) engine=InnoDB; +start transaction; +insert into bug11151 values (0, 0); +rollback; +select a, b from bug11151; +a b +delete from bug11151; +start transaction; +insert into bug11151 values (42, 0); +load data infile '../std_data_ln/loaddata5.dat' into table bug11151 fields terminated by '' enclosed by '' (a, b); +insert into bug11151 values (42, 99); +rollback; +select a, b from bug11151; +a b +drop table bug11151; diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 27c8005ca0c..ab7d44d1fe1 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -113,4 +113,26 @@ select * from t1; # cleanup drop table t1, t2; + + +# +# Bug#11151: LOAD DATA INFILE commits transaction in 5.0 +# +create table bug11151 (a int, b int) engine=InnoDB; + +start transaction; +insert into bug11151 values (0, 0); +rollback; +select a, b from bug11151; +delete from bug11151; + +start transaction; +insert into bug11151 values (42, 0); +load data infile '../std_data_ln/loaddata5.dat' into table bug11151 fields terminated by '' enclosed by '' (a, b); +insert into bug11151 values (42, 99); +rollback; +select a, b from bug11151; + +drop table bug11151; + # End of 5.0 tests diff --git a/sql/sql_load.cc b/sql/sql_load.cc index cc724c102a4..bc45ae9e334 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -381,7 +381,7 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->next_number_field=0; } - ha_enable_transaction(thd, TRUE); + if (file >= 0) my_close(file,MYF(0)); free_blobs(table); /* if pack_blob was used */ @@ -396,9 +396,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()) ; @@ -465,8 +462,6 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ignore, transactional_table); } #endif /*!EMBEDDED_LIBRARY*/ - if (transactional_table) - error=ha_autocommit_or_rollback(thd,error); err: if (thd->lock)