mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 05:52:27 +01:00
88cd7a98a5
The binlog_innodb test was sensitive to what tests ran before it. Now run FLUSH STATUS before performing operations that need to be checked. sys_var_thd_ulong::update() was improperly casting an option value from ulonglong to ulong before comparing it to the max allowed value. On systems where ulong and ulonglong are of different size, this caused values greater than ULONG_MAX to wrap around (not be truncated to ULONG_MAX, which appears to have been the intention of the original coder), and caused some checks to work incorrectly. This wasn't generally visible to the user, because later checks would prevent the wrapped-around value from being used. But it caused warning messages to differ between 32- and 64-bit platforms. Fix is to just remove the cast. Also added a DBUG_ASSERT to ensure that the value really is capped properly before finally stuffing it into the ulong.
173 lines
6.2 KiB
Text
173 lines
6.2 KiB
Text
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;
|
|
ERROR HY000: Binary logging not possible. Message: Transaction level 'READ-UNCOMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'
|
|
COMMIT;
|
|
BEGIN;
|
|
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|
UPDATE t1 SET b = 2*a WHERE a > 2;
|
|
ERROR HY000: Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'
|
|
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
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
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 */
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 2*a WHERE a > 1
|
|
master-bin.000001 # Xid # # COMMIT /* XID */
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
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 */
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 3*a WHERE a > 3
|
|
master-bin.000001 # Xid # # COMMIT /* XID */
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 4*a WHERE a > 4
|
|
master-bin.000001 # Xid # # COMMIT /* XID */
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
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 */
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
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 */
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 3*a WHERE a > 3
|
|
master-bin.000001 # Xid # # COMMIT /* XID */
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 4*a WHERE a > 4
|
|
master-bin.000001 # Xid # # COMMIT /* XID */
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
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 */
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
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 */
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
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 */
|
|
master-bin.000001 # Query # # use `test`; BEGIN
|
|
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;
|
|
flush status;
|
|
show status like "binlog_cache_use";
|
|
Variable_name Value
|
|
Binlog_cache_use 0
|
|
show status like "binlog_cache_disk_use";
|
|
Variable_name Value
|
|
Binlog_cache_disk_use 0
|
|
create table t1 (a int) engine=innodb;
|
|
show status like "binlog_cache_use";
|
|
Variable_name Value
|
|
Binlog_cache_use 1
|
|
show status like "binlog_cache_disk_use";
|
|
Variable_name Value
|
|
Binlog_cache_disk_use 1
|
|
begin;
|
|
delete from t1;
|
|
commit;
|
|
show status like "binlog_cache_use";
|
|
Variable_name Value
|
|
Binlog_cache_use 2
|
|
show status like "binlog_cache_disk_use";
|
|
Variable_name Value
|
|
Binlog_cache_disk_use 1
|
|
drop table t1;
|
|
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
|
|
show master status /* there must no UPDATE in binlog */;
|
|
File Position Binlog_Do_DB Binlog_Ignore_DB
|
|
master-bin.000001 106
|
|
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'
|
|
show master status /* there must be no UPDATE query event */;
|
|
File Position Binlog_Do_DB Binlog_Ignore_DB
|
|
master-bin.000001 106
|
|
drop table t1, t2;
|
|
End of tests
|