summaryrefslogtreecommitdiff
path: root/mysql-test/main/multi_update_binlog.test
blob: 16155aa1af375a641fb9d3154e326a25de40a89d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#
# Test of update statement that uses many tables.
#

source include/have_log_bin.inc;

CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");

#
# 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,
  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 ;

# as the test is about to see erroed queries in binlog
set @sav_binlog_format=  @@session.binlog_format;
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
UPDATE t2,t1 SET t2.a=t1.a+2;
# check
select * from t2 /* must be (3,1), (4,4) */;
source include/show_binlog_events.inc;

# 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
UPDATE t2,t1  SET t2.a=t2.b where t2.a=t1.a;
source include/show_binlog_events.inc;

# cleanup
drop table t1, t2;
set @@session.binlog_format= @sav_binlog_format;

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

# prepare
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;

# exec cases B, A - see innodb.test

# B. send_eof() and send_error() afterward

--error ER_DUP_ENTRY
delete t3.* from t2,t3 where t2.a=t3.a;

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

# cleanup
drop table t1, t2, t3;