| 1 |
# BUG #36763: TRUNCATE TABLE fails to replicate when stmt-based |
| 2 |
# binlogging is not supported. |
| 3 |
|
| 4 |
# This should always be logged as a statement, even when executed as a |
| 5 |
# row-by-row deletion. |
| 6 |
|
| 7 |
# $before_truncate A statement to execute (just) before issuing the |
| 8 |
# TRUNCATE TABLE |
| 9 |
|
| 10 |
|
| 11 |
eval CREATE TABLE t1 (a INT) ENGINE=$engine; |
| 12 |
eval CREATE TABLE t2 (a INT) ENGINE=$engine; |
| 13 |
INSERT INTO t2 VALUES (1),(2),(3); |
| 14 |
let $binlog_start = query_get_value("SHOW MASTER STATUS", Position, 1); |
| 15 |
if ($before_truncate) { |
| 16 |
eval $before_truncate; |
| 17 |
} |
| 18 |
--echo **** Truncate of empty table shall be logged |
| 19 |
TRUNCATE TABLE t1; |
| 20 |
|
| 21 |
if ($before_truncate) { |
| 22 |
eval $before_truncate; |
| 23 |
} |
| 24 |
TRUNCATE TABLE t2; |
| 25 |
source include/show_binlog_events.inc; |
| 26 |
|
| 27 |
DROP TABLE t1,t2; |
| 28 |
|
| 29 |
--echo # |
| 30 |
--echo # Bug#42643: InnoDB does not support replication of TRUNCATE TABLE |
| 31 |
--echo # |
| 32 |
|
| 33 |
eval CREATE TABLE t1 (a INT) ENGINE=$engine; |
| 34 |
eval CREATE TABLE t2 (a INT) ENGINE=$engine; |
| 35 |
INSERT INTO t1 VALUES (1),(2); |
| 36 |
|
| 37 |
let $binlog_start = query_get_value("SHOW MASTER STATUS", Position, 1); |
| 38 |
if ($before_truncate) { |
| 39 |
eval $before_truncate; |
| 40 |
} |
| 41 |
|
| 42 |
BEGIN; |
| 43 |
INSERT INTO t2 SELECT * FROM t1; |
| 44 |
|
| 45 |
connect (truncate,localhost,root,,); |
| 46 |
send TRUNCATE TABLE t1; |
| 47 |
|
| 48 |
connection default; |
| 49 |
INSERT INTO t2 SELECT * FROM t1; |
| 50 |
SELECT COUNT(*) FROM t2; |
| 51 |
COMMIT; |
| 52 |
|
| 53 |
connection truncate; |
| 54 |
--echo # Reaping TRUNCATE TABLE |
| 55 |
--reap |
| 56 |
SELECT COUNT(*) FROM t1; |
| 57 |
SELECT COUNT(*) FROM t2; |
| 58 |
|
| 59 |
connection default; |
| 60 |
|
| 61 |
source include/show_binlog_events.inc; |
| 62 |
disconnect truncate; |
| 63 |
DROP TABLE t1,t2; |