2
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
5
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
8
# Bug #25144 "replication / binlog with view breaks".
9
# Statements that used views didn't ensure that view were not modified
10
# during their execution. Indeed this led to incorrect binary log with
11
# statement based logging and as result to broken replication.
13
drop tables if exists t1, t2;
14
drop view if exists v1;
15
# Syncing slave with master and switching to connection 'slave'
16
# Switching to connection 'master'
17
create table t1 (i int);
18
create table t2 (i int);
19
create view v1 as select * from t1;
20
# First we try to concurrently execute statement that uses view
21
# and statement that drops it. We use "user" locks as means to
22
# suspend execution of first statement once it opens our view.
23
select get_lock("lock_bg25144", 1);
24
get_lock("lock_bg25144", 1)
26
# Switching to connection 'master1'
27
insert into v1 values (get_lock("lock_bg25144", 100));
28
# Switching to connection 'master2'
30
# Switching to connection 'master'
31
select release_lock("lock_bg25144");
32
release_lock("lock_bg25144")
34
# Switching to connection 'master1'
35
select release_lock("lock_bg25144");
36
release_lock("lock_bg25144")
38
# Switching to connection 'master2'
39
# Switching to connection 'master'
40
# Check that insertion through view did happen.
44
# Syncing slave with master and switching to connection 'slave'
45
# Check that slave was able to replicate this sequence
46
# which means that we got correct binlog order.
50
# Switching to connection 'master'
51
# Now we will repeat the test by trying concurrently execute
52
# statement that uses a view and statement that alters it.
53
create view v1 as select * from t1;
54
select get_lock("lock_bg25144", 1);
55
get_lock("lock_bg25144", 1)
57
# Switching to connection 'master1'
58
insert into v1 values (get_lock("lock_bg25144", 100));
59
# Switching to connection 'master2'
60
alter view v1 as select * from t2;
61
# Switching to connection 'master'
62
select release_lock("lock_bg25144");
63
release_lock("lock_bg25144")
65
# Switching to connection 'master1'
66
select release_lock("lock_bg25144");
67
release_lock("lock_bg25144")
69
# Switching to connection 'master2'
70
# Switching to connection 'master'
71
# Second insertion should go to t1 as well.
78
# Syncing slave with master and switching to connection 'slave'
79
# Now let us check that statements were logged in proper order
80
# So we have same result on slave.
87
# Switching to connection 'master'
90
# Syncing slave with master and switching to connection 'slave'