List:Commits« Previous MessageNext Message »
From:Sven Sandberg Date:January 13 2010 4:52pm
Subject:bzr commit into mysql-6.0-codebase branch (sven.sandberg:3823)
Bug#49222
View as plain text  
#At file:///home/sven/bzr/b49222-rand_unsafe/pe/ based on revid:gshchepa@stripped

 3823 Sven Sandberg	2010-01-13 [merge]
      merged BUG#49222 from mysql-5.1-bugteam to mysql-pe

    modified:
      mysql-test/extra/rpl_tests/rpl_row_func003.test
      mysql-test/suite/binlog/r/binlog_unsafe.result
      mysql-test/suite/binlog/t/binlog_unsafe.test
      mysql-test/suite/rpl/r/rpl_misc_functions.result
      mysql-test/suite/rpl/r/rpl_nondeterministic_functions.result
      mysql-test/suite/rpl/r/rpl_optimize.result
      mysql-test/suite/rpl/r/rpl_row_func003.result
      mysql-test/suite/rpl/t/rpl_misc_functions.test
      mysql-test/suite/rpl/t/rpl_nondeterministic_functions.test
      mysql-test/suite/rpl/t/rpl_optimize.test
      mysql-test/suite/rpl_ndb_big/r/rpl_ndb_func003.result
      sql/item_create.cc
=== modified file 'mysql-test/extra/rpl_tests/rpl_row_func003.test'
--- a/mysql-test/extra/rpl_tests/rpl_row_func003.test	2009-12-02 14:52:07 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_row_func003.test	2010-01-13 16:51:37 +0000
@@ -15,6 +15,8 @@
 #       Vs slave.                                                           #
 #############################################################################
 
+CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
+
 # Begin clean up test section
 connection master;
 --disable_warnings
@@ -44,7 +46,9 @@ INSERT INTO test.t1 VALUES (null,test.f1
 
 SET AUTOCOMMIT=0;
 START TRANSACTION;
+--disable_warnings
 INSERT INTO test.t1 VALUES (null,test.f1());
+--enable_warnings
 ROLLBACK;
 SET AUTOCOMMIT=1;
 

=== modified file 'mysql-test/suite/binlog/r/binlog_unsafe.result'
--- a/mysql-test/suite/binlog/r/binlog_unsafe.result	2009-12-16 08:27:58 +0000
+++ b/mysql-test/suite/binlog/r/binlog_unsafe.result	2010-01-13 16:51:37 +0000
@@ -408,6 +408,9 @@ Note	1592	Statement may not be safe to l
 INSERT INTO t1 VALUES (VERSION());
 Warnings:
 Note	1592	Statement may not be safe to log in statement format.
+INSERT INTO t1 VALUES (RAND());
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
 DELETE FROM t1;
 SET TIMESTAMP=1000000;
 INSERT INTO t1 VALUES

=== modified file 'mysql-test/suite/binlog/t/binlog_unsafe.test'
--- a/mysql-test/suite/binlog/t/binlog_unsafe.test	2009-12-16 08:27:58 +0000
+++ b/mysql-test/suite/binlog/t/binlog_unsafe.test	2010-01-13 16:51:37 +0000
@@ -48,6 +48,8 @@
 # BUG#41980, SBL, INSERT .. SELECT .. LIMIT = ERROR, even when @@SQL_LOG_BIN is 0
 # BUG#42640: mysqld crashes when unsafe statements are executed (STRICT_TRANS_TABLES mode)
 # Bug#45827: Stmt using two autoinc values does not produce unsafe warning
+# BUG#47995: Mark user functions as unsafe
+# BUG#49222: Mare RAND() unsafe
 #
 # ==== Related test cases ====
 #
@@ -462,6 +464,7 @@ DROP TABLE t1,t2,t3;
 
 #
 # BUG#47995: Mark user functions as unsafe
+# BUG#49222: Mare RAND() unsafe
 #
 # Test that the system functions that are supposed to be marked unsafe
 # generate a warning.  Each INSERT statement below should generate a
@@ -472,27 +475,28 @@ SET SESSION binlog_format = STATEMENT;
 CREATE TABLE t1 (a VARCHAR(1000));
 INSERT INTO t1 VALUES (CURRENT_USER());       #marked unsafe before BUG#47995
 INSERT INTO t1 VALUES (FOUND_ROWS());         #marked unsafe before BUG#47995
-INSERT INTO t1 VALUES (GET_LOCK('tmp', 1));
-INSERT INTO t1 VALUES (IS_FREE_LOCK('tmp'));
-INSERT INTO t1 VALUES (IS_USED_LOCK('tmp'));
-INSERT INTO t1 VALUES (LOAD_FILE('../../std_data/words2.dat')); #marked unsafe before BUG#47995
+INSERT INTO t1 VALUES (GET_LOCK('tmp', 1));   #marked unsafe in BUG#47995
+INSERT INTO t1 VALUES (IS_FREE_LOCK('tmp'));  #marked unsafe in BUG#47995
+INSERT INTO t1 VALUES (IS_USED_LOCK('tmp'));  #marked unsafe in BUG#47995
+INSERT INTO t1 VALUES (LOAD_FILE('../../std_data/words2.dat')); #marked unsafe in BUG#39701
 INSERT INTO t1 VALUES (MASTER_POS_WAIT('dummy arg', 4711, 1));
-INSERT INTO t1 VALUES (RELEASE_LOCK('tmp'));
+INSERT INTO t1 VALUES (RELEASE_LOCK('tmp'));  #marked unsafe in BUG#47995
 INSERT INTO t1 VALUES (ROW_COUNT());          #marked unsafe before BUG#47995
 INSERT INTO t1 VALUES (SESSION_USER());       #marked unsafe before BUG#47995
-INSERT INTO t1 VALUES (SLEEP(1));
-INSERT INTO t1 VALUES (SYSDATE());
+INSERT INTO t1 VALUES (SLEEP(1));             #marked unsafe in BUG#47995
+INSERT INTO t1 VALUES (SYSDATE());            #marked unsafe in BUG#47995
 INSERT INTO t1 VALUES (SYSTEM_USER());        #marked unsafe before BUG#47995
 INSERT INTO t1 VALUES (USER());               #marked unsafe before BUG#47995
 INSERT INTO t1 VALUES (UUID());               #marked unsafe before BUG#47995
 INSERT INTO t1 VALUES (UUID_SHORT());         #marked unsafe before BUG#47995
-INSERT INTO t1 VALUES (VERSION());
+INSERT INTO t1 VALUES (VERSION());            #marked unsafe in BUG#47995
+INSERT INTO t1 VALUES (RAND());               #marked unsafe in BUG#49222
 DELETE FROM t1;
 
 # Since we replicate the TIMESTAMP variable, functions affected by the
 # TIMESTAMP variable are safe to replicate.  So we check that the
-# following following functions depend on the TIMESTAMP variable and
-# don't generate a warning.
+# following following functions that depend on the TIMESTAMP variable
+# are not unsafe and don't generate a warning.
 
 SET TIMESTAMP=1000000;
 INSERT INTO t1 VALUES

=== modified file 'mysql-test/suite/rpl/r/rpl_misc_functions.result'
--- a/mysql-test/suite/rpl/r/rpl_misc_functions.result	2008-10-10 09:42:05 +0000
+++ b/mysql-test/suite/rpl/r/rpl_misc_functions.result	2010-01-13 16:51:37 +0000
@@ -4,6 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
+CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
 create table t1(id int, i int, r1 int, r2 int, p varchar(100));
 insert into t1 values(1, connection_id(), 0, 0, "");
 insert into t1 values(2, 0, rand()*1000, rand()*1000, "");

=== modified file 'mysql-test/suite/rpl/r/rpl_nondeterministic_functions.result'
--- a/mysql-test/suite/rpl/r/rpl_nondeterministic_functions.result	2009-11-18 14:50:31 +0000
+++ b/mysql-test/suite/rpl/r/rpl_nondeterministic_functions.result	2010-01-13 09:00:03 +0000
@@ -4,6 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
+CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
 CREATE TABLE t1 (a VARCHAR(1000));
 INSERT INTO t1 VALUES (CONNECTION_ID());
 INSERT INTO t1 VALUES (CONNECTION_ID());

=== modified file 'mysql-test/suite/rpl/r/rpl_optimize.result'
--- a/mysql-test/suite/rpl/r/rpl_optimize.result	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_optimize.result	2010-01-13 09:00:03 +0000
@@ -4,6 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
+CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
 create table t1 (a int not null auto_increment primary key, b int, key(b));
 INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
 INSERT INTO t1 (a) SELECT null FROM t1;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_func003.result'
--- a/mysql-test/suite/rpl/r/rpl_row_func003.result	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_func003.result	2010-01-13 09:00:03 +0000
@@ -4,6 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
+CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
 DROP FUNCTION IF EXISTS test.f1;
 DROP TABLE IF EXISTS test.t1;
 CREATE TABLE test.t1 (a INT NOT NULL AUTO_INCREMENT, c CHAR(16),PRIMARY KEY(a))ENGINE=INNODB;

=== modified file 'mysql-test/suite/rpl/t/rpl_misc_functions.test'
--- a/mysql-test/suite/rpl/t/rpl_misc_functions.test	2008-10-10 09:42:05 +0000
+++ b/mysql-test/suite/rpl/t/rpl_misc_functions.test	2010-01-13 16:51:37 +0000
@@ -3,12 +3,16 @@
 #
 source include/master-slave.inc;
 
+CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
+
 create table t1(id int, i int, r1 int, r2 int, p varchar(100));
 insert into t1 values(1, connection_id(), 0, 0, "");
 # don't put rand and password in the same query, to see if they replicate
 # independently
 # Pure rand test
+--disable_warnings
 insert into t1 values(2, 0, rand()*1000, rand()*1000, "");
+--enable_warnings
 # change the rand suite on the master (we do this because otherwise password()
 # benefits from the fact that the above rand() is well replicated : 
 # it picks the same sequence element, which hides a possible bug in password() replication.
@@ -19,7 +23,9 @@ set sql_log_bin=1;
 # Pure password test
 insert into t1 values(3, 0, 0, 0, password('does_this_work?'));
 # "altogether now"
+--disable_warnings
 insert into t1 values(4, connection_id(), rand()*1000, rand()*1000, password('does_this_still_work?'));
+--enable_warnings
 select * into outfile 'rpl_misc_functions.outfile' from t1;
 let $MYSQLD_DATADIR= `select @@datadir`;
 sync_slave_with_master;
@@ -73,11 +79,13 @@ DELIMITER ;|
 
 # Exercise the functions and procedures then compare the results on
 # the master to those on the slave.
+--disable_warnings
 CALL test_replication_sp1();
 CALL test_replication_sp2();
 INSERT INTO t1 (col_a) VALUES (test_replication_sf());
 INSERT INTO t1 (col_a) VALUES (test_replication_sf());
 INSERT INTO t1 (col_a) VALUES (test_replication_sf());
+--enable_warnings
 
 --sync_slave_with_master
 

=== modified file 'mysql-test/suite/rpl/t/rpl_nondeterministic_functions.test'
--- a/mysql-test/suite/rpl/t/rpl_nondeterministic_functions.test	2009-11-18 14:50:31 +0000
+++ b/mysql-test/suite/rpl/t/rpl_nondeterministic_functions.test	2010-01-13 09:00:03 +0000
@@ -17,6 +17,8 @@
 
 --source include/master-slave.inc
 
+CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
+
 CREATE TABLE t1 (a VARCHAR(1000));
 
 # We replicate the connection_id in the query_log_event
@@ -41,7 +43,9 @@ INSERT INTO t1 VALUES
   (UTC_TIMESTAMP());
 
 # We replicate the random seed in a rand_log_event
+--disable_warnings
 INSERT INTO t1 VALUES (RAND());
+--enable_warnings
 # We replicate the last_insert_id in an intvar_log_event
 INSERT INTO t1 VALUES (LAST_INSERT_ID());
 

=== modified file 'mysql-test/suite/rpl/t/rpl_optimize.test'
--- a/mysql-test/suite/rpl/t/rpl_optimize.test	2009-12-02 14:52:07 +0000
+++ b/mysql-test/suite/rpl/t/rpl_optimize.test	2010-01-13 16:51:37 +0000
@@ -13,6 +13,8 @@
 -- source include/not_ndb_default.inc
 -- source include/master-slave.inc
 
+CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
+
 create table t1 (a int not null auto_increment primary key, b int, key(b));
 INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
 INSERT INTO t1 (a) SELECT null FROM t1;
@@ -30,8 +32,8 @@ INSERT INTO t1 (a) SELECT null FROM t1;
 INSERT INTO t1 (a) SELECT null FROM t1;
 save_master_pos;
 # a few updates to force OPTIMIZE to do something
-update t1 set b=(a/2*rand());
 --disable_warnings
+update t1 set b=(a/2*rand());
 delete from t1 order by b limit 10000;
 --enable_warnings
 

=== modified file 'mysql-test/suite/rpl_ndb_big/r/rpl_ndb_func003.result'
--- a/mysql-test/suite/rpl_ndb_big/r/rpl_ndb_func003.result	2008-09-11 08:01:28 +0000
+++ b/mysql-test/suite/rpl_ndb_big/r/rpl_ndb_func003.result	2010-01-13 16:51:37 +0000
@@ -4,6 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
+CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
 DROP FUNCTION IF EXISTS test.f1;
 DROP TABLE IF EXISTS test.t1;
 CREATE TABLE test.t1 (a INT NOT NULL AUTO_INCREMENT, c CHAR(16),PRIMARY KEY(a))ENGINE=NDB;

=== modified file 'sql/item_create.cc'
--- a/sql/item_create.cc	2009-12-15 06:57:50 +0000
+++ b/sql/item_create.cc	2010-01-13 16:51:37 +0000
@@ -4215,6 +4215,16 @@ Create_func_rand::create_native(THD *thd
   if (item_list != NULL)
     arg_count= item_list->elements;
 
+  /*
+    When RAND() is binlogged, the seed is binlogged too.  So the
+    sequence of random numbers is the same on a replication slave as
+    on the master.  However, if several RAND() values are inserted
+    into a table, the order in which the rows are modified may differ
+    between master and slave, because the order is undefined.  Hence,
+    the statement is unsafe to log in statement format.
+  */
+  thd->lex->set_stmt_unsafe();
+
   switch (arg_count) {
   case 0:
   {


Attachment: [text/bzr-bundle] bzr/sven.sandberg@sun.com-20100113165137-c7mllysvnjfydya4.bundle
Thread
bzr commit into mysql-6.0-codebase branch (sven.sandberg:3823)Bug#49222Sven Sandberg13 Jan