Commit ed0ab76e authored by aelkin/elkin@koti.dsl.inet.fi's avatar aelkin/elkin@koti.dsl.inet.fi
Browse files

Bug #29136 erred multi-delete on trans table does not rollback the statement

similar to bug_27716, but it was stressed on in the synopsis on that there is another
side of the artifact affecting behaviour in transaction.

Fixed with deploying multi_delete::send_error() - otherwise never called - and refining its logic
to perform binlogging job if needed.

The changeset includes the following side effects:
- added tests to check bug_23333's scenarios on the mixture of tables for multi_update;
- fixes bug@30763 with two-liner patch and a test coinciding to one added for bug_23333.
parent 4c01449b
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -1119,6 +1119,19 @@ show master status /* there must be no UPDATE query event */;
File	Position	Binlog_Do_DB	Binlog_Ignore_DB
master-bin.000001	98		
drop table t1, t2;
drop table if exists t1, t2;
CREATE TABLE t1 (a int, PRIMARY KEY (a));
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
create trigger trg_del_t2 after  delete on t2 for each row
insert into t1 values (1);
insert into t1 values (1);
insert into t2 values (1),(2);
delete t2 from t2;
ERROR 23000: Duplicate entry '1' for key 1
select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
count(*)
2
drop table t1, t2;
create table t1 (a int, b int) engine=innodb;
insert into t1 values(20,null);
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
@@ -1792,10 +1805,10 @@ Variable_name Value
Innodb_page_size	16384
show status like "Innodb_rows_deleted";
Variable_name	Value
Innodb_rows_deleted	72
Innodb_rows_deleted	73
show status like "Innodb_rows_inserted";
Variable_name	Value
Innodb_rows_inserted	29732
Innodb_rows_inserted	29734
show status like "Innodb_rows_updated";
Variable_name	Value
Innodb_rows_updated	29532
+48 −4
Original line number Diff line number Diff line
@@ -393,7 +393,9 @@ count(*)
drop table t1,t2;
CREATE TABLE t1 (a int  NOT NULL auto_increment primary key) ENGINE=MyISAM;
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique);
CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique) ENGINE=MyISAM;
CREATE TABLE t4 (a int, PRIMARY KEY (a), b int unique) ENGINE=Innodb;
CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
insert into t2 values (1);
reset master;
insert into t2 values (bug27417(1));
@@ -427,6 +429,31 @@ master-bin.000001 190
select count(*) from t1 /* must be 2 */;
count(*)
2
delete from t3;
delete from t4;
insert into t3 values (1,1);
insert into t4 values (1,1),(2,2);
reset master;
UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
ERROR 23000: Duplicate entry '2' for key 1
show master status /* the offset must denote there is the query */;
File	Position	Binlog_Do_DB	Binlog_Ignore_DB
master-bin.000001	301		
select count(*) from t1 /* must be 4 */;
count(*)
4
delete from t1;
delete from t3;
delete from t4;
insert into t3 values (1,1),(2,2);
insert into t4 values (1,1),(2,2);
reset master;
UPDATE t3,t4 SET t3.a=t4.a + bug27417(1);
ERROR 23000: Duplicate entry '2' for key 1
select count(*) from t1 /* must be 1 */;
count(*)
1
drop table t4;
delete from t1;
delete from t2;
delete from t3;
@@ -443,6 +470,23 @@ master-bin.000001 246
select count(*) from t1 /* must be 1 */;
count(*)
1
drop trigger trg_del;
delete from t1;
delete from t2;
delete from t5;
create trigger trg_del_t2 after  delete on t2 for each row
insert into t1 values (1);
insert into t2 values (2),(3);
insert into t5 values (1),(2);
reset master;
delete t2.* from t2,t5 where t2.a=t5.a + 1;
ERROR 23000: Duplicate entry '1' for key 1
show master status /* the offset must denote there is the query */;
File	Position	Binlog_Do_DB	Binlog_Ignore_DB
master-bin.000001	274		
select count(*) from t1 /* must be 1 */;
count(*)
1
delete from t1;
create table t4 (a int default 0, b int primary key) engine=innodb;
insert into t4 values (0, 17);
@@ -458,7 +502,7 @@ count(*)
show master status /* the offset must denote there is the query */;
File	Position	Binlog_Do_DB	Binlog_Ignore_DB
master-bin.000001	376		
drop trigger trg_del;
drop table t1,t2,t3,t4;
drop trigger trg_del_t2;
drop table t1,t2,t3,t4,t5;
drop function bug27417;
end of tests
+22 −2
Original line number Diff line number Diff line
@@ -545,7 +545,7 @@ a b
4	4
show master status /* there must be the UPDATE query event */;
File	Position	Binlog_Do_DB	Binlog_Ignore_DB
master-bin.000001	189		
master-bin.000001	260		
delete from t1;
delete from t2;
insert into t1 values (1,2),(3,4),(4,4);
@@ -555,6 +555,26 @@ UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a;
ERROR 23000: Duplicate entry '4' for key 1
show master status /* there must be the UPDATE query event */;
File	Position	Binlog_Do_DB	Binlog_Ignore_DB
master-bin.000001	204		
master-bin.000001	275		
drop table t1, t2;
drop table if exists t1, t2, t3;
CREATE TABLE t1 (a int, PRIMARY KEY (a));
CREATE TABLE t2 (a int, PRIMARY KEY (a));
CREATE TABLE t3 (a int, PRIMARY KEY (a)) ENGINE=MyISAM;
create trigger trg_del_t3 before  delete on t3 for each row insert into t1 values (1);
insert into t2 values (1),(2);
insert into t3 values (1),(2);
reset master;
delete t3.* from t2,t3 where t2.a=t3.a;
ERROR 23000: Duplicate entry '1' for key 1
select count(*) from t1 /* must be 1 */;
count(*)
1
select count(*) from t3 /* must be 1 */;
count(*)
1
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Query	1	#	use `test`; delete t3.* from t2,t3 where t2.a=t3.a
drop table t1, t2, t3;
end of tests
+32 −0
Original line number Diff line number Diff line
@@ -792,6 +792,38 @@ show master status /* there must be no UPDATE query event */;
# cleanup bug#27716
drop table t1, t2;

#
# Bug #29136  	erred multi-delete on trans table does not rollback 
#

# prepare
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
CREATE TABLE t1 (a int, PRIMARY KEY (a));
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
create trigger trg_del_t2 after  delete on t2 for each row
       insert into t1 values (1);
insert into t1 values (1);
insert into t2 values (1),(2);


# exec cases A, B - see multi_update.test

# A. send_error() w/o send_eof() branch

--error ER_DUP_ENTRY
delete t2 from t2;

# check

select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;

# cleanup bug#29136

drop table t1, t2;


#
# Testing of IFNULL
#
+70 −6
Original line number Diff line number Diff line
@@ -385,13 +385,17 @@ drop table t1,t2;

#
# Bug#23333 using the patch (and the test) for bug#27471
#
# throughout the bug tests 
# t1 - non-trans side effects gatherer;
# t2 - transactional table;
#

CREATE TABLE t1 (a int  NOT NULL auto_increment primary key) ENGINE=MyISAM;
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique);
CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique) ENGINE=MyISAM;
CREATE TABLE t4 (a int, PRIMARY KEY (a), b int unique) ENGINE=Innodb;
CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;


#
@@ -434,7 +438,7 @@ CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique);
 select count(*) from t1 /* must be 2 */;

#
# UPDATE (multi-update see bug#27716)
# UPDATE inc multi-update
#

# prepare
@@ -450,9 +454,48 @@ CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique);
 show master status /* the offset must denote there is the query */;
 select count(*) from t1 /* must be 2 */;

## multi_update::send_eof() branch

# prepare
 delete from t3;
 delete from t4;
 insert into t3 values (1,1);
 insert into t4 values (1,1),(2,2);

 reset master;

# execute
 --error ER_DUP_ENTRY
 UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;

# check
 show master status /* the offset must denote there is the query */;
 select count(*) from t1 /* must be 4 */;

## send_error() branch of multi_update

# prepare
 delete from t1;
 delete from t3;
 delete from t4;
 insert into t3 values (1,1),(2,2);
 insert into t4 values (1,1),(2,2);

 reset master;

# execute
 --error ER_DUP_ENTRY
 UPDATE t3,t4 SET t3.a=t4.a + bug27417(1);

# check
 select count(*) from t1 /* must be 1 */;

# cleanup
 drop table t4;


#
# DELETE (for multi-delete see Bug #29136)
# DELETE incl multi-delete
#

# prepare
@@ -472,6 +515,27 @@ CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique);
 show master status /* the offset must denote there is the query */;
 select count(*) from t1 /* must be 1 */;

# cleanup
 drop trigger trg_del;

# prepare
 delete from t1;
 delete from t2;
 delete from t5;
 create trigger trg_del_t2 after  delete on t2 for each row
   insert into t1 values (1);
 insert into t2 values (2),(3);
 insert into t5 values (1),(2);
 reset master;

# execute
 --error ER_DUP_ENTRY
 delete t2.* from t2,t5 where t2.a=t5.a + 1;

# check
 show master status /* the offset must denote there is the query */;
 select count(*) from t1 /* must be 1 */;


#
# LOAD DATA
@@ -496,8 +560,8 @@ CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique);
#


drop trigger trg_del;
drop table t1,t2,t3,t4;
drop trigger trg_del_t2;
drop table t1,t2,t3,t4,t5;
drop function bug27417;


Loading