List:Commits« Previous MessageNext Message »
From:guilhem Date:September 5 2006 4:52pm
Subject:bk commit into 5.0 tree (guilhem:1.2259) BUG#11151
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 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-09-05 16:52:05+02:00, guilhem@stripped +10 -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().
  The result is that LOAD DATA INFILE commits all uncommitted changes
  of NDB if this is an NDB table, its own changes if this is an NDB
  table, but does not affect other engines.
  Note: even though there is no "commit the full transaction at end"
  anymore, LOAD DATA INFILE stays disabled in routines (re-entrency
  problems per a comment of Pem).
  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-09-05 16:52:03+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-09-05 16:52:03+02:00,
guilhem@stripped +0 -0

  mysql-test/r/loaddata_autocom_innodb.result@stripped, 2006-09-05 16:52:03+02:00,
guilhem@stripped +21 -0
    result for InnoDB (no autocommit)

  mysql-test/r/loaddata_autocom_innodb.result@stripped, 2006-09-05 16:52:03+02:00,
guilhem@stripped +0 -0

  mysql-test/r/loaddata_autocom_ndb.result@stripped, 2006-09-05 16:52:03+02:00,
guilhem@stripped +23 -0
    result for NDB (autocommit)

  mysql-test/r/loaddata_autocom_ndb.result@stripped, 2006-09-05 16:52:03+02:00,
guilhem@stripped +0 -0

  mysql-test/r/rpl_ndb_innodb_trans.result@stripped, 2006-09-05 16:52:03+02:00,
guilhem@stripped +103 -0
    result for InnoDB+NDB transactions. Observe that when ROLLBACK
    cannot rollback the LOAD DATA INFILE in NDB it issues warning 1196
    as appropriate.

  mysql-test/r/rpl_ndb_innodb_trans.result@stripped, 2006-09-05 16:52:03+02:00,
guilhem@stripped +0 -0

  mysql-test/t/loaddata_autocom_innodb.test@stripped, 2006-09-05 16:52:03+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-09-05 16:52:03+02:00,
guilhem@stripped +0 -0

  mysql-test/t/loaddata_autocom_ndb.test@stripped, 2006-09-05 16:52:03+02:00,
guilhem@stripped +4 -0
    test that NDB does autocommit in LOAD DATA INFIL

  mysql-test/t/loaddata_autocom_ndb.test@stripped, 2006-09-05 16:52:03+02:00,
guilhem@stripped +0 -0

  mysql-test/t/rpl_ndb_innodb_trans-slave.opt@stripped, 2006-09-05 16:52:03+02:00,
guilhem@stripped +1 -0
    need to tell the slave to use innodb

  mysql-test/t/rpl_ndb_innodb_trans-slave.opt@stripped, 2006-09-05 16:52:03+02:00,
guilhem@stripped +0 -0

  mysql-test/t/rpl_ndb_innodb_trans.test@stripped, 2006-09-05 16:52:03+02:00,
guilhem@stripped +66 -0
    test of transactions mixing NDB and InnoDB. To see if ROLLBACK
    rolls back in both engines, with the exception of LOAD DATA INFILE
    which does not roll back NDB: we see that a LOAD DATA INFILE in NDB
    commits all what has been done in NDB so far, commits its changes,
    but does not commit in other engines.

  mysql-test/t/rpl_ndb_innodb_trans.test@stripped, 2006-09-05 16:52:03+02:00,
guilhem@stripped +0 -0

  sql/ha_ndbcluster.cc@stripped, 2006-09-05 16:52:03+02:00, guilhem@stripped +8 -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/sql_load.cc@stripped, 2006-09-05 16:52:03+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.0-maint

--- 1.97/sql/sql_load.cc	2006-09-05 16:52:25 +02:00
+++ 1.98/sql/sql_load.cc	2006-09-05 16:52:25 +02:00
@@ -147,10 +147,6 @@ bool mysql_load(THD *thd,sql_exchange *e
 	       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,
@@ -394,7 +390,6 @@ bool mysql_load(THD *thd,sql_exchange *e
     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/09/05 16:52:03
# 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/09/05 16:52:03
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/09/05 16:52:03
SET SESSION STORAGE_ENGINE = ndbcluster;
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;
Warnings:
Warning	1196	Some non-transactional changed tables couldn't be rolled back
select count(*) from t1;
count(*)
4
drop table t1;

--- New file ---
+++ mysql-test/r/rpl_ndb_innodb_trans.result	06/09/05 16:52:03
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1 (a int, unique(a)) engine=ndbcluster;
create table t2 (a int, unique(a)) engine=innodb;
begin;
insert into t1 values(1);
insert into t2 values(1);
rollback;
select count(*) from t1;
count(*)
0
select count(*) from t2;
count(*)
0
select count(*) from t1;
count(*)
0
select count(*) from t2;
count(*)
0
begin;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t2;
Warnings:
Warning	1262	Row 1 was truncated; it contained more data than there were input columns
Warning	1262	Row 2 was truncated; it contained more data than there were input columns
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
Warnings:
Warning	1262	Row 1 was truncated; it contained more data than there were input columns
Warning	1262	Row 2 was truncated; it contained more data than there were input columns
rollback;
Warnings:
Warning	1196	Some non-transactional changed tables couldn't be rolled back
select count(*) from t1;
count(*)
2
select count(*) from t2;
count(*)
0
select count(*) from t1;
count(*)
2
select count(*) from t2;
count(*)
0
delete from t1;
delete from t2;
begin;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t2;
Warnings:
Warning	1262	Row 1 was truncated; it contained more data than there were input columns
Warning	1262	Row 2 was truncated; it contained more data than there were input columns
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
Warnings:
Warning	1262	Row 1 was truncated; it contained more data than there were input columns
Warning	1262	Row 2 was truncated; it contained more data than there were input columns
rollback;
Warnings:
Warning	1196	Some non-transactional changed tables couldn't be rolled back
select count(*) from t1;
count(*)
2
select count(*) from t2;
count(*)
0
select count(*) from t1;
count(*)
2
select count(*) from t2;
count(*)
0
delete from t1;
delete from t2;
begin;
insert into t2 values(3),(4);
insert into t1 values(3),(4);
load data infile '../std_data_ln/rpl_loaddata.dat' into table t2;
Warnings:
Warning	1262	Row 1 was truncated; it contained more data than there were input columns
Warning	1262	Row 2 was truncated; it contained more data than there were input columns
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
Warnings:
Warning	1262	Row 1 was truncated; it contained more data than there were input columns
Warning	1262	Row 2 was truncated; it contained more data than there were input columns
rollback;
Warnings:
Warning	1196	Some non-transactional changed tables couldn't be rolled back
select count(*) from t1;
count(*)
4
select count(*) from t2;
count(*)
0
select count(*) from t1;
count(*)
4
select count(*) from t2;
count(*)
0
drop table t1,t2;

--- New file ---
+++ mysql-test/t/loaddata_autocom_innodb.test	06/09/05 16:52:03
--source include/have_innodb.inc
let $engine_type= InnoDB;

--source include/loaddata_autocom.inc

--- New file ---
+++ mysql-test/t/loaddata_autocom_ndb.test	06/09/05 16:52:03
--source include/have_ndb.inc
let $engine_type=ndbcluster;

--source include/loaddata_autocom.inc

--- New file ---
+++ mysql-test/t/rpl_ndb_innodb_trans-slave.opt	06/09/05 16:52:03
--innodb

--- New file ---
+++ mysql-test/t/rpl_ndb_innodb_trans.test	06/09/05 16:52:03
# Test of a transaction mixing the two engines

-- source include/have_ndb.inc
-- source include/have_innodb.inc
-- source include/master-slave.inc

create table t1 (a int, unique(a)) engine=ndbcluster;
create table t2 (a int, unique(a)) engine=innodb;


begin;
insert into t1 values(1);
insert into t2 values(1);
rollback;

select count(*) from t1;
select count(*) from t2;
sync_slave_with_master;
select count(*) from t1;
select count(*) from t2;
connection master;

begin;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t2;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
rollback;

select count(*) from t1;
select count(*) from t2;
sync_slave_with_master;
select count(*) from t1;
select count(*) from t2;
connection master;

delete from t1;
delete from t2;
begin;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t2;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
rollback;

select count(*) from t1;
select count(*) from t2;
sync_slave_with_master;
select count(*) from t1;
select count(*) from t2;
connection master;

delete from t1;
delete from t2;
begin;
insert into t2 values(3),(4);
insert into t1 values(3),(4);
load data infile '../std_data_ln/rpl_loaddata.dat' into table t2;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
rollback;

select count(*) from t1;
select count(*) from t2;
sync_slave_with_master;
select count(*) from t1;
select count(*) from t2;
connection master;

drop table t1,t2;
sync_slave_with_master;


--- 1.277/sql/ha_ndbcluster.cc	2006-09-05 16:52:25 +02:00
+++ 1.278/sql/ha_ndbcluster.cc	2006-09-05 16:52:25 +02:00
@@ -3526,7 +3526,14 @@ int ha_ndbcluster::external_lock(THD *th
   if (lock_type != F_UNLCK)
   {
     DBUG_PRINT("info", ("lock_type != F_UNLCK"));
-    if (!thd->transaction.on)
+    if (thd->lex->sql_command == SQLCOM_LOAD)
+    {
+      m_transaction_on= FALSE;
+      /* Would be simpler if has_transactions() didn't always say "yes" */
+      thd->options|= OPTION_STATUS_NO_TRANS_UPDATE;
+      thd->no_trans_update= TRUE;
+    }
+    else if (!thd->transaction.on)
       m_transaction_on= FALSE;
     else
       m_transaction_on= thd->variables.ndb_use_transactions;
Thread
bk commit into 5.0 tree (guilhem:1.2259) BUG#11151guilhem5 Sep