From: Date: August 29 2006 11:20am Subject: bk commit into 5.1 tree (guilhem:1.2286) BUG#11151 List-Archive: http://lists.mysql.com/commits/10988 X-Bug: 11151 Message-Id: <200608290920.k7T9KW6r007881@gbichot3.local> Below is the list of changes that have just been committed into a local 5.1 repository of guilhem. When guilhem does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2006-08-29 11:20:26+02:00, guilhem@stripped +8 -0 Fix for BUG#11151 "LOAD DATA INFILE commits transaction in 5.0". In 5.0 we made LOAD DATA INFILE autocommit in all engines, while only NDB wanted that. Users and trainers complained that it affected InnoDB and was a change compared to 4.1 where only NDB autocommitted. To revert to the behaviour of 4.1, we move the autocommit logic out of mysql_load() into ha_ndbcluster::external_lock(). As there is no "commit the full transaction at end" anymore, LOAD DATA INFILE can be allowed in stored functions. This patch is for discussion; I don't even know if it should go into 5.0 (as it is a behaviour change in a GA) or in 5.1. Note: ha_ndbcluster::has_transactions() does not give reliable results because it says "yes" even if transactions are disabled in this engine... mysql-test/include/loaddata_autocom.inc@stripped, 2006-08-29 11:20:22+02:00, guilhem@stripped +21 -0 test for engines to see if they autocommit or not in LOAD DATA INFILE mysql-test/include/loaddata_autocom.inc@stripped, 2006-08-29 11:20:22+02:00, guilhem@stripped +0 -0 mysql-test/r/loaddata_autocom_innodb.result@stripped, 2006-08-29 11:20:22+02:00, guilhem@stripped +21 -0 result for InnoDB (no autocommit) mysql-test/r/loaddata_autocom_innodb.result@stripped, 2006-08-29 11:20:22+02:00, guilhem@stripped +0 -0 mysql-test/r/loaddata_autocom_ndb.result@stripped, 2006-08-29 11:20:22+02:00, guilhem@stripped +25 -0 result for NDB (autocommit) mysql-test/r/loaddata_autocom_ndb.result@stripped, 2006-08-29 11:20:22+02:00, guilhem@stripped +0 -0 mysql-test/t/loaddata_autocom_innodb.test@stripped, 2006-08-29 11:20:22+02:00, guilhem@stripped +4 -0 test that InnoDB does not autocommit in LOAD DATA INFILE. mysql-test/t/loaddata_autocom_innodb.test@stripped, 2006-08-29 11:20:22+02:00, guilhem@stripped +0 -0 mysql-test/t/loaddata_autocom_ndb.test@stripped, 2006-08-29 11:20:22+02:00, guilhem@stripped +4 -0 test that NDB does autocommit in LOAD DATA INFILE mysql-test/t/loaddata_autocom_ndb.test@stripped, 2006-08-29 11:20:22+02:00, guilhem@stripped +0 -0 sql/ha_ndbcluster.cc@stripped, 2006-08-29 11:20:21+02:00, guilhem@stripped +1 -1 NDB wants to do autocommit if this is LOAD DATA INFILE. For this to not affect all other engines, we move the logic inside ha_ndbcluster. sql/sp_head.cc@stripped, 2006-08-29 11:20:21+02:00, guilhem@stripped +0 -1 LOAD DATA INFILEdoes not do a transaction commit at its end anymore, so can be allowed in stored functions. sql/sql_load.cc@stripped, 2006-08-29 11:20:22+02:00, guilhem@stripped +0 -5 This ha_enable_transaction() in mysql_load() forced an autocommit in all engines, while only NDB wants to do that. So we move the logic inside ha_ndbcluster.cc. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: guilhem # Host: gbichot3.local # Root: /home/mysql_src/mysql-5.1-2 --- 1.103/sql/sql_load.cc 2006-08-29 11:20:33 +02:00 +++ 1.104/sql/sql_load.cc 2006-08-29 11:20:33 +02:00 @@ -146,10 +146,6 @@ MYF(0)); DBUG_RETURN(TRUE); } - /* - This needs to be done before external_lock - */ - ha_enable_transaction(thd, FALSE); if (open_and_lock_tables(thd, table_list)) DBUG_RETURN(TRUE); if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context, @@ -392,7 +388,6 @@ table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); 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 */ --- New file --- +++ mysql-test/include/loaddata_autocom.inc 06/08/29 11:20:22 # Test if the engine does autocommit in LOAD DATA INFILE, or not # (NDB wants to do, others don't). eval SET SESSION STORAGE_ENGINE = $engine_type; --disable_warnings drop table if exists t1; --enable_warnings create table t1 (a text, b text); start transaction; load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; commit; select count(*) from t1; truncate table t1; start transaction; load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; rollback; select count(*) from t1; drop table t1; --- New file --- +++ mysql-test/r/loaddata_autocom_innodb.result 06/08/29 11:20:22 SET SESSION STORAGE_ENGINE = InnoDB; drop table if exists t1; create table t1 (a text, b text); start transaction; load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; Warnings: Warning 1261 Row 3 doesn't contain data for all columns commit; select count(*) from t1; count(*) 4 truncate table t1; start transaction; load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; Warnings: Warning 1261 Row 3 doesn't contain data for all columns rollback; select count(*) from t1; count(*) 0 drop table t1; --- New file --- +++ mysql-test/r/loaddata_autocom_ndb.result 06/08/29 11:20:22 SET SESSION STORAGE_ENGINE = ndbcluster; drop table if exists t1; create table t1 (a text, b text); Warnings: Error 1465 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' start transaction; load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; Warnings: Warning 1261 Row 3 doesn't contain data for all columns commit; select count(*) from t1; count(*) 4 truncate table t1; Warnings: Error 1465 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' start transaction; load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; Warnings: Warning 1261 Row 3 doesn't contain data for all columns rollback; select count(*) from t1; count(*) 4 drop table t1; --- New file --- +++ mysql-test/t/loaddata_autocom_innodb.test 06/08/29 11:20:22 --source include/have_innodb.inc let $engine_type= InnoDB; --source include/loaddata_autocom.inc --- New file --- +++ mysql-test/t/loaddata_autocom_ndb.test 06/08/29 11:20:22 --source include/have_ndb.inc let $engine_type=ndbcluster; --source include/loaddata_autocom.inc --- 1.352/sql/ha_ndbcluster.cc 2006-08-29 11:20:33 +02:00 +++ 1.353/sql/ha_ndbcluster.cc 2006-08-29 11:20:33 +02:00 @@ -3975,7 +3975,7 @@ if (lock_type != F_UNLCK) { DBUG_PRINT("info", ("lock_type != F_UNLCK")); - if (!thd->transaction.on) + if (!thd->transaction.on || (thd->lex->sql_command == SQLCOM_LOAD)) m_transaction_on= FALSE; else m_transaction_on= thd->variables.ndb_use_transactions; --- 1.233/sql/sp_head.cc 2006-08-29 11:20:33 +02:00 +++ 1.234/sql/sp_head.cc 2006-08-29 11:20:33 +02:00 @@ -252,7 +252,6 @@ case SQLCOM_TRUNCATE: case SQLCOM_COMMIT: case SQLCOM_ROLLBACK: - case SQLCOM_LOAD: case SQLCOM_LOAD_MASTER_DATA: case SQLCOM_LOCK_TABLES: case SQLCOM_CREATE_PROCEDURE: