mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
a0b7b2426f
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... sql/ha_ndbcluster.cc: 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: 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. mysql-test/include/loaddata_autocom.inc: test for engines to see if they autocommit or not in LOAD DATA INFILE mysql-test/r/loaddata_autocom_innodb.result: result for InnoDB (no autocommit) mysql-test/r/loaddata_autocom_ndb.result: result for NDB (autocommit) mysql-test/r/rpl_ndb_innodb_trans.result: 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/t/loaddata_autocom_innodb.test: test that InnoDB does not autocommit in LOAD DATA INFILE. mysql-test/t/loaddata_autocom_ndb.test: test that NDB does autocommit in LOAD DATA INFIL mysql-test/t/rpl_ndb_innodb_trans-slave.opt: need to tell the slave to use innodb mysql-test/t/rpl_ndb_innodb_trans.test: 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.
103 lines
2.8 KiB
Text
103 lines
2.8 KiB
Text
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;
|