Hi Mats
I noticed that you removed the SET BINLOG_FORMAT=MIXED statement from
the test case compared with your previous patch, and I think you're
hoping the combination mechanism of mtr will run the test in all the
formats, but actually, this is not the case. test case
'rpl_truncate_3innodb.test' included 'extra/rpl_tests/rpl_truncate.test'
to do the real test, and the latter set the BINLOG_FORMAT directly to
run the test from 'extra/rpl_tests/rpl_truncate_helper.test', the last
format it set is ROW, so the test statement you put in
'rpl_truncate_3innodb.test' will always be run in ROW format. I think
you should put you test code in
'extra/rpl_tests/rpl_truncate_helper.test', and I also think this test
case need some reconstruction to make it clearer. Use the combination
mechanism to set binlog_format instead of setting it directly in the
test case.
BTW, if the test code you added is actually run in STATEMENT format,
it'll fail.
On 2008-06-19 Tue 11:22 +0200, Mats Kindahl wrote:
> #At file:///home/bzr/b36763-mysql-5.1-bugteam/
>
> 2655 Mats Kindahl 2008-06-19
> Bug #36763: TRUNCATE TABLE fails to replicate when stmt-based binlogging is
> not supported.
>
> When executing a TRUNCATE TABLE under MIXED mode, the TRUNCATE statement was
> not written to the binary log. The reason for this was that the statement
> was assumed to be a "row query type", meaning that the statement is logged
> only if the current statement is not row-based. Since InnoDB forces row-based
> logging for statements in READ UNCOMMITTED isolation level, this caused the
> statement to not be logged.
>
> The problem is fixed by deliberately marking TRUNCATE TABLE statements to be
> "statement query types", meaning that they are always logged as statements.
> modified:
> mysql-test/suite/rpl/r/rpl_truncate_3innodb.result
> mysql-test/suite/rpl/t/rpl_truncate_3innodb.test
> sql/sql_delete.cc
>
> === modified file 'mysql-test/suite/rpl/r/rpl_truncate_3innodb.result'
> --- a/mysql-test/suite/rpl/r/rpl_truncate_3innodb.result 2007-12-14 13:40:45 +0000
> +++ b/mysql-test/suite/rpl/r/rpl_truncate_3innodb.result 2008-06-19 09:21:35 +0000
> @@ -260,3 +260,14 @@ master-bin.000001 # Delete_rows # # tabl
> master-bin.000001 # Xid # # COMMIT /* XID */
> master-bin.000001 # Query # # use `test`; DROP TABLE t1
> RESET MASTER;
> +[on master]
> +CREATE TABLE t1 (a INT) ENGINE=INNODB;
> +INSERT INTO t1 VALUES (1),(2),(3);
> +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
> +TRUNCATE TABLE t1;
> +SELECT * FROM t1;
> +a
> +[on slave]
> +SELECT * FROM t1;
> +a
> +DROP TABLE t1;
>
> === modified file 'mysql-test/suite/rpl/t/rpl_truncate_3innodb.test'
> --- a/mysql-test/suite/rpl/t/rpl_truncate_3innodb.test 2007-06-27 12:28:02 +0000
> +++ b/mysql-test/suite/rpl/t/rpl_truncate_3innodb.test 2008-06-19 09:21:35 +0000
> @@ -4,3 +4,38 @@
>
> let $engine=InnoDB;
> --source extra/rpl_tests/rpl_truncate.test
> +
> +# Resetting master and slave
> +disable_query_log;
> +connection slave;
> +STOP SLAVE;
> +source include/wait_for_slave_to_stop.inc;
> +connection master;
> +RESET MASTER;
> +connection slave;
> +RESET SLAVE;
> +START SLAVE;
> +source include/wait_for_slave_to_start.inc;
> +enable_query_log;
> +
> +# BUG #36763: TRUNCATE TABLE fails to replicate when stmt-based
> +# binlogging is not supported.
> +
> +# TRUNCATE TABLE should be treated as a DDL (DROP TABLE + CREATE
> +# TABLE), so it should replicate fine in all replication modes without
> +# any form of warning or error.
> +
> +--echo [on master]
> +connection master;
> +CREATE TABLE t1 (a INT) ENGINE=INNODB;
> +INSERT INTO t1 VALUES (1),(2),(3);
> +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
> +TRUNCATE TABLE t1;
> +SELECT * FROM t1;
> +--echo [on slave]
> +sync_slave_with_master;
> +SELECT * FROM t1;
> +
> +connection master;
> +DROP TABLE t1;
> +sync_slave_with_master;
>
> === modified file 'sql/sql_delete.cc'
> --- a/sql/sql_delete.cc 2008-03-27 12:07:01 +0000
> +++ b/sql/sql_delete.cc 2008-06-19 09:21:35 +0000
> @@ -382,7 +382,10 @@ cleanup:
> statement-based; otherwise, 'ha_delete_row()' was used to
> delete specific rows which we might log row-based.
> */
> - int log_result= thd->binlog_query(THD::ROW_QUERY_TYPE,
> + THD::enum_binlog_query_type query_type=
> + thd->lex->sql_command == SQLCOM_TRUNCATE ?
> + THD::STMT_QUERY_TYPE : THD::ROW_QUERY_TYPE;
> + int log_result= thd->binlog_query(query_type,
> thd->query, thd->query_length,
> transactional_table, FALSE, killed_status);
>
>