• unknown's avatar
    Bug #45855 row events in binlog after switch from binlog_fmt=mix to stmt with open tmp tbl · 32b6e904
    unknown authored
    Bug #45856  	can't switch from binlog_format=row to mix with open tmp tbl
    
    
    If binlog_format=MIXED, there are open temporary tables, an unsafe statement
    is executed, and the user issues 'SET @@session.binlog_format = STATEMENT',
    then subsequent DML statements will be written in row format despite 
    binlog_format=STATEMENT. Because the binlog format can't be reset to
    statement based by 'reset_current_stmt_binlog_row_based' function.
    
    If binlog_format=ROW, there are open temporary tables, and an unsafe statement
    is executed, then the statement 'SET @@session.binlog_format = MIXED' generates
    the error:
    "Cannot switch out of the row-based binary log format when the session has open
    temporary tables"
    However, it is safe to switch to MIXED mode because events in row format are allowed.
    
    
    To fix the above two problems, generate ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
    and forbid switching from MIXED or ROW to STATEMENT when there are open temp
    tables and we are logging in row format. There is no error in any other case.
    
    
    mysql-test/suite/binlog/r/binlog_format_switch_in_tmp_table.result:
      Test result for bug#45855 and bug#45856.
    mysql-test/suite/binlog/t/binlog_format_switch_in_tmp_table.test:
      Added test file to verify if the program will generate
      ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR error and forbid
      switching from MIXED or ROW to STATEMENT when there are
      open temp tables and we are logging in row format. There
      is no error in any other case.
    32b6e904
set_var.cc 133 KB