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
|
2006-03-09 15:59:29 +01:00
|
|
|
master-bin.000001 # Query 1 # drop database if exists mysqltest1
|
|
|
|
master-bin.000001 # Table_map 1 # table_id: # (mysql.proc)
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Query 1 # create database mysqltest1
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE TABLE t1 (a varchar(100))
|
|
|
|
master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1)
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1)
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1)
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1)
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1)
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1)
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1)
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1)
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1)
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 # User var 1 # @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 select @'string'
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 # User var 1 # @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 select @'string'
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values("for")
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 select "yesterday"
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 # User var 1 # @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 select @'string'
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 # User var 1 # @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 select @'string'
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values("for")
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 select "yesterday"
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # User var 1 # @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 select @'string'
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 select "yesterday"
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # User var 1 # @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 select @'string'
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 select "yesterday"
|
2006-03-10 17:31:07 +01:00
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` 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-10 17:31:07 +01:00
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` 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-10 17:31:07 +01:00
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` 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-09 15:59:29 +01:00
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 select "yesterday"
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values("work")
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
|
|
|
master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1)
|
|
|
|
master-bin.000001 # Write_rows 1 # table_id: # 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;
|