• Alfranio Correia's avatar
    BUG#53437 @@session.sql_bin_log support in substatements is incorrect · 83575960
    Alfranio Correia authored
          
    The thd->variables.option_bits & OPTION_BIN_LOG is currently abused: 
    it's both a system variable and an implementation switch. The current
    approach to this option bit breaks the session variable encapsulation. 
          
    Besides it is allowed to change @@session.sql_bin_log within a
    transaction what may lead to not correctly logging a transaction.
          
    To fix the problems,  we created a thd->variables variable to represent
    the "sql_log_bin" and prohibited its update inside a transaction or
    sub-statement.
    
    mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result:
      Updated result file. The reason the warnings are removed is
      related to BUG#50312.
    mysql-test/suite/binlog/r/binlog_switch_inside_trans.result:
      Checks when is possible to change the option @@session.sql_log_bin.
    mysql-test/suite/binlog/t/binlog_switch_inside_trans.test:
      Checks when is possible to change the option @@session.sql_log_bin.
    mysql-test/suite/rpl/r/rpl_non_direct_stm_mixing_engines.result:
      Updated the result file with warnings that were being printed
      due to the wrong use of the thd->variables.option_bits and
      sql_log_bin_top_level variables.
    mysql-test/suite/rpl/r/rpl_stm_mixing_engines.result:
      Updated the result file with warnings that were being printed
      due to the wrong use of the thd->variables.option_bits and
      sql_log_bin_top_level variables.
    sql/share/errmsg-utf8.txt:
      Introduces two error messages to notify that the @@session.sql_log_bin
      cannot be changed inside a sub-statement or transaction.
    sql/sql_base.cc:
      Removes the variable sql_log_bin_toplevel and uses
      the session variable sql_log_bin.
    sql/sql_class.cc:
      Replaces the variable sql_log_bin_toplevel by the
      (variables.option_bits & OPTION_BIN_LOG).
    sql/sql_class.h:
      Removes the variable sql_log_bin_toplevel and creates 
      a session variable sql_log_bin.
    sql/sys_vars.cc:
      Checks when the sql_log_bin can be correctly updated.
    83575960
sql_class.h 118 KB