• Alfranio Correia's avatar
    BUG#50312 Warnings for unsafe sub-statement not returned to client · 88b32056
    Alfranio Correia authored
                            
    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.
    88b32056
sql_lex.cc 84.9 KB