• Venkatesh Duggirala's avatar
    Bug#17047208 REPLICATION DIFFERENCE FOR MULTIPLE TRIGGERS · bb56c30a
    Venkatesh Duggirala authored
        Problem & Analysis: If DML invokes a trigger or a
        stored function that inserts into an AUTO_INCREMENT column,
        that DML has to be marked as 'unsafe' statement. If the
        tables are locked in the transaction prior to DML statement
        (using LOCK TABLES), then the same statement is not marked as
        'unsafe' statement. The logic of checking whether unsafeness
        is protected with if (!thd->locked_tables_mode). Hence if
        we lock the tables prior to DML statement, it is *not* entering
        into this if condition. Hence the statement is not marked
        as unsafe statement.
    
        Fix: Irrespective of locked_tables_mode value, the unsafeness
        check should be done. Now with this patch, the code is moved
        out to 'decide_logging_format()' function where all these checks
        are happening and also with out 'if(!thd->locked_tables_mode)'.
        Along with the specified test case in the bug scenario
        (BINLOG_STMT_UNSAFE_AUTOINC_COLUMNS), we also identified that
        other cases BINLOG_STMT_UNSAFE_AUTOINC_NOT_FIRST,
        BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT, BINLOG_STMT_UNSAFE_INSERT_TWO_KEYS
        are also protected with thd->locked_tables_mode which is not right. All
        of those checks also moved to 'decide_logging_format()' function.
    bb56c30a
sql_lex.h 83.2 KB