Debian Codegraph @

mysql-test/suite/perfschema/include/binlog_edge_common.inc

raw
1 # Test replication, when using special non-replicated tables.
2 #
3 # This test involve special statements that use non-replicated tables.
4 # Changes affecting non replicated tables are never written to the binlog.
5 # Executing these statements may or may not work, as the statements involved
6 # are edge cases.
7 # In MIXED or ROW binlog format, execution should succeed,
8 # and only partial data (the rows affecting replicated tables only)
9 # should be written to the binlog.
10 # In STATEMENT binlog format, execution should
11 # raise a warning (ER_BINLOG_UNSAFE_STATEMENT) if a non replicated table is
12 # only read from, or fail with an error (ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES)
13 # if a non replicated table is written to.
14 #
15 # SHOW ERRORS will print in the
16 # test .result file the exact outcome.
17
18 RESET MASTER;
19
20 --disable_warnings
21 drop database if exists my_replicated_db;
22 --enable_warnings
23
24 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
25
26 create database my_replicated_db;
27
28 create table my_replicated_db.my_tx_table(a bigint) engine = innodb;
29 create table my_replicated_db.my_bh_table(a bigint) engine = blackhole;
30
31 use test;
32 drop table if exists marker_start;
33
34 use my_replicated_db;
35
36 insert into my_tx_table(a)
37 values (1000), (2000), (3000);
38
39 insert into my_bh_table(a)
40 values (1000), (2000), (3000);
41
42 use test;
43 drop table if exists marker_insert_select;
44
45 use my_replicated_db;
46
47 # Note:
48 # The queries used here do not make any sense (no semantic).
49 # What this test is interrested in, is check the behavior
50 # when replicating queries that mix both:
51 # - non replicated tables
52 # - replicated tables
53
54 insert into my_tx_table(a)
55 select thread_id from performance_schema.threads;
56
57 insert into my_bh_table(a)
58 select thread_id from performance_schema.threads;
59
60 # For the information_schema,
61 # no error is enforced yet.
62 # Documenting the current behavior
63
64 insert into my_tx_table(a)
65 select id from information_schema.processlist;
66
67 insert into my_bh_table(a)
68 select id from information_schema.processlist;
69
70 insert into my_tx_table(a)
71 select thread_id from mysql.general_log;
72
73 insert into my_bh_table(a)
74 select thread_id from mysql.general_log;
75
76 insert into my_tx_table(a)
77 select thread_id from mysql.slow_log;
78
79 insert into my_bh_table(a)
80 select thread_id from mysql.slow_log;
81
82 insert into my_tx_table(a)
83 select Relay_log_pos from mysql.slave_relay_log_info;
84
85 insert into my_bh_table(a)
86 select Relay_log_pos from mysql.slave_relay_log_info;
87
88 insert into my_tx_table(a)
89 select Master_log_pos from mysql.slave_master_info;
90
91 insert into my_bh_table(a)
92 select Master_log_pos from mysql.slave_master_info;
93
94 insert into my_tx_table(a)
95 select Relay_log_pos from mysql.slave_worker_info;
96
97 insert into my_bh_table(a)
98 select Relay_log_pos from mysql.slave_worker_info;
99
100 use test;
101 drop table if exists marker_multi_update;
102
103 use my_replicated_db;
104
105 --error 0, ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
106 update my_tx_table, performance_schema.setup_instruments
107 set my_tx_table.a = my_tx_table.a + 1,
108 performance_schema.setup_instruments.timed= 'NO';
109
110 --error 0, ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
111 update my_bh_table, performance_schema.setup_instruments
112 set my_bh_table.a = my_bh_table.a + 1,
113 performance_schema.setup_instruments.timed= 'NO';
114
115 use test;
116 drop table if exists marker_multi_delete;
117
118 use my_replicated_db;
119
120 insert into performance_schema.setup_actors
121 values ('FOO', 'FOO', 'FOO', 'YES', 'YES');
122
123 --error 0, ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
124 delete my_tx_table.*, performance_schema.setup_actors.*
125 from my_tx_table, performance_schema.setup_actors
126 where my_tx_table.a != 1000
127 or performance_schema.setup_actors.role='FOO';
128
129 insert into performance_schema.setup_actors
130 values ('BAZ', 'BAZ', 'BAZ', 'YES', 'YES');
131
132 --error 0, ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
133 delete my_bh_table.*, performance_schema.setup_actors.*
134 from my_bh_table, performance_schema.setup_actors
135 where my_bh_table.a != 1000
136 or performance_schema.setup_actors.role='BAZ';
137
138 use test;
139 drop table if exists marker_end;
140
141 drop database my_replicated_db;
142
143 --source include/show_binlog_events.inc
144
145 # Restore performance_schema.setup_actors, damaged by this script
146
147 truncate table performance_schema.setup_actors;
148 insert into performance_schema.setup_actors values ('%', '%', '%', 'YES', 'YES');
149