mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
Bug #27716 multi-update did partially and has not binlogged
manual merge with 5.0: automatic merge went incorrectly; fixing tests in rbr mode.
This commit is contained in:
parent
798b38a447
commit
f544286789
7 changed files with 119 additions and 17 deletions
|
@ -1086,6 +1086,39 @@ n d
|
|||
1 30
|
||||
2 20
|
||||
drop table t1,t2;
|
||||
CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL auto_increment,
|
||||
`b` int(11) default NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
|
||||
CREATE TABLE `t2` (
|
||||
`a` int(11) NOT NULL auto_increment,
|
||||
`b` int(11) default NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=INNODB DEFAULT CHARSET=latin1 ;
|
||||
insert into t1 values (1,1),(2,2);
|
||||
insert into t2 values (1,1),(4,4);
|
||||
reset master;
|
||||
UPDATE t2,t1 SET t2.a=t1.a+2;
|
||||
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
|
||||
select * from t2 /* must be (3,1), (4,4) */;
|
||||
a b
|
||||
1 1
|
||||
4 4
|
||||
show master status /* there must no UPDATE in binlog */;
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 106
|
||||
delete from t1;
|
||||
delete from t2;
|
||||
insert into t1 values (1,2),(3,4),(4,4);
|
||||
insert into t2 values (1,2),(3,4),(4,4);
|
||||
reset master;
|
||||
UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a;
|
||||
ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
|
||||
show master status /* there must be no UPDATE query event */;
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 106
|
||||
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
|
||||
|
@ -1775,13 +1808,13 @@ Variable_name Value
|
|||
Innodb_page_size 16384
|
||||
show status like "Innodb_rows_deleted";
|
||||
Variable_name Value
|
||||
Innodb_rows_deleted 2070
|
||||
Innodb_rows_deleted 2072
|
||||
show status like "Innodb_rows_inserted";
|
||||
Variable_name Value
|
||||
Innodb_rows_inserted 3083
|
||||
Innodb_rows_inserted 3088
|
||||
show status like "Innodb_rows_updated";
|
||||
Variable_name Value
|
||||
Innodb_rows_updated 886
|
||||
Innodb_rows_updated 888
|
||||
show status like "Innodb_row_lock_waits";
|
||||
Variable_name Value
|
||||
Innodb_row_lock_waits 0
|
||||
|
|
|
@ -614,27 +614,28 @@ CREATE TABLE `t2` (
|
|||
`b` int(11) default NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
|
||||
set @@session.binlog_format= mixed;
|
||||
insert into t1 values (1,1),(2,2);
|
||||
insert into t2 values (1,1),(4,4);
|
||||
reset master;
|
||||
UPDATE t2,t1 SET t2.a=t1.a+2;
|
||||
ERROR 23000: Duplicate entry '3' for key 1
|
||||
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
|
||||
select * from t2 /* must be (3,1), (4,4) */;
|
||||
a b
|
||||
3 1
|
||||
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 197
|
||||
delete from t1;
|
||||
delete from t2;
|
||||
insert into t1 values (1,2),(3,4),(4,4);
|
||||
insert into t2 values (1,2),(3,4),(4,4);
|
||||
reset master;
|
||||
UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a;
|
||||
ERROR 23000: Duplicate entry '4' for key 1
|
||||
ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
|
||||
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 212
|
||||
drop table t1, t2;
|
||||
end of tests
|
||||
|
|
|
@ -218,3 +218,27 @@ k HEX(a) HEX(b)
|
|||
2 0 8
|
||||
**** On Master ****
|
||||
DROP TABLE IF EXISTS t1_myisam, t1_innodb, t2_myisam, t2_innodb;
|
||||
drop table if exists t1, t2;
|
||||
CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL auto_increment,
|
||||
`b` int(11) default NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
|
||||
CREATE TABLE `t2` (
|
||||
`a` int(11) NOT NULL auto_increment,
|
||||
`b` int(11) default NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
|
||||
insert into t1 values (1,1),(2,2);
|
||||
insert into t2 values (1,1),(4,4);
|
||||
UPDATE t2,t1 SET t2.a=t1.a+2;
|
||||
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
|
||||
select * from t2 /* must be (3,1), (4,4) */;
|
||||
a b
|
||||
3 1
|
||||
4 4
|
||||
select * from t2 /* must be (3,1), (4,4) */;
|
||||
a b
|
||||
3 1
|
||||
4 4
|
||||
drop table t1,t2;
|
||||
|
|
|
@ -774,7 +774,7 @@ CREATE TABLE `t2` (
|
|||
insert into t1 values (1,1),(2,2);
|
||||
insert into t2 values (1,1),(4,4);
|
||||
reset master;
|
||||
--error ER_DUP_ENTRY
|
||||
--error ER_DUP_ENTRY_WITH_KEY_NAME
|
||||
UPDATE t2,t1 SET t2.a=t1.a+2;
|
||||
# check
|
||||
select * from t2 /* must be (3,1), (4,4) */;
|
||||
|
@ -786,7 +786,7 @@ delete from t2;
|
|||
insert into t1 values (1,2),(3,4),(4,4);
|
||||
insert into t2 values (1,2),(3,4),(4,4);
|
||||
reset master;
|
||||
--error ER_DUP_ENTRY
|
||||
--error ER_DUP_ENTRY_WITH_KEY_NAME
|
||||
UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a;
|
||||
show master status /* there must be no UPDATE query event */;
|
||||
|
||||
|
|
|
@ -570,10 +570,10 @@ delete t1.*,t2.* from t1,t2 where t1.i2=t2.id;
|
|||
select * from t1 order by i1;
|
||||
select * from t2 order by id;
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
# Bug#27716 multi-update did partially and has not binlogged
|
||||
#
|
||||
|
||||
CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL auto_increment,
|
||||
`b` int(11) default NULL,
|
||||
|
@ -586,23 +586,28 @@ CREATE TABLE `t2` (
|
|||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
|
||||
|
||||
# A. testing multi_update::send_eof() execution branch
|
||||
# as the test is about to see erroed queries in binlog
|
||||
set @@session.binlog_format= mixed;
|
||||
|
||||
|
||||
# A. testing multi_update::send_error() effective update
|
||||
insert into t1 values (1,1),(2,2);
|
||||
insert into t2 values (1,1),(4,4);
|
||||
reset master;
|
||||
--error ER_DUP_ENTRY
|
||||
--error ER_DUP_ENTRY_WITH_KEY_NAME
|
||||
UPDATE t2,t1 SET t2.a=t1.a+2;
|
||||
# check
|
||||
select * from t2 /* must be (3,1), (4,4) */;
|
||||
show master status /* there must be the UPDATE query event */;
|
||||
|
||||
# B. testing multi_update::send_error() execution branch
|
||||
# B. testing multi_update::send_error() ineffective update
|
||||
# (as there is a policy described at mysql_update() still go to binlog)
|
||||
delete from t1;
|
||||
delete from t2;
|
||||
insert into t1 values (1,2),(3,4),(4,4);
|
||||
insert into t2 values (1,2),(3,4),(4,4);
|
||||
reset master;
|
||||
--error ER_DUP_ENTRY
|
||||
--error ER_DUP_ENTRY_WITH_KEY_NAME
|
||||
UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a;
|
||||
show master status /* there must be the UPDATE query event */;
|
||||
|
||||
|
|
|
@ -184,3 +184,42 @@ SELECT k, HEX(a),HEX(b) FROM t2_innodb;
|
|||
connection master;
|
||||
DROP TABLE IF EXISTS t1_myisam, t1_innodb, t2_myisam, t2_innodb;
|
||||
sync_slave_with_master;
|
||||
|
||||
#
|
||||
# Bug#27716 multi-update did partially and has not binlogged
|
||||
#
|
||||
|
||||
connection master;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2;
|
||||
--enable_warnings
|
||||
CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL auto_increment,
|
||||
`b` int(11) default NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
|
||||
|
||||
CREATE TABLE `t2` (
|
||||
`a` int(11) NOT NULL auto_increment,
|
||||
`b` int(11) default NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
|
||||
|
||||
# testing multi_update::send_error() effective update
|
||||
insert into t1 values (1,1),(2,2);
|
||||
insert into t2 values (1,1),(4,4);
|
||||
|
||||
connection master;
|
||||
--error ER_DUP_ENTRY_WITH_KEY_NAME
|
||||
UPDATE t2,t1 SET t2.a=t1.a+2;
|
||||
select * from t2 /* must be (3,1), (4,4) */;
|
||||
sync_slave_with_master;
|
||||
|
||||
connection slave;
|
||||
select * from t2 /* must be (3,1), (4,4) */;
|
||||
|
||||
connection master;
|
||||
drop table t1,t2;
|
||||
|
||||
sync_slave_with_master;
|
||||
|
|
|
@ -1589,9 +1589,9 @@ void multi_update::send_error(uint errcode,const char *err)
|
|||
*/
|
||||
if (mysql_bin_log.is_open())
|
||||
{
|
||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||
transactional_tables, FALSE);
|
||||
mysql_bin_log.write(&qinfo);
|
||||
thd->binlog_query(THD::ROW_QUERY_TYPE,
|
||||
thd->query, thd->query_length,
|
||||
transactional_tables, FALSE);
|
||||
}
|
||||
if (!trans_safe)
|
||||
thd->no_trans_update.all= TRUE;
|
||||
|
|
Loading…
Reference in a new issue