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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
|
--echo
--echo
connection master;
if ($is_temporary)
{
--let $_temporary=TEMPORARY
}
CREATE TABLE t2(c1 INT, c2 char(10));
INSERT INTO t2 VALUES(1, 'abc'), (2, 'abc');
--echo
--echo # The original query should be binlogged if the table does not exist.
--echo # ------------------------------------------------------------------
--echo
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
eval CREATE $_temporary TABLE IF NOT EXISTS t1 (c1 INT , c2 INT, c3 char(10), c4 INT KEY)
SELECT 'abc' AS c3, 1 AS c4;
source include/show_binlog_events.inc;
--sync_slave_with_master
--connection master
if (!$is_temporary)
{
--let $diff_tables= master:t1,slave:t1
--source include/diff_tables.inc
}
--echo
--echo # The statement should be binlogged as two events. one is
--echo # 'CREATE $_temporary TABLE IF NOT EXISTS ..', another one is
--echo # 'INSERT ... SELECT'.
--echo # ------------------------------------------------------------------
--echo
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
eval CREATE $_temporary TABLE IF NOT EXISTS t1
SELECT 'abc', 2;
source include/show_binlog_events.inc;
--sync_slave_with_master
--connection master
if (!$is_temporary)
{
--let $diff_tables= master:t1,slave:t1
--source include/diff_tables.inc
}
--echo
--echo # Verify if it can be binlogged with right database name when the table
--echo # is not in the default database
--echo
--disable_warnings
DROP DATABASE IF EXISTS db1;
--enable_warnings
CREATE DATABASE db1;
USE db1;
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
eval CREATE $_temporary TABLE IF NOT EXISTS test.t1
SELECT 'abc', 20;
source include/show_binlog_events.inc;
--sync_slave_with_master
--connection master
if (!$is_temporary)
{
--let $diff_tables= master:test.t1,slave:test.t1
--source include/diff_tables.inc
}
USE test;
DROP DATABASE db1;
--echo
--echo # It should be binlogged as 'REPLACE ... SELECT'
--echo # if the original statement has option REPLACE
--echo
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
eval CREATE $_temporary TABLE IF NOT EXISTS t1
REPLACE SELECT '123', 2;
source include/show_binlog_events.inc;
--sync_slave_with_master
--connection master
if (!$is_temporary)
{
--let $diff_tables= master:t1,slave:t1
--source include/diff_tables.inc
}
--echo
--echo # It should be binlogged as 'INSERT IGNORE... SELECT'
--echo # if the original statement has option IGNORE
--echo
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
eval CREATE $_temporary TABLE IF NOT EXISTS t1
IGNORE SELECT '123', 2;
source include/show_binlog_events.inc;
--sync_slave_with_master
--connection master
if (!$is_temporary)
{
--let $diff_tables= master:t1,slave:t1
--source include/diff_tables.inc
}
--echo
--echo # Nothing should be binlogged if error happens and no any row is inserted
--echo
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
--error ER_DUP_ENTRY
eval CREATE $_temporary TABLE IF NOT EXISTS t1
SELECT '123', 2;
source include/show_binlog_events.inc;
--sync_slave_with_master
--connection master
if (!$is_temporary)
{
--let $diff_tables= master:t1,slave:t1
--source include/diff_tables.inc
}
--echo
--echo # Verify it can binlog well when there are some braces('(')
--echo
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
eval CREATE $_temporary TABLE IF NOT EXISTS t1
(SELECT '123', 3) UNION (SELECT '123', 4);
eval CREATE $_temporary TABLE IF NOT EXISTS t1
REPLACE (SELECT 'abc', 3) UNION (SELECT 'abc', 4);
eval CREATE $_temporary TABLE IF NOT EXISTS t1
IGNORE (SELECT '123', 3) UNION (SELECT '123', 4);
source include/show_binlog_events.inc;
--sync_slave_with_master
--connection master
if (!$is_temporary)
{
--let $diff_tables= master:t1,slave:t1
--source include/diff_tables.inc
}
if (!$is_temporary)
{
--echo
--echo # Throw a warning that table already exists and don't insert anything
--echo
CREATE VIEW t3 AS SELECT * FROM t2;
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
CREATE TABLE IF NOT EXISTS t3
SELECT '123', 2;
source include/show_binlog_events.inc;
DROP VIEW t3;
}
--echo
--echo # The statement can be binlogged correctly when it is in a SP/EVENT/TRIGGER
--echo
--disable_warnings
DROP PROCEDURE IF EXISTS p1;
--enable_warnings
eval CREATE PROCEDURE p1(IN a INT)
CREATE $_temporary TABLE IF NOT EXISTS t1 SELECT '123', a;
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
call p1(500);
call p1(600);
source include/show_binlog_events.inc;
--sync_slave_with_master
--connection master
if (!$is_temporary)
{
--let $diff_tables= master:t1,slave:t1
--source include/diff_tables.inc
}
DROP PROCEDURE p1;
--echo
--echo # The statement can be binlogged correctly when it is in a prepared statement
--echo
eval PREPARE stm FROM "CREATE $_temporary TABLE IF NOT EXISTS t1 SELECT '123', ?";
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
SET @a= 700;
EXECUTE stm USING @a;
SET @a= 800;
EXECUTE stm USING @a;
source include/show_binlog_events.inc;
--sync_slave_with_master
--connection master
if (!$is_temporary)
{
--let $diff_tables= master:t1,slave:t1
--source include/diff_tables.inc
}
--echo
--echo # The statement can be binlogged correctly when it is in a conditional comment
--echo
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
--echo # The whole statement in a conditional comment
eval /*!CREATE $_temporary TABLE IF NOT EXISTS t1
SELECT 'abc', 900*/;
source include/show_binlog_events.inc;
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
--echo
--echo # There is an long comment before SELECT
eval /*!CREATE $_temporary /*blabla*/ TABLE IF NOT EXISTS t1
SELECT 'abc', 901*/;
source include/show_binlog_events.inc;
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
--echo
--echo # Conditional comment starts just from SELECT
eval CREATE $_temporary TABLE IF NOT EXISTS t1
/*!SELECT 'abc',*/ 902;
source include/show_binlog_events.inc;
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
--echo
--echo # Only SELECT keyword is in the conditional comment
eval CREATE $_temporary TABLE IF NOT EXISTS t1
/*!SELECT*/ /*!'abc',*/ 904;
source include/show_binlog_events.inc;
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
--echo
--echo # Conditional comment is after SELECT keyword
eval CREATE $_temporary TABLE IF NOT EXISTS t1
SELECT /*!'abc',*/ 903;
source include/show_binlog_events.inc;
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
--echo
--echo # Conditional comment ends just before SELECT keyword
eval /*!CREATE $_temporary TABLE IF NOT EXISTS t1
*/SELECT 'abc', 905;
source include/show_binlog_events.inc;
--sync_slave_with_master
--connection master
if (!$is_temporary)
{
--let $diff_tables= master:t1,slave:t1
--source include/diff_tables.inc
}
DROP TABLE t2;
eval DROP $_temporary TABLE t1;
|