List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:October 31 2007 11:25am
Subject:bk commit into 5.1 tree (mats:1.2605) BUG#28086
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mats. When mats does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-10-31 12:25:38+01:00, mats@stripped +3 -0
  BUG#28086 (SBR of USER() becomes corrupted on slave):
  
  Marking statements containing USER() as unsafe, causing them to switch to using
  row-based logging in MIXED mode and generate a warning in STATEMENT mode.

  mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result@stripped, 2007-10-31 12:25:31+01:00, mats@stripped +37 -0
    Result change.

  mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test@stripped, 2007-10-31 12:25:32+01:00, mats@stripped +24 -0
    Adding test to check that USER() cause a switch to row-based logging.

  sql/sql_yacc.yy@stripped, 2007-10-31 12:25:32+01:00, mats@stripped +1 -0
    Setting statements containing USER() to be unsafe.

diff -Nrup a/mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result b/mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result
--- a/mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result	2007-07-04 22:06:25 +02:00
+++ b/mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result	2007-10-31 12:25:31 +01:00
@@ -405,6 +405,17 @@ CREATE TABLE t12 (data LONG);
 LOCK TABLES t12 WRITE;
 INSERT INTO t12 VALUES(UUID());
 UNLOCK TABLES;
+CREATE FUNCTION my_user()
+RETURNS CHAR(64)
+BEGIN
+DECLARE user CHAR(64);
+SELECT USER() INTO user;
+RETURN user;
+END $$
+DROP TABLE IF EXISTS t13;
+CREATE TABLE t13 (data CHAR(64));
+INSERT INTO t13 VALUES (USER());
+INSERT INTO t13 VALUES (my_user());
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	drop database if exists mysqltest1
@@ -709,6 +720,19 @@ master-bin.000001	#	Query	#	#	use `mysql
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE t12 (data LONG)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t12)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` FUNCTION my_user()
+RETURNS CHAR(64)
+BEGIN
+DECLARE user CHAR(64);
+SELECT USER() INTO user;
+RETURN user;
+END
+master-bin.000001	#	Query	#	#	use `mysqltest1`; DROP TABLE IF EXISTS t13
+master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE t13 (data CHAR(64))
+master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t13)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t13)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	drop database if exists mysqltest1
@@ -1012,6 +1036,19 @@ master-bin.000001	#	Query	#	#	use `mysql
 master-bin.000001	#	Query	#	#	use `mysqltest1`; DROP TABLE IF EXISTS t12
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE t12 (data LONG)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t12)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` FUNCTION my_user()
+RETURNS CHAR(64)
+BEGIN
+DECLARE user CHAR(64);
+SELECT USER() INTO user;
+RETURN user;
+END
+master-bin.000001	#	Query	#	#	use `mysqltest1`; DROP TABLE IF EXISTS t13
+master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE t13 (data CHAR(64))
+master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t13)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t13)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 drop database mysqltest1;
 set global binlog_format =@my_binlog_format;
diff -Nrup a/mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test b/mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test
--- a/mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test	2007-06-27 14:27:24 +02:00
+++ b/mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test	2007-10-31 12:25:32 +01:00
@@ -518,6 +518,30 @@ CREATE TABLE t12 (data LONG);
 LOCK TABLES t12 WRITE;
 INSERT INTO t12 VALUES(UUID());
 UNLOCK TABLES;
+sync_slave_with_master;
+
+#
+# BUG#28086: SBR of USER() becomes corrupted on slave
+# 
+
+connection master;
+
+# Just to get something that is non-trivial, albeit still simple, we
+# stuff the result of USER() into a variable.
+--delimiter $$
+CREATE FUNCTION my_user()
+    RETURNS CHAR(64)
+BEGIN
+  DECLARE user CHAR(64);
+  SELECT USER() INTO user;
+  RETURN user;
+END $$
+--delimiter ;
+
+DROP TABLE IF EXISTS t13;
+CREATE TABLE t13 (data CHAR(64));
+INSERT INTO t13 VALUES (USER());
+INSERT INTO t13 VALUES (my_user());
 
 source include/show_binlog_events.inc;
 sync_slave_with_master;
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy	2007-10-30 09:01:56 +01:00
+++ b/sql/sql_yacc.yy	2007-10-31 12:25:32 +01:00
@@ -6790,6 +6790,7 @@ function_call_keyword:
         | USER '(' ')'
           {
             $$= new (YYTHD->mem_root) Item_func_user();
+            Lex->set_stmt_unsafe();
             Lex->safe_to_cache_query=0;
           }
         | YEAR_SYM '(' expr ')'
Thread
bk commit into 5.1 tree (mats:1.2605) BUG#28086Mats Kindahl31 Oct