2007-06-12 21:47:00 +02:00
SET BINLOG_FORMAT=MIXED;
RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=INNODB;
INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6);
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
UPDATE t1 SET b = 2*a WHERE a > 1;
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
UPDATE t1 SET b = a * a WHERE a > 3;
COMMIT;
SET BINLOG_FORMAT=STATEMENT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
UPDATE t1 SET b = 1*a WHERE a > 1;
2010-04-28 14:47:49 +02:00
ERROR HY000: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
2007-06-12 21:47:00 +02:00
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
UPDATE t1 SET b = 2*a WHERE a > 2;
2010-04-28 14:47:49 +02:00
ERROR HY000: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
2007-06-12 21:47:00 +02:00
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
UPDATE t1 SET b = 3*a WHERE a > 3;
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
UPDATE t1 SET b = 4*a WHERE a > 4;
COMMIT;
SET BINLOG_FORMAT=MIXED;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
UPDATE t1 SET b = 1*a WHERE a > 1;
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
UPDATE t1 SET b = 2*a WHERE a > 2;
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
UPDATE t1 SET b = 3*a WHERE a > 3;
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
UPDATE t1 SET b = 4*a WHERE a > 4;
COMMIT;
SET BINLOG_FORMAT=ROW;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
UPDATE t1 SET b = 1*a WHERE a > 1;
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
UPDATE t1 SET b = 2*a WHERE a > 2;
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
UPDATE t1 SET b = 3*a WHERE a > 3;
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
UPDATE t1 SET b = 4*a WHERE a > 4;
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=INNODB
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6)
master-bin.000001 # Xid # # COMMIT /* XID */
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 2*a WHERE a > 1
master-bin.000001 # Xid # # COMMIT /* XID */
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 3*a WHERE a > 3
master-bin.000001 # Xid # # COMMIT /* XID */
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 4*a WHERE a > 4
master-bin.000001 # Xid # # COMMIT /* XID */
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 3*a WHERE a > 3
master-bin.000001 # Xid # # COMMIT /* XID */
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 4*a WHERE a > 4
master-bin.000001 # Xid # # COMMIT /* XID */
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
2009-05-31 13:44:41 +08:00
master-bin.000001 # Query # # BEGIN
2007-06-12 21:47:00 +02:00
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
DROP TABLE t1;
2009-01-08 03:06:54 +01:00
flush status;
2007-06-19 09:56:19 +02:00
show status like "binlog_cache_use";
2007-06-22 11:22:29 +02:00
Variable_name Value
2009-01-08 03:06:54 +01:00
Binlog_cache_use 0
2007-06-19 09:56:19 +02:00
show status like "binlog_cache_disk_use";
2007-06-22 11:22:29 +02:00
Variable_name Value
Binlog_cache_disk_use 0
2007-06-19 09:56:19 +02:00
create table t1 (a int) engine=innodb;
show status like "binlog_cache_use";
2007-06-22 11:22:29 +02:00
Variable_name Value
2010-01-05 16:55:23 +00:00
Binlog_cache_use 2
2007-06-19 09:56:19 +02:00
show status like "binlog_cache_disk_use";
2007-06-22 11:22:29 +02:00
Variable_name Value
Binlog_cache_disk_use 1
2007-06-19 09:56:19 +02:00
begin;
delete from t1;
commit;
show status like "binlog_cache_use";
2007-06-22 11:22:29 +02:00
Variable_name Value
2010-01-05 16:55:23 +00:00
Binlog_cache_use 4
2007-06-19 09:56:19 +02:00
show status like "binlog_cache_disk_use";
2007-06-22 11:22:29 +02:00
Variable_name Value
Binlog_cache_disk_use 1
2007-06-19 09:56:19 +02:00
drop table t1;
2007-08-14 15:35:19 -06:00
CREATE TABLE `t1` (
`a` int(11) NOT NULL auto_increment,
`b` int(11) default NULL,
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
CREATE TABLE `t2` (
`a` int(11) NOT NULL auto_increment,
`b` int(11) default NULL,
PRIMARY KEY (`a`)
) ENGINE=INNODB DEFAULT CHARSET=latin1 ;
insert into t1 values (1,1),(2,2);
insert into t2 values (1,1),(4,4);
reset master;
UPDATE t2,t1 SET t2.a=t1.a+2;
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
select * from t2 /* must be (3,1), (4,4) */;
a b
1 1
4 4
2009-09-29 14:16:23 +03:00
there must no UPDATE in binlog
show master status;
2007-08-14 15:35:19 -06:00
File Position Binlog_Do_DB Binlog_Ignore_DB
2009-09-29 14:16:23 +03:00
master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
2007-08-14 15:35:19 -06:00
delete from t1;
delete from t2;
insert into t1 values (1,2),(3,4),(4,4);
insert into t2 values (1,2),(3,4),(4,4);
reset master;
UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a;
ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
2009-09-29 14:16:23 +03:00
there must no UPDATE in binlog
show master status;
2007-08-14 15:35:19 -06:00
File Position Binlog_Do_DB Binlog_Ignore_DB
2009-09-29 14:16:23 +03:00
master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
2007-08-14 15:35:19 -06:00
drop table t1, t2;
2007-06-21 22:10:40 +02:00
End of tests