Bug #50312 Warnings for unsafe sub-statement not returned to client
Submitted: 13 Jan 2010 16:24 Modified: 20 Aug 2010 14:14
Reporter: Sven Sandberg Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:5.1-rep+3, next-mr, 5.5.99-m3, 6.0-codebase OS:Any
Assigned to: Alfranio Tavares Correia Junior CPU Architecture:Any
Tags: regression, unsafe, warnings

[13 Jan 2010 16:24] Sven Sandberg
Description:
When binlog_format=STATEMENT, any statement that may cause the slave to go out of sync generates a warning. The warning is written to the log, the warning count is returned to the client in the server reply, and the warnings are accessible through SHOW WARNINGS. This bug affects only the warning count returned to the client and the warnings visible through SHOW WARNINGS, it does not affect the warnings written to the log.

After BUG#36649 (pushed to next-mr), warnings for sub-statements are cleared when a new sub-statement is started. This is problematic since it suppresses warnings for unsafe statements in some cases. It is important that we always give a warning to the client, because the user needs to know when there is a risk that the slave goes out of sync.

How to repeat:
--source include/have_binlog_format_statement.inc

CREATE TABLE t (a VARCHAR(100));

--delimiter |
CREATE PROCEDURE proc()
BEGIN
  INSERT INTO t VALUES (UUID());  -- unsafe, generates warning
  INSERT INTO t VALUES (1);       -- clears the warning
END|
--delimiter ;
CALL proc();

--delimiter |
CREATE FUNCTION func() RETURNS INT
BEGIN
  INSERT INTO t VALUES (UUID());  -- unsafe, generates warning
  INSERT INTO t VALUES (1);       -- clears the warning
  RETURN 0;
END|
--delimiter ;
SELECT func();

Suggested fix:
Currently, the unsafe warning is generated in binlog_query(). We can change this, so that the warning is generated just before the server sends its reply to the client. Then the warning cannot be cleared out by any subsequent sub-statement.

The implementation of this mechanism is slightly different in next-mr and 5.1-rep+3.
[13 Jan 2010 16:44] Valeriy Kravchuk
Verified just as described. This is what we have now in versions with the fix:

CURRENT_TEST: rpl.bug50312
--- /Users/openxs/dbs/6.0-codebase/mysql-test/suite/rpl/r/bug50312.result	2010-01-13 19:41:30.000000000 +0300
+++ /Users/openxs/dbs/6.0-codebase/mysql-test/suite/rpl/r/bug50312.reject	2010-01-13 19:41:38.000000000 +0300
@@ -0,0 +1,16 @@
+CREATE TABLE t (a VARCHAR(100));
+CREATE PROCEDURE proc()
+BEGIN
+INSERT INTO t VALUES (UUID());  -- unsafe, generates warning
+INSERT INTO t VALUES (1);       -- clears the warning
+END|
+CALL proc();
+CREATE FUNCTION func() RETURNS INT
+BEGIN
+INSERT INTO t VALUES (UUID());  -- unsafe, generates warning
+INSERT INTO t VALUES (1);       -- clears the warning
+RETURN 0;
+END|
+SELECT func();
+func()
+0

while in 5.1.43 from bzr we have (correct):

CURRENT_TEST: rpl.bug50312
--- /Users/openxs/dbs/5.1/mysql-test/suite/rpl/r/bug50312.result	2010-01-13 19:38:33.000000000 +0300
+++ /Users/openxs/dbs/5.1/mysql-test/suite/rpl/r/bug50312.reject	2010-01-13 19:38:54.000000000 +0300
@@ -0,0 +1,20 @@
+CREATE TABLE t (a VARCHAR(100));
+CREATE PROCEDURE proc()
+BEGIN
+INSERT INTO t VALUES (UUID());  -- unsafe, generates warning
+INSERT INTO t VALUES (1);       -- clears the warning
+END|
+CALL proc();
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+CREATE FUNCTION func() RETURNS INT
+BEGIN
+INSERT INTO t VALUES (UUID());  -- unsafe, generates warning
+INSERT INTO t VALUES (1);       -- clears the warning
+RETURN 0;
+END|
+SELECT func();
+func()
+0
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
[13 Jan 2010 16:54] Sven Sandberg
Btw, this was found because binlog_unsafe started to fail in 5.1-rep+3 after merge from next-mr
[13 Jan 2010 23:27] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/96826

2939 Luis Soares	2010-01-13
      Disabled binlog_unsafe due to BUG#50312.
[18 Jan 2010 12:06] Bugs System
Pushed into 6.0.14-alpha (revid:alik@ibmvm-20100118120357-hnzhgadkpzqfnvsc) (version source revid:alik@ibmvm-20100118115413-kd3klpine09yyktw) (merge vers: 6.0.14-alpha) (pib:16)
[18 Jan 2010 12:07] Bugs System
Pushed into mysql-next-mr (revid:alik@ibmvm-20100118120111-73dulkgc893it4r9) (version source revid:alik@ibmvm-20100118115335-0stecyzftqm7bqx6) (pib:16)
[5 Feb 2010 15:44] Konstantin Osipov
I believe this is not a bug.
The server behaves in accordance to the standard.
[25 Feb 2010 13:28] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/101450

2984 Alfranio Correia	2010-02-25
      BUG#50312 Warnings for unsafe sub-statement not returned to client
      
      After BUG#36649, warnings for sub-statements are cleared when a 
      new sub-statement is started. This is problematic since it suppresses
      warnings for unsafe statements in some cases. It is important that we
      always give a warning to the client, because the user needs to know
      when there is a risk that the slave goes out of sync.
      
      We fixed the problem by generating warning messages for unsafe statements
      while calling the functions my_ok and my_eof. We also started checking
      unsafeness when both performance and log tables are used. This is necessary
      after the performance schema which does a distinction between performance
      and log tables.
     @ mysql-test/extra/rpl_tests/create_recursive_construct.inc
        Changed the order of the calls in the procedure because the code
        that checks if a warning message is printed out expects that the
        first statement gives an warning what is not the case for INSERT
        INTO ta$CRC_ARG_level VALUES (47);
     @ mysql-test/suite/binlog/r/binlog_unsafe.result
        There several changes here:
        
        (1) - Changed the CREATE PROCEDURE $CRC.
        
        (2) - The procedure $CRC was failing and the content of the binlog
        was being printed out, after fix (1) the failure disappeared.
        
        (3) - The warning message for unsafeness due to auto-increment collumns was changed.
        
        (4) - The warning message for unsafeness due to VERSION(), RAND() was changed.
        
        (5) - Removed information on log positions from the test case.
     @ mysql-test/suite/binlog/t/binlog_unsafe.test
        Added code to remove information on log positions from the test case.
     @ mysql-test/suite/binlog/t/disabled.def
        Reenabled the test case binlog_unsafe.
     @ sql/sql_class.cc
        Remove the routine that create the warning messages from the THD::binlog_query
        and checked for unsafeness when both performance and log tables where used. 
        After the introduction of the performance schema, we need to check both.
     @ sql/sql_class.h
        The warning messages for unsafe statements are generated before
        changing the diagnostic area in the functions my_ok and my_eof.
[1 Mar 2010 21:43] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/101958

2984 Alfranio Correia	2010-03-01
      BUG#50312 Warnings for unsafe sub-statement not returned to client
      
      After BUG#36649, warnings for sub-statements are cleared when a 
      new sub-statement is started. This is problematic since it suppresses
      warnings for unsafe statements in some cases. It is important that we
      always give a warning to the client, because the user needs to know
      when there is a risk that the slave goes out of sync.
      
      We fixed the problem by generating warning messages for unsafe statements
      while calling the functions my_ok and my_eof. We also started checking
      unsafeness when both performance and log tables are used. This is necessary
      after the performance schema which does a distinction between performance
      and log tables.
     @ mysql-test/extra/rpl_tests/create_recursive_construct.inc
        Changed the order of the calls in the procedure because the code
        that checks if a warning message is printed out expects that the
        first statement gives an warning what is not the case for INSERT
        INTO ta$CRC_ARG_level VALUES (47);
     @ mysql-test/suite/binlog/r/binlog_unsafe.result
        There several changes here:
        
        (1) - Changed the CREATE PROCEDURE $CRC.
        
        (2) - The procedure $CRC was failing and the content of the binlog
        was being printed out, after fix (1) the failure disappeared.
        
        (3) - The warning message for unsafeness due to auto-increment collumns was changed.
        
        (4) - The warning message for unsafeness due to VERSION(), RAND() was changed.
        
        (5) - Removed information on log positions from the test case.
     @ mysql-test/suite/binlog/t/binlog_unsafe.test
        Added code to remove information on log positions from the test case.
     @ mysql-test/suite/binlog/t/disabled.def
        Reenabled the test case binlog_unsafe.
     @ mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result
        Fixed test case.
     @ mysql-test/suite/rpl/r/rpl_stm_found_rows.result
        Fixed teste case.
     @ mysql-test/suite/rpl/r/rpl_stm_mixing_engines.result
        Fixed test case.
     @ sql/sql_class.cc
        Removed the routine that create the warning messages from the THD::binlog_query
        and checked for unsafeness when both performance and log tables where used. 
        After the introduction of the performance schema, we need to check both.
     @ sql/sql_class.h
        The warning messages for unsafe statements are generated before
        changing the diagnostic area in the functions my_ok and my_eof.
        
        A flag to control if the THD::binlog_query was called is also
        added as an warning message is printed out only if the statement
        was logged.
     @ sql/sql_parse.cc
        Reseted the flag that controls if the THD::binlog_query was called.
[6 Mar 2010 11:08] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:vvaintroub@linux-rbsx-20100118220048-5vnyqi5ghsbgmdsd) (merge vers: 5.5.99-m3) (pib:16)
[14 Apr 2010 23:05] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/105680

3155 Alfranio Correia	2010-04-15
      BUG#50312 Warnings for unsafe sub-statement not returned to client
      
      After BUG#36649, warnings for sub-statements are cleared when a 
      new sub-statement is started. This is problematic since it suppresses
      warnings for unsafe statements in some cases. It is important that we
      always give a warning to the client, because the user needs to know
      when there is a risk that the slave goes out of sync.
      
      We fixed the problem by generating warning messages for unsafe statements
      while returning from a stored procedure, function, trigger or while
      executing a top level statement.
      
      We also started checking unsafeness when both performance and log tables are used. 
      This is necessary after the performance schema which does a distinction between
      performance and log tables.
     @ mysql-test/extra/rpl_tests/create_recursive_construct.inc
        Changed the order of the calls in the procedure because the code
        that checks if a warning message is printed out expects that the
        first statement gives an warning what is not the case for INSERT
        INTO ta$CRC_ARG_level VALUES (47);
     @ mysql-test/suite/binlog/r/binlog_unsafe.result
        There are several changes here:
        
        (1) - Changed the CREATE PROCEDURE $CRC.
        
        (2) - The procedure $CRC was failing and the content of the binlog
        was being printed out, after fix (1) the failure disappeared.
        
        (3) - The warning message for unsafeness due to auto-increment collumns was changed.
        
        (4) - The warning message for unsafeness due to VERSION(), RAND() was changed.
        
        (5) - Removed information on log positions from the test case.
     @ mysql-test/suite/binlog/t/binlog_unsafe.test
        Added code to remove information on log positions from the test case.
     @ mysql-test/suite/binlog/t/disabled.def
        Reenabled the test case binlog_unsafe.
     @ mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result
        Fixed test case.
     @ mysql-test/suite/rpl/r/rpl_stm_found_rows.result
        Fixed test case.
     @ mysql-test/suite/rpl/r/rpl_stm_mixing_engines.result
        Fixed test case.
     @ sql/sp_head.cc
        Changed the code to print the warning messages when returning from a stored
        procedure, function or trigger.
     @ sql/sql_class.cc
        Changed the routine in the THD::binlog_query that prints the warning messages
        to avoid trying to print them when inside a stored procedure, function or trigger.
        
        Checked for unsafeness when both performance and log tables where used. 
        After the introduction of the performance schema, we need to check both.
     @ sql/sql_class.h
        The warning messages for unsafe statements are generated before
        changing the diagnostic area in the functions my_ok and my_eof.
        
        A flag to control if the THD::binlog_query was called is also
        added as an warning message is printed out only if the statement
        was logged.
     @ sql/sql_parse.cc
        Reseted the flag that controls if the THD::binlog_query was called.
[22 Apr 2010 15:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/106369

3146 Alfranio Correia	2010-04-22 [merge]
      BUG#50312 Warnings for unsafe sub-statement not returned to client
      
      After BUG#36649, warnings for sub-statements are cleared when a 
      new sub-statement is started. This is problematic since it suppresses
      warnings for unsafe statements in some cases. It is important that we
      always give a warning to the client, because the user needs to know
      when there is a risk that the slave goes out of sync.
      
      We fixed the problem by generating warning messages for unsafe statements
      while returning from a stored procedure, function, trigger or while
      executing a top level statement.
      
      We also started checking unsafeness when both performance and log tables are used. 
      This is necessary after the performance schema which does a distinction between
      performance and log tables.
     @ mysql-test/extra/rpl_tests/create_recursive_construct.inc
        Changed the order of the calls in the procedure because the code
        that checks if a warning message is printed out expects that the
        first statement gives an warning what is not the case for INSERT
        INTO ta$CRC_ARG_level VALUES (47);
     @ mysql-test/suite/binlog/r/binlog_unsafe.result
        There are several changes here:
        
        (1) - Changed the CREATE PROCEDURE $CRC.
        
        (2) - The procedure $CRC was failing and the content of the binlog
        was being printed out, after fix (1) the failure disappeared.
        
        (3) - The warning message for unsafeness due to auto-increment collumns was changed.
        
        (4) - The warning message for unsafeness due to VERSION(), RAND() was changed.
        
        (5) - Removed information on log positions from the test case.
     @ mysql-test/suite/binlog/t/binlog_unsafe.test
        Added code to remove information on log positions from the test case.
     @ mysql-test/suite/binlog/t/disabled.def
        Reenabled the test case binlog_unsafe.
     @ mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result
        Fixed test case.
     @ mysql-test/suite/rpl/r/rpl_stm_found_rows.result
        Fixed test case.
     @ mysql-test/suite/rpl/r/rpl_stm_mixing_engines.result
        Fixed test case.
     @ sql/sp_head.cc
        Changed the code to print the warning messages when returning from a stored
        procedure, function or trigger.
     @ sql/sql_class.cc
        Changed the routine in the THD::binlog_query that prints the warning messages
        to avoid trying to print them when inside a stored procedure, function or trigger.
        
        Checked for unsafeness when both performance and log tables where used. 
        After the introduction of the performance schema, we need to check both.
     @ sql/sql_class.h
        The warning messages for unsafe statements are generated before
        changing the diagnostic area in the functions my_ok and my_eof.
        
        A flag to control if the THD::binlog_query was called is also
        added as an warning message is printed out only if the statement
        was logged.
     @ sql/sql_parse.cc
        Reseted the flag that controls if the THD::binlog_query was called.
[28 May 2010 9:17] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/109453

3072 Alfranio Correia	2010-05-28
      BUG#50312 Warnings for unsafe sub-statement not returned to client
            
      After BUG#36649, warnings for sub-statements are cleared when a 
      new sub-statement is started. This is problematic since it suppresses
      warnings for unsafe statements in some cases. It is important that we
      always give a warning to the client, because the user needs to know
      when there is a risk that the slave goes out of sync.
            
      We fixed the problem by generating warning messages for unsafe statements
      while returning from a stored procedure, function, trigger or while
      executing a top level statement.
            
      We also started checking unsafeness when both performance and log tables are used. 
      This is necessary after the performance schema which does a distinction between
      performance and log tables.
     @ mysql-test/extra/rpl_tests/create_recursive_construct.inc
        Changed the order of the calls in the procedure because the code
        that checks if a warning message is printed out expects that the
        first statement gives an warning what is not the case for INSERT
        INTO ta$CRC_ARG_level VALUES (47);
     @ mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result
        Updated the result file.
     @ mysql-test/suite/binlog/r/binlog_unsafe.result
        There are several changes here:
                
        (1) - Changed the CREATE PROCEDURE $CRC.
                
        (2) - The procedure $CRC was failing and the content of the binlog
        was being printed out, after fix (1) the failure disappeared.
                
        (3) - The warning message for unsafeness due to auto-increment collumns was
        changed.
                
        (4) - The warning message for unsafeness due to VERSION(), RAND() was changed.
                
        (5) - Removed information on log positions from the test case.
     @ mysql-test/suite/binlog/t/binlog_unsafe.test
        Added code to remove information on log positions from the test case.
     @ mysql-test/suite/binlog/t/disabled.def
        Reenabled the test case binlog_unsafe.
     @ mysql-test/suite/rpl/r/rpl_non_direct_stm_mixing_engines.result
        Updated the result file.
     @ mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result
        Updated the result file.
     @ mysql-test/suite/rpl/r/rpl_stm_found_rows.result
        Updated the result file.
     @ mysql-test/suite/rpl/r/rpl_stm_mixing_engines.result
        Updated the result file.
     @ sql/sp_head.cc
        Changed the code to print the warning messages when returning from a
        stored procedure or function.
     @ sql/sql_class.cc
        Changed the routine in the THD::binlog_query that prints the warning messages
        to avoid trying to print them when inside a stored procedure, function or
        trigger.
                
        Checked for unsafeness when both performance and log tables where used.
        After the introduction of the performance schema, we need to check both.
     @ sql/sql_class.h
        Made the issue_unsafe_warnings() function public in order to allow
        it to be called from sp_head.cc
[9 Jul 2010 9:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/113218

3086 Alfranio Correia	2010-07-09
      BUG#50312 Warnings for unsafe sub-statement not returned to client
                  
        After BUG#36649, warnings for sub-statements are cleared when a 
        new sub-statement is started. This is problematic since it suppresses
        warnings for unsafe statements in some cases. It is important that we
        always give a warning to the client, because the user needs to know
        when there is a risk that the slave goes out of sync.
                  
        We fixed the problem by generating warning messages for unsafe statements
        while returning from a stored procedure, function, trigger or while
        executing a top level statement.
                  
        We also started checking unsafeness when both performance and log tables are used. 
        This is necessary after the performance schema which does a distinction between
        performance and log tables.
     @ mysql-test/extra/rpl_tests/create_recursive_construct.inc
        Changed the order of the calls in the procedure because the code
        that checks if a warning message is printed out expects that the
        first statement gives an warning what is not the case for INSERT
        INTO ta$CRC_ARG_level VALUES (47);
     @ mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result
        Updated the result file.
     @ mysql-test/suite/binlog/r/binlog_unsafe.result
        There are several changes here:
                        
          (1) - Changed the CREATE PROCEDURE $CRC.
                        
          (2) - The procedure $CRC was failing and the content of the binlog
                was being printed out, after fix (1) the failure disappeared.
                        
          (3) - The warning message for unsafeness due to auto-increment collumns was
                changed.
                        
          (4) - The warning message for unsafeness due to VERSION(), RAND() was changed.
     @ mysql-test/suite/binlog/t/binlog_unsafe.test
        Reenabled the test case binlog_unsafe.
     @ mysql-test/suite/binlog/t/disabled.def
        Reenabled the test case binlog_unsafe.
     @ mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result
        Updated the result file.
     @ mysql-test/suite/rpl/r/rpl_non_direct_stm_mixing_engines.result
        Updated the result file.
     @ mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result
        Updated the result file.
     @ sql/log.cc
        Rerenced the lex.
     @ sql/log_event.cc
        Rerenced the lex.
     @ sql/sp_head.cc
        Changed the code to print the warning messages when returning from a
        stored procedure or function.
     @ sql/sql_class.cc
        Changed the routine in the THD::binlog_query that prints the warning messages
        to avoid trying to print them when inside a stored procedure, function or
        trigger.
     @ sql/sql_class.h
        Moved the stmt_accessed_table_flag variable and related information to the
        LEX as we need the variable reset after each statement even inside a stored
        procedure, what did not happen if the information was in the THD.
        
        Changed the routine in the THD::binlog_query that prints the warning
        messages to avoid trying to print them when inside a stored procedure,
        function or trigger.
                        
        Checked for unsafeness when both performance and log tables where used.
        After the introduction of the performance schema, we need to check both.
     @ sql/sql_lex.cc
        Moved the stmt_accessed_table_flag variable and related information to the
        LEX as we need the variable reset after each statement even inside a stored
        procedure, what did not happen if the information was in the THD.
     @ sql/sql_lex.h
        Moved the stmt_accessed_table_flag variable and related information to the
        LEX as we need the variable reset after each statement even inside a stored
        procedure, what did not happen if the information was in the THD.
     @ sql/sql_parse.cc
        Moved the stmt_accessed_table_flag variable and related information to the
        LEX as we need the variable reset after each statement even inside a stored
        procedure, what did not happen if the information was in the THD.
[9 Jul 2010 11:11] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/113227

3086 Alfranio Correia	2010-07-09 [merge]
      Merge BUG#50312 into mysql-trunk-bugfixing (local)
     @ sql/log.cc
        Changed the binlog_rollback and use_trans_cache functions.
     @ sql/log_event.cc
        Reorganize the code to make it clear.
[8 Aug 2010 17:48] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/115264

3190 Alfranio Correia	2010-08-08
      BUG#50312 Warnings for unsafe sub-statement not returned to client
                        
      After BUG#36649, warnings for sub-statements are cleared when a 
      new sub-statement is started. This is problematic since it suppresses
      warnings for unsafe statements in some cases. It is important that we
      always give a warning to the client, because the user needs to know
      when there is a risk that the slave goes out of sync.
                        
      We fixed the problem by generating warning messages for unsafe statements
      while returning from a stored procedure, function, trigger or while
      executing a top level statement.
                        
      We also started checking unsafeness when both performance and log tables are
      used. This is necessary after the performance schema which does a distinction
      between performance and log tables.
     @ mysql-test/extra/rpl_tests/create_recursive_construct.inc
        Changed the order of the calls in the procedure because the code
        that checks if a warning message is printed out expects that the
        first statement gives an warning what is not the case for INSERT
        INTO ta$CRC_ARG_level VALUES (47);
     @ mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result
        Updated the result file.
     @ mysql-test/suite/binlog/r/binlog_unsafe.result
        There are several changes here:
        
        (1) - Changed the CREATE PROCEDURE $CRC.
                                
        (2) - The procedure $CRC was failing and the content of the binlog
              was being printed out, after fix (1) the failure disappeared.
                                
        (3) - The warning message for unsafeness due to auto-increment collumns was
              changed.
                                
        (4) - The warning message for unsafeness due to VERSION(), RAND() was changed.
     @ mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test
        Tested filters.
     @ mysql-test/suite/binlog/t/binlog_unsafe.test
        Reenabled the test case binlog_unsafe.
     @ mysql-test/suite/binlog/t/disabled.def
        Reenabled the test case binlog_unsafe.
     @ mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result
        Updated the result file.
     @ mysql-test/suite/rpl/r/rpl_non_direct_stm_mixing_engines.result
        Updated the result file.
     @ mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result
        Updated the result file.
     @ sql/binlog.cc
        Changed the routine in the THD::binlog_query that prints the warning
        messages to avoid trying to print them when inside a stored procedure,
        function or trigger.
                                
        Checked for unsafeness when both performance and log tables where used.
        After the introduction of the performance schema, we need to check both.
     @ sql/sql_class.cc
        Moved the stmt_accessed_table_flag variable and related information to the
        LEX as we need the variable reset after each statement even inside a stored
        procedure, what did not happen if the information was in the THD.
[10 Aug 2010 11:34] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/115398

3172 Alfranio Correia	2010-08-10
      BUG#50312 Warnings for unsafe sub-statement not returned to client
                              
      After BUG#36649, warnings for sub-statements are cleared when a 
      new sub-statement is started. This is problematic since it suppresses
      warnings for unsafe statements in some cases. It is important that we
      always give a warning to the client, because the user needs to know
      when there is a risk that the slave goes out of sync.
                              
      We fixed the problem by generating warning messages for unsafe statements
      while returning from a stored procedure, function, trigger or while
      executing a top level statement.
                              
      We also started checking unsafeness when both performance and log tables are
      used. This is necessary after the performance schema which does a distinction
      between performance and log tables.
     @ mysql-test/extra/rpl_tests/create_recursive_construct.inc
        Changed the order of the calls in the procedure because the code
        that checks if a warning message is printed out expects that the
        first statement gives an warning what is not the case for INSERT
        INTO ta$CRC_ARG_level VALUES (47);
     @ mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result
        Updated the result file.
     @ mysql-test/suite/binlog/r/binlog_unsafe.result
        There are several changes here:
                
        (1) - Changed the CREATE PROCEDURE $CRC.
                                        
        (2) - The procedure $CRC was failing and the content of the binlog
              was being printed out, after fix (1) the failure disappeared.
                                        
        (3) - The warning message for unsafeness due to auto-increment collumns was
              changed.
                                        
        (4) - The warning message for unsafeness due to VERSION(), RAND() was changed.
     @ mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test
        Tested filters.
     @ mysql-test/suite/binlog/t/binlog_unsafe.test
        Reenabled the test case binlog_unsafe.
     @ mysql-test/suite/binlog/t/disabled.def
        Reenabled the test case binlog_unsafe.
     @ mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result
        Updated the result file.
     @ mysql-test/suite/rpl/r/rpl_non_direct_stm_mixing_engines.result
        Updated the result file.
     @ mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result
        Updated the result file.
     @ sql/sql_class.cc
        Moved the stmt_accessed_table_flag variable and related information to the
        LEX as we need the variable reset after each statement even inside a stored
        procedure, what did not happen if the information was in the THD.
                
        Changed the routine in the THD::binlog_query that prints the warning
        messages to avoid trying to print them when inside a stored procedure,
        function or trigger.
                                
        Checked for unsafeness when both performance and log tables where used.
        After the introduction of the performance schema, we need to check both.
[16 Aug 2010 6:30] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@sun.com-20100816062701-qo9dpnk5tkt1pksb) (version source revid:alik@sun.com-20100816062603-xc16eftmv7rmktyq) (merge vers: 5.6.1-m4) (pib:20)
[16 Aug 2010 6:41] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100816062819-bluwgdq8q4xysmlg) (version source revid:alik@sun.com-20100816062612-enatdwnv809iw3s9) (pib:20)
[16 Aug 2010 10:21] Jon Stephens
Documented fix in the 5.6.1 changelog as follows:

        When --binlog_format=STATEMENT, any statement that may cause the
        slave to go out of sync generates a warning. The warning is
        written to the log, the warning count is returned to the client
        in the server's response, and the warnings are accessible
        through SHOW WARNINGS. The current bug affects only the warning
        count returned to the client and the warnings visible through
        SHOW WARNINGS; it does not affect which warnings are written to
        the log.

        The fix for Bug #36649 caused warnings for substatements to be
        cleared whenever a new substatement was started. However, this
        suppressed warnings for unsafe statements in some cases. Now,
        the warning are no longer cleared.

Waiting on 5.5 merge, set NM status.
[20 Aug 2010 14:14] Jon Stephens
Also documented in the 5.5.6 changelog.

Closed-