WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
2006-02-25 22:21:03 +01:00
|
|
|
stop slave;
|
|
|
|
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
|
|
|
reset master;
|
|
|
|
reset slave;
|
|
|
|
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
|
|
|
start slave;
|
|
|
|
drop database if exists mysqltest1;
|
|
|
|
create database mysqltest1;
|
|
|
|
use mysqltest1;
|
|
|
|
show global variables like "binlog_format%";
|
|
|
|
Variable_name Value
|
|
|
|
binlog_format ROW
|
|
|
|
show session variables like "binlog_format%";
|
|
|
|
Variable_name Value
|
|
|
|
binlog_format ROW
|
|
|
|
select @@global.binlog_format, @@session.binlog_format;
|
|
|
|
@@global.binlog_format @@session.binlog_format
|
|
|
|
ROW ROW
|
|
|
|
CREATE TABLE t1 (a varchar(100));
|
|
|
|
prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
|
|
|
|
set @string="emergency";
|
|
|
|
insert into t1 values("work");
|
|
|
|
execute stmt1 using @string;
|
|
|
|
deallocate prepare stmt1;
|
|
|
|
prepare stmt1 from 'insert into t1 select ?';
|
|
|
|
insert into t1 values(concat(UUID(),"work"));
|
|
|
|
execute stmt1 using @string;
|
|
|
|
deallocate prepare stmt1;
|
|
|
|
insert into t1 values(concat("for",UUID()));
|
|
|
|
insert into t1 select "yesterday";
|
|
|
|
create temporary table tmp(a char(3));
|
|
|
|
insert into tmp values("see");
|
|
|
|
set binlog_format=statement;
|
|
|
|
ERROR HY000: Cannot switch out of the row-based binary log format when the session has open temporary tables
|
|
|
|
insert into t1 select * from tmp;
|
|
|
|
drop temporary table tmp;
|
|
|
|
set binlog_format=statement;
|
|
|
|
show global variables like "binlog_format%";
|
|
|
|
Variable_name Value
|
|
|
|
binlog_format ROW
|
|
|
|
show session variables like "binlog_format%";
|
|
|
|
Variable_name Value
|
|
|
|
binlog_format STATEMENT
|
|
|
|
select @@global.binlog_format, @@session.binlog_format;
|
|
|
|
@@global.binlog_format @@session.binlog_format
|
|
|
|
ROW STATEMENT
|
|
|
|
set global binlog_format=statement;
|
|
|
|
show global variables like "binlog_format%";
|
|
|
|
Variable_name Value
|
|
|
|
binlog_format STATEMENT
|
|
|
|
show session variables like "binlog_format%";
|
|
|
|
Variable_name Value
|
|
|
|
binlog_format STATEMENT
|
|
|
|
select @@global.binlog_format, @@session.binlog_format;
|
|
|
|
@@global.binlog_format @@session.binlog_format
|
|
|
|
STATEMENT STATEMENT
|
|
|
|
prepare stmt1 from 'insert into t1 select ?';
|
|
|
|
set @string="emergency";
|
|
|
|
insert into t1 values("work");
|
|
|
|
execute stmt1 using @string;
|
|
|
|
deallocate prepare stmt1;
|
|
|
|
prepare stmt1 from 'insert into t1 select ?';
|
|
|
|
insert into t1 values("work");
|
|
|
|
execute stmt1 using @string;
|
|
|
|
deallocate prepare stmt1;
|
|
|
|
insert into t1 values("for");
|
|
|
|
insert into t1 select "yesterday";
|
|
|
|
set binlog_format=default;
|
|
|
|
select @@global.binlog_format, @@session.binlog_format;
|
|
|
|
@@global.binlog_format @@session.binlog_format
|
|
|
|
STATEMENT STATEMENT
|
|
|
|
set global binlog_format=default;
|
|
|
|
ERROR 42000: Variable 'binlog_format' doesn't have a default value
|
|
|
|
select @@global.binlog_format, @@session.binlog_format;
|
|
|
|
@@global.binlog_format @@session.binlog_format
|
|
|
|
STATEMENT STATEMENT
|
|
|
|
prepare stmt1 from 'insert into t1 select ?';
|
|
|
|
set @string="emergency";
|
|
|
|
insert into t1 values("work");
|
|
|
|
execute stmt1 using @string;
|
|
|
|
deallocate prepare stmt1;
|
|
|
|
prepare stmt1 from 'insert into t1 select ?';
|
|
|
|
insert into t1 values("work");
|
|
|
|
execute stmt1 using @string;
|
|
|
|
deallocate prepare stmt1;
|
|
|
|
insert into t1 values("for");
|
|
|
|
insert into t1 select "yesterday";
|
|
|
|
set binlog_format=mixed;
|
|
|
|
select @@global.binlog_format, @@session.binlog_format;
|
|
|
|
@@global.binlog_format @@session.binlog_format
|
|
|
|
STATEMENT MIXED
|
|
|
|
set global binlog_format=mixed;
|
|
|
|
select @@global.binlog_format, @@session.binlog_format;
|
|
|
|
@@global.binlog_format @@session.binlog_format
|
|
|
|
MIXED MIXED
|
|
|
|
prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
|
|
|
|
set @string="emergency";
|
|
|
|
insert into t1 values("work");
|
|
|
|
execute stmt1 using @string;
|
|
|
|
deallocate prepare stmt1;
|
|
|
|
prepare stmt1 from 'insert into t1 select ?';
|
|
|
|
insert into t1 values(concat(UUID(),"work"));
|
|
|
|
execute stmt1 using @string;
|
|
|
|
deallocate prepare stmt1;
|
|
|
|
insert into t1 values(concat("for",UUID()));
|
|
|
|
insert into t1 select "yesterday";
|
|
|
|
prepare stmt1 from 'insert into t1 select ?';
|
|
|
|
insert into t1 values(concat(UUID(),"work"));
|
|
|
|
execute stmt1 using @string;
|
|
|
|
deallocate prepare stmt1;
|
|
|
|
insert into t1 values(concat("for",UUID()));
|
|
|
|
insert into t1 select "yesterday";
|
|
|
|
create procedure foo()
|
|
|
|
begin
|
|
|
|
insert into t1 values("work");
|
|
|
|
insert into t1 values(concat("for",UUID()));
|
|
|
|
insert into t1 select "yesterday";
|
|
|
|
end|
|
|
|
|
create procedure foo2()
|
|
|
|
begin
|
|
|
|
insert into t1 values(concat("emergency",UUID()));
|
|
|
|
insert into t1 values("work");
|
|
|
|
insert into t1 values(concat("for",UUID()));
|
|
|
|
set session binlog_format=row; # accepted for stored procs
|
|
|
|
insert into t1 values("more work");
|
|
|
|
set session binlog_format=mixed;
|
|
|
|
end|
|
|
|
|
create function foo3() returns bigint unsigned
|
|
|
|
begin
|
|
|
|
set session binlog_format=row; # rejected for stored funcs
|
|
|
|
insert into t1 values("alarm");
|
|
|
|
return 100;
|
|
|
|
end|
|
|
|
|
call foo();
|
|
|
|
call foo2();
|
|
|
|
select foo3();
|
|
|
|
ERROR HY000: Cannot change the binary logging format inside a stored function or trigger
|
|
|
|
select * from t1 where a="alarm";
|
|
|
|
a
|
|
|
|
show binlog events from 102;
|
|
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
|
|
master-bin.000001 102 Query 1 205 drop database if exists mysqltest1
|
2006-03-03 09:49:46 +01:00
|
|
|
master-bin.000001 205 Table_map 1 262 table_id: 15 (mysql.proc)
|
|
|
|
master-bin.000001 262 Write_rows 1 291 table_id: 4294967295 flags: STMT_END_F
|
|
|
|
master-bin.000001 291 Table_map 1 349 table_id: 16 (mysql.event)
|
|
|
|
master-bin.000001 349 Write_rows 1 378 table_id: 4294967295 flags: STMT_END_F
|
|
|
|
master-bin.000001 378 Query 1 473 create database mysqltest1
|
|
|
|
master-bin.000001 473 Query 1 574 use `mysqltest1`; CREATE TABLE t1 (a varchar(100))
|
|
|
|
master-bin.000001 574 Table_map 1 619 table_id: 17 (mysqltest1.t1)
|
|
|
|
master-bin.000001 619 Write_rows 1 648 table_id: 4294967295 flags: STMT_END_F
|
|
|
|
master-bin.000001 648 Table_map 1 693 table_id: 17 (mysqltest1.t1)
|
|
|
|
master-bin.000001 693 Write_rows 1 728 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 728 Table_map 1 773 table_id: 17 (mysqltest1.t1)
|
|
|
|
master-bin.000001 773 Write_rows 1 849 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 849 Table_map 1 894 table_id: 17 (mysqltest1.t1)
|
|
|
|
master-bin.000001 894 Write_rows 1 923 table_id: 4294967295 flags: STMT_END_F
|
|
|
|
master-bin.000001 923 Table_map 1 968 table_id: 17 (mysqltest1.t1)
|
|
|
|
master-bin.000001 968 Write_rows 1 1039 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 1039 Table_map 1 1084 table_id: 17 (mysqltest1.t1)
|
|
|
|
master-bin.000001 1084 Write_rows 1 1124 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 1124 Table_map 1 1169 table_id: 17 (mysqltest1.t1)
|
|
|
|
master-bin.000001 1169 Write_rows 1 1239 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 1239 Table_map 1 1284 table_id: 17 (mysqltest1.t1)
|
|
|
|
master-bin.000001 1284 Write_rows 1 1324 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 1324 Table_map 1 1369 table_id: 17 (mysqltest1.t1)
|
|
|
|
master-bin.000001 1369 Write_rows 1 1403 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 1403 Query 1 1501 use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 1501 User var 1 1549 @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
|
|
|
|
master-bin.000001 1549 Query 1 1649 use `mysqltest1`; insert into t1 select @'string'
|
|
|
|
master-bin.000001 1649 Query 1 1747 use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 1747 User var 1 1795 @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
|
|
|
|
master-bin.000001 1795 Query 1 1895 use `mysqltest1`; insert into t1 select @'string'
|
|
|
|
master-bin.000001 1895 Query 1 1992 use `mysqltest1`; insert into t1 values("for")
|
|
|
|
master-bin.000001 1992 Query 1 2094 use `mysqltest1`; insert into t1 select "yesterday"
|
|
|
|
master-bin.000001 2094 Query 1 2192 use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 2192 User var 1 2240 @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
|
|
|
|
master-bin.000001 2240 Query 1 2340 use `mysqltest1`; insert into t1 select @'string'
|
|
|
|
master-bin.000001 2340 Query 1 2438 use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 2438 User var 1 2486 @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
|
|
|
|
master-bin.000001 2486 Query 1 2586 use `mysqltest1`; insert into t1 select @'string'
|
|
|
|
master-bin.000001 2586 Query 1 2683 use `mysqltest1`; insert into t1 values("for")
|
|
|
|
master-bin.000001 2683 Query 1 2785 use `mysqltest1`; insert into t1 select "yesterday"
|
|
|
|
master-bin.000001 2785 Query 1 2883 use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 2883 Write_rows 1 2959 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 2959 Write_rows 1 3030 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 3030 User var 1 3078 @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
|
|
|
|
master-bin.000001 3078 Query 1 3178 use `mysqltest1`; insert into t1 select @'string'
|
|
|
|
master-bin.000001 3178 Write_rows 1 3248 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 3248 Query 1 3350 use `mysqltest1`; insert into t1 select "yesterday"
|
|
|
|
master-bin.000001 3350 Write_rows 1 3421 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 3421 User var 1 3469 @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
|
|
|
|
master-bin.000001 3469 Query 1 3569 use `mysqltest1`; insert into t1 select @'string'
|
|
|
|
master-bin.000001 3569 Write_rows 1 3639 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 3639 Query 1 3741 use `mysqltest1`; insert into t1 select "yesterday"
|
|
|
|
master-bin.000001 3741 Query 1 3953 use `mysqltest1`; create procedure foo()
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
2006-02-25 22:21:03 +01:00
|
|
|
begin
|
|
|
|
insert into t1 values("work");
|
|
|
|
insert into t1 values(concat("for",UUID()));
|
|
|
|
insert into t1 select "yesterday";
|
|
|
|
end
|
2006-03-03 09:49:46 +01:00
|
|
|
master-bin.000001 3953 Query 1 4310 use `mysqltest1`; create procedure foo2()
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
2006-02-25 22:21:03 +01:00
|
|
|
begin
|
|
|
|
insert into t1 values(concat("emergency",UUID()));
|
|
|
|
insert into t1 values("work");
|
|
|
|
insert into t1 values(concat("for",UUID()));
|
|
|
|
set session binlog_format=row; # accepted for stored procs
|
|
|
|
insert into t1 values("more work");
|
|
|
|
set session binlog_format=mixed;
|
|
|
|
end
|
2006-03-03 09:49:46 +01:00
|
|
|
master-bin.000001 4310 Query 1 4538 use `mysqltest1`; create function foo3() returns bigint unsigned
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
2006-02-25 22:21:03 +01:00
|
|
|
begin
|
|
|
|
set session binlog_format=row; # rejected for stored funcs
|
|
|
|
insert into t1 values("alarm");
|
|
|
|
return 100;
|
|
|
|
end
|
2006-03-03 09:49:46 +01:00
|
|
|
master-bin.000001 4538 Query 1 4644 use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 4644 Write_rows 1 4714 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 4714 Query 1 4824 use `mysqltest1`; insert into t1 select "yesterday"
|
|
|
|
master-bin.000001 4824 Write_rows 1 4900 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 4900 Query 1 5006 use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 5006 Write_rows 1 5076 table_id: 17 flags: STMT_END_F
|
|
|
|
master-bin.000001 5076 Table_map 1 5121 table_id: 17 (mysqltest1.t1)
|
|
|
|
master-bin.000001 5121 Write_rows 1 5161 table_id: 17 flags: STMT_END_F
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
2006-02-25 22:21:03 +01:00
|
|
|
drop database mysqltest1;
|