1. 10 Jul, 2006 4 commits
    • unknown's avatar
      fixes after merge. Updates to test's results. · 20c59f9c
      unknown authored
      We now reset the THD members related to auto_increment+binlog in
      MYSQL_LOG::write(). This is better than in THD::cleanup_after_query(),
      which was not able to distinguish between SELECT myfunc1(),myfunc2()
      and INSERT INTO t SELECT myfunc1(),myfunc2() from a binlogging point
      of view.
      Rows_log_event::exec_event() now calls lex_start() instead of
      mysql_init_query() because the latter now does too much (it resets
      the binlog format).
      
      
      mysql-test/extra/rpl_tests/rpl_insert_id.test:
        fix after merge
      mysql-test/mysql-test-run.pl:
        -v does not bring useful information when running valgrind; I remove it;
        if you think it's useful add it back.
      mysql-test/r/binlog_stm_mix_innodb_myisam.result:
        Position columns of SHOW BINLOG EVENTS are replaced by # (more robust
        if the size of an event changes).
      mysql-test/r/rpl_insert_id.result:
        fix after merge
      mysql-test/r/rpl_loaddata.result:
        The binlog positions change, because one event disappeared; indeed there
        was this in the binlog (in the current 5.1!):
        SET INSERT_ID=2;
        SET INSERT_ID=1;
        SET TIMESTAMP=1152540671;
        load data LOCAL INFILE '/tmp/SQL_LOAD_MB-1-2' INTO table t1;
        Two INSERT_ID events, useless and a bug. Goes away afer cleaning up
        auto_increment handling.
      mysql-test/r/rpl_switch_stm_row_mixed.result:
        INSERT_ID=5 appears, it's a consequence of having merged the fix
        for BUG#20341
        "stored function inserting into one auto_increment puts bad data in slave".
        In mixed mode, if one substatement of a stored procedure requires row-based,
        the entire procedure uses row-based (was already true for stored functions);
        this is a consequence of not doing the resetting of binlog format inside
        lock_tables() (which didn't work with how the slave thread executes
        row-based binlog events).
      mysql-test/t/rpl_switch_stm_row_mixed.test:
        removing the multi-row delayed insert because in RBR the number of events
        which it generates, is not repeatable (probably depends on how the delayed
        thread groups rows, i.e. dependent on timing).
      sql/ha_partition.cc:
        update to new prototype
      sql/ha_partition.h:
        update to new prototype of the handler:: method.
      sql/handler.cc:
        after-merge fixes (manually merging part which was hard to merge in fmtool)
      sql/log.cc:
        When we write to the binary log, THD's parameters which influenced this
        write are reset: stmt_depends_on_first_successful_insert_id_in_prev_stmt
        and auto_inc_intervals_in_cur_stmt_for_binlog. This is so that future
        writes are not influenced by those and can write their own values.
        As a consequence, when we don't write to the binlog we do not reset.
        This is to abide by the rule that in a complex statement (using triggers etc),
        the first top- or substatement to generate auto_increment ids
        wins their writing to the binlog (that writing may be done by the statement
        itself or by the caller); so for example for
        INSERT INTO t SELECT myfunc() where myfunc() inserts into auto_increment
        and INSERT INTO t does not, myfunc() will fill
        auto_inc_intervals_in_cur_stmt_for_binlog, which will not be reset when
        myfunc() ends, then INSERT INTO t will write to the binlog and thus
        write the preserved auto_inc_intervals_in_cur_stmt_for_binlog.
      sql/log_event.cc:
        mysql_init_query() does too much now to be called in Rows_log_event::exec_event
        (it call mysql_reset_thd_for_next_command() which may switch
        the binlog format now).
        It's ok to call it in Table_map_log_event::exec_event() but its call must
        be before setting the binlog format to "row".
      sql/sql_base.cc:
        Resetting the binlog format in lock_tables() was a bad idea of mine;
        it causes problems in execution of row-based binlog events, where
        the thread sets the binlog format by itself and does not want a next
        lock_tables() to reset the binlog format.
        It is also misleading, for a function named lock_tables(), to reset
        the binlog format.
        As a consequence of this change, in mixed binlogging mode, a routine
        is logged either entirely statement-based or entirely row-based, we
        don't switch in the middle (this was already true for prelocked routines,
        now it's also true for stored procedures).
      sql/sql_class.cc:
        resetting of auto_increment variables used for binlogging is now done
        when writing to the binary log, no need to do the resetting at the end
        of the statement. It is also more correct this way; consider
        SELECT myfunc1(),myfunc2();
        where both functions insert into the same auto_increment column.
        Binlogging is done in 2 events: "SELECT myfunc1()" and "SELECT myfunc2()".
        So each of those needs to have, in binlog, the INSERT_ID which
        it inserted. But as the 2 function calls are executed under prelocked mode,
        the old code didn't reset auto_inc_intervals_in_cur_stmt_for_binlog
        after the first SELECT was binlogged, and so the INSERT_ID of the first
        SELECT was binlogged for the first SELECT and (wrong) also for the 2nd
        SELECT event.
        stmt_depends_on_first_... has the same logic.
      sql/sql_class.h:
        clearer comment
      sql/sql_delete.cc:
        unneeded #ifdef. As we temporarily change the binlog format to "statement"
        before calling mysql_delete(), we must restore it afterwards.
      sql/sql_insert.cc:
        after-merge fixes.
        No need to reset auto_inc_intervals_in_cur_stmt_for_binlog for every
        row in the delayed insert system thread, because we already reset it
        when writing to the binlog.
      sql/sql_parse.cc:
        unneeded #ifdef
      20c59f9c
    • unknown's avatar
      Merge gbichot@bk-internal.mysql.com:/home/bk/mysql-5.1-rpl · 3a3a5622
      unknown authored
      into  gbichot3.local:/home/mysql_src/mysql-5.1
      
      
      mysql-test/mysql-test-run.pl:
        Auto merged
      sql/sql_base.cc:
        Auto merged
      3a3a5622
    • unknown's avatar
      Merge romeo.(none):/home/bkroot/mysql-5.1-new-rpl · 45f56813
      unknown authored
      into  romeo.(none):/home/bk/b20821-mysql-5.1-new-rpl
      
      
      45f56813
    • unknown's avatar
      Fixing problem where the command line for MYSQL_DUMP_SLAVE was not · 00abe212
      unknown authored
      set properly.
      
      
      00abe212
  2. 09 Jul, 2006 10 commits
    • unknown's avatar
      Merge gbichot3.local:/home/mysql_src/mysql-5.1-interval-move-next-insert-id · 9939a66b
      unknown authored
      into  gbichot3.local:/home/mysql_src/mysql-5.1
      
      
      sql/ha_federated.cc:
        Auto merged
      sql/ha_ndbcluster.cc:
        Auto merged
      sql/handler.h:
        Auto merged
      sql/log_event.cc:
        Auto merged
      sql/set_var.cc:
        Auto merged
      sql/sql_class.cc:
        Auto merged
      sql/sql_class.h:
        Auto merged
      sql/sql_parse.cc:
        Auto merged
      sql/sql_select.cc:
        Auto merged
      sql/sql_table.cc:
        Auto merged
      sql/sql_update.cc:
        Auto merged
      sql/handler.cc:
        will fix by hand
      mysql-test/extra/rpl_tests/rpl_insert_id.test:
        merge
      mysql-test/r/rpl_insert_id.result:
        merge
      sql/sql_insert.cc:
        merge
      9939a66b
    • unknown's avatar
      post-merge test/result fixes. · e0ef4b1e
      unknown authored
      
      mysql-test/r/rpl_switch_stm_row_mixed.result:
        post-merge fix
      mysql-test/t/rpl_switch_stm_row_mixed.test:
        post-merge fix (and no need to use a table t12 in some place).
      e0ef4b1e
    • unknown's avatar
      Merge gbichot3.local:/home/mysql_src/mysql-5.1-new-19630 · 53641471
      unknown authored
      into  gbichot3.local:/home/mysql_src/mysql-5.1
      
      
      mysql-test/t/disabled.def:
        Auto merged
      sql/set_var.cc:
        Auto merged
      sql/sql_class.h:
        Auto merged
      mysql-test/r/rpl_switch_stm_row_mixed.result:
        manual merge (will fix)
      mysql-test/t/rpl_switch_stm_row_mixed.test:
        manual merge (will fix)
      53641471
    • unknown's avatar
      fixes in test results (using # for positions in SHOW BINLOG EVENTS). · f94e8d78
      unknown authored
      
      mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
        As in other tests, we should replace both position columns of SHOW BINLOG
        EVENTS; otherwise a small change (like here, the fact that CREATE TEMPORARY
        TABLE is not binlogged in RBR as a consequence of the bugfix for BUG#20522)
        causes a large diff in the result file.
      mysql-test/r/binlog_row_mix_innodb_myisam.result:
        result update: positions in SHOW BINLOG EVENTS become #, and
        the CREATE TEMPORARY TABLE disappear from binlog (consequence of fix for
        BUG#20522 "RBR: CREATE TEMPORARY TABLE SELECT writes to binlog though
        unneeded").
      f94e8d78
    • unknown's avatar
      post-merge fixes · 15c321f6
      unknown authored
      
      mysql-test/r/rpl_switch_stm_row_mixed.result:
        result update.
        I noticed the appearance of an additional table_map+rows in the binlog
        when INSERT DELAYED, since I pulled the latest fixes to RBR of 
        INSERT DELAYED. This is ok, I put the reason why into sql_insert.cc.
      sql/sql_insert.cc:
        A comment about the new row-based binlogging of INSERT DELAYED.
        Removing duplicate MY_HOOKS (from a wrong merge of the past??).
      15c321f6
    • unknown's avatar
      Merge gbichot3.local:/home/mysql_src/mysql-5.1-new-WL3146-handler · 9fe33acb
      unknown authored
      into  gbichot3.local:/home/mysql_src/mysql-5.1
      
      
      sql/sql_insert.cc:
        Auto merged
      9fe33acb
    • unknown's avatar
      Manual merge of test from 5.0 (needs to be manual because the test files · 94201860
      unknown authored
      were copied/split between 5.0 and 5.1).
      
      
      mysql-test/extra/rpl_tests/rpl_auto_increment.test:
        manual merge of test from 5.0
      mysql-test/extra/rpl_tests/rpl_insert_id.test:
        manuel merge of test from 5.0
      mysql-test/r/rpl_auto_increment.result:
        error messages changed compared to 5.0
      94201860
    • unknown's avatar
      Merge gbichot3.local:/home/mysql_src/mysql-5.0 · f85f9ac2
      unknown authored
      into  gbichot3.local:/home/mysql_src/mysql-5.1
      
      
      mysql-test/r/rpl_auto_increment.result:
        Auto merged
      mysql-test/r/rpl_insert_id.result:
        Auto merged
      mysql-test/t/rpl_openssl.test:
        Auto merged
      sql/ha_ndbcluster.cc:
        Auto merged
      mysql-test/t/rpl_auto_increment.test:
        will fix by hand
      mysql-test/t/rpl_insert_id.test:
        will fix by hand
      sql/handler.cc:
        comment
      sql/handler.h:
        manual merge
      sql/sql_insert.cc:
        manual merge
      f85f9ac2
    • unknown's avatar
      WL#3146 "less locking in auto_increment": · 60272e75
      unknown authored
      this is a cleanup patch for our current auto_increment handling:
      new names for auto_increment variables in THD, new methods to manipulate them
      (see sql_class.h), some move into handler::, causing less backup/restore
      work when executing substatements. 
      This makes the logic hopefully clearer, less work is is needed in
      mysql_insert().
      By cleaning up, using different variables for different purposes (instead
      of one for 3 things...), we fix those bugs, which someone may want to fix
      in 5.0 too:
      BUG#20339 "stored procedure using LAST_INSERT_ID() does not replicate
      statement-based"
      BUG#20341 "stored function inserting into one auto_increment puts bad
      data in slave"
      BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY UPDATE"
      (now if a row is updated, LAST_INSERT_ID() will return its id)
      and re-fixes:
      BUG#6880 "LAST_INSERT_ID() value changes during multi-row INSERT"
      (already fixed differently by Ramil in 4.1)
      Test of documented behaviour of mysql_insert_id() (there was no test).
      The behaviour changes introduced are:
      - LAST_INSERT_ID() now returns "the first autogenerated auto_increment value
      successfully inserted", instead of "the first autogenerated auto_increment
      value if any row was successfully inserted", see auto_increment.test.
      Same for mysql_insert_id(), see mysql_client_test.c.
      - LAST_INSERT_ID() returns the id of the updated row if ON DUPLICATE KEY
      UPDATE, see auto_increment.test. Same for mysql_insert_id(), see
      mysql_client_test.c.
      - LAST_INSERT_ID() does not change if no autogenerated value was successfully 
      inserted (it used to then be 0), see auto_increment.test.
      - if in INSERT SELECT no autogenerated value was successfully inserted,
      mysql_insert_id() now returns the id of the last inserted row (it already
      did this for INSERT VALUES), see mysql_client_test.c.
      - if INSERT SELECT uses LAST_INSERT_ID(X), mysql_insert_id() now returns X
      (it already did this for INSERT VALUES), see mysql_client_test.c.
      - NDB now behaves like other engines wrt SET INSERT_ID: with INSERT IGNORE,
      the id passed in SET INSERT_ID is re-used until a row succeeds; SET INSERT_ID
      influences not only the first row now.
      
      Additionally, when unlocking a table we check that the thread is not keeping
      a next_insert_id (as the table is unlocked that id is potentially out-of-date);
      forgetting about this next_insert_id is done in a new
      handler::ha_release_auto_increment().
      
      Finally we prepare for engines capable of reserving finite-length intervals
      of auto_increment values: we store such intervals in THD. The next step
      (to be done by the replication team in 5.1) is to read those intervals from
      THD and actually store them in the statement-based binary log. NDB
      will be a good engine to test that.
      
      
      mysql-test/extra/binlog_tests/binlog.test:
        Testing that if INSERT_ID is set to a value too big for the
        column's type, the binlogged INSERT_ID is the truncated value
        (important if slave has a column of a "wider" numeric type).
        Testing binlogging of INSERT_ID with INSERT DELAYED, to be sure that 
        we binlog an INSERT_ID event only for the delayed rows which use one.
      mysql-test/extra/rpl_tests/rpl_insert_id.test:
        Testcase for BUG#20339 "stored procedure using
        LAST_INSERT_ID() does not replicate statement-based".
        Testcase for BUG#20341 "stored function inserting into one
        auto_increment puts bad data in slave".
      mysql-test/extra/rpl_tests/rpl_loaddata.test:
        Test that LOAD DATA INFILE sets a value for a future LAST_INSERT_ID().
      mysql-test/r/auto_increment.result:
        behaviour change: when INSERT totally fails (not even succeeds
        partially and then rolls back), don't change last_insert_id().
        Behaviour change: LAST_INSERT_ID() is now the first successfully inserted,
        autogenerated, id.
        Behaviour change: if INSERT ON DUPLICATE KEY UPDATE, if the table has auto_increment
        and a row is updated, then LAST_INSERT_ID() returns the id of this row.
      mysql-test/r/binlog_row_binlog.result:
        result update
      mysql-test/r/binlog_stm_binlog.result:
        result update
      mysql-test/r/insert.result:
        result update
      mysql-test/r/rpl_insert_id.result:
        result update
      mysql-test/r/rpl_loaddata.result:
        result update
      mysql-test/r/rpl_ndb_auto_inc.result:
        ndb's behaviour is now like other engines wrt SET INSERT_ID
        in a multi-row INSERT:
        - with INSERT IGNORE: the id passed in SET INSERT_ID is re-used until
        a row succeeds.
        - generally, SET INSERT_ID sets the first value and other values are
        simply computed from this first value, instead of previously where
        the 2nd and subsequent values where not influenced by SET INSERT_ID;
        this good change is due to the removal of "thd->next_insert_id=0"
        from ha_ndbcluster.
      mysql-test/t/auto_increment.test:
        A testcase of BUG#19243: if ON DUPLICATE KEY UPDATE updates a row,
        LAST_INSERT_ID() now returns the id of the row.
        Test of new behaviour of last_insert_id() when no autogenerated value was
        inserted, or when only some autogenerated value (not the first of them) was
        inserted.
      mysql-test/t/insert.test:
        testing INSERT IGNORE re-using generated values
      sql/ha_federated.cc:
        update for new variables.
      sql/ha_ndbcluster.cc:
        handler::auto_increment_column_changed not needed, equivalent to
        (insert_id_for_cur_row > 0).
        thd->next_insert_id=0 not needed anymore; it was used to force
        handler::update_auto_increment() to call ha_ndbcluster::get_auto_increment()
        for each row of a multi-row INSERT, now this happens naturally
        because NDB says "I have reserved you *one* value" in get_auto_increment(),
        so handler::update_auto_increment() calls again for next row.
      sql/handler.cc:
        More comments, use of new methods and variables. Hopes to be clearer
        than current code.
        thd->prev_insert_id not in THD anymore: it is managed locally by inserters
        (like mysql_insert()).
        THD::clear_next_insert_id is now equivalent to
        handler::next_insert_id > 0.
        get_auto_increment() reserves an interval of values from the engine,
        uses this interval for next rows of the statement, until interval
        is exhausted then it asks for another interval (of a bigger size
        than the first one; size doubles until reaching 65535 then it stays constant).
        If doing statement-based binlogging, intervals are remembered in a list
        for storage in the binlog.
        For "forced" insert_id values (SET INSERT_ID or replication slave),
        forced_auto_inc_intervals is non-empty and the handler takes its intervals
        from there, without calling get_auto_increment().
        ha_release_auto_increment() resets the handler's auto_increment variables;
        it calls release_auto_increment() which is handler-dependent and
        serves to return to the engine any unused tail of the last used
        interval.
        If ending a statement, next_insert_id>0 means that autoinc values have been
        generated or taken from the master's binlog (in a replication slave) so
        we clear those values read from binlog, so that next top- or sub-
        statement does not use them.
      sql/handler.h:
        handler::auto_increment_changed can be replaced by
        (handler::insert_id_for_cur_row > 0).
        THD::next_insert_id moves into handler (more natural, and prepares
        for the day when we'll support a single statement inserting into
        two tables - "multi-table INSERT" like we have UPDATE - will this
        happen?).
        This move makes the backup/restore of THD::next_insert_id when entering
        a substatement unneeded, as each substatement has its own handler
        objects.
      sql/item_func.cc:
        new names for variables.
        For the setting of what mysql_insert_id() will return to the client,
        LAST_INSERT_ID(X) used to simply pretend that the generated autoinc
        value for the current row was X, but this led to having no reliable
        way to know the really generated value, so we now have a bool:
        thd->arg_of_last_insert_id_function which enables us to know that
        LAST_INSERT_ID(X) was called (and then X can be found in
        thd->first_successful_insert_id_in_prev_stmt).
      sql/log.cc:
        new variable names for insert_ids. Removing some unused variables in the slow
        log.
      sql/log_event.cc:
        new variable names, comments. Preparing for when master's won't binlog
        LAST_INSERT_ID if it was 0.
      sql/set_var.cc:
        new variable names.
        The last change repeats how Bar fixed BUG#20392
        "INSERT_ID session variable has weird value" in 5.0.
      sql/sql_class.cc:
        new variables for insert_id. In THD::cleanup_after_query() we fix
        BUG#20339 "stored procedure using LAST_INSERT_ID() does not replicate
        statement-based" (will one want to fix it in 5.0?). Many comments
        about what stored functions do to auto_increment.
        In reset|restore_sub_statement_state(), we need to backup less
        auto_inc variables as some of them have moved to the handler;
        we backup/restore those which are about the current top- or sub-
        statement, *not* those about the statement-based binlog
        (which evolve as the top- and sub-statement execute).
        Because we split THD::last_insert_id into 
        THD::first_successful_insert_id_in_prev_stmt and
        THD::auto_inc_intervals_for_binlog (among others), we fix
        BUG#20341 "stored function inserting into one auto_increment
        puts bad data in slave": indeed we can afford to not backup/restore
        THD::auto_inc_intervals_for_binlog (which fixes the bug) while still
        backing up / restoring THD::first_successful_insert_id_in_prev_stmt
        (ensuring that the top-level LAST_INSERT_ID() is not affected by INSERTs
        done by sub-statements, as is desirable and tested in rpl_insert_id.test).
      sql/sql_class.h:
        new variables and methods for auto_increment.
        Some THD members move into handler (those which are really about
        the table being inserted), some stay in THD (those which are
        about what a future LAST_INSERT_ID() should return, or about
        what should be stored into the statement-based binlog).
        THD::next_insert_id moves to handler::.
        THD::clear_next_insert_id removed (had become equivalent
        to next_insert_id > 0).
        THD::last_insert_id becomes four:
        THD::first_successful_insert_id_in_cur_stmt,
        THD::auto_inc_intervals_for_binlog,
        handler::insert_id_for_cur_row,
        THD::first_successful_insert_id_in_prev_stmt.
        THD::current_insert_id becomes:
        THD::first_successful_insert_id_in_prev_stmt_for_binlog
        THD::prev_insert_id is removed, handler can just use
        handler::insert_id_for_cur_row instead (which is more accurate:
        for the first row, prev_insert_id was set before get_auto_increment
        was called, so was 0, causing a call to
        get_auto_increment() for the 2nd row if the 1st row fails;
        here we don't need the call as insert_id_for_cur_row has
        the value of the first row).
        THD::last_insert_id_used becomes: stmt_depends_on_first_row_in_prev_stmt
        THD::insert_id_used is removed (equivalent to
        auto_inc_intervals_for_binlog non empty).
        The interval returned by get_auto_increment() and currently being
        consumed is handler::auto_inc_interval_for_cur_row.
        Comments to explain each of them.
        select_insert::last_insert_id becomes autoinc_value_of_last_inserted_row.
      sql/sql_insert.cc:
        the "id" variable is not changed for each row now; it used to compensate for
        this contradiction:
        - thd->last_insert_id supposed job was to keep the id of the first row
        - but it was updated for every row
        - so mysql_insert() made sure to catch its first value and restore it at the end of stmt.
        Now THD keeps the first value in first_successful_insert_id_in_cur_stmt,
        and value of the row in insert_id_for_cur_row. So "id" only serves to fill
        mysql_insert_id(), as depending on some conditions, "id" must be different
        values.
        Prev_insert_id moves from THD to write_record().
        We now set LAST_INSERT_ID() in ON DUPLICATE KEY UPDATE too (BUG#19243).
        In an INSERT DELAYED, we still "reset auto-increment caching" but differently
        (by calling ha_release_auto_increment()).
      sql/sql_load.cc:
        no need to fiddle with "id", THD maintains
        THD::first_successful_insert_id_in_cur_stmt by itself and correctly now.
        ha_release_auto_increment() is now (logically) called before we unlock
        the table.
      sql/sql_parse.cc:
        update to new variable names.
        Assertion that reset_thd_for_next_command() is not called for every
        substatement of a routine (I'm not against it, but if we do this change,
        statement-based binlogging needs some adjustments).
      sql/sql_select.cc:
        update for new variable names
      sql/sql_table.cc:
        next_insert_id not needed in mysql_alter_table(), THD manages.
      sql/sql_update.cc:
        update for new variable names.
        Even though this is UPDATE, an insert id can be generated (by
        LAST_INSERT_ID(X)) and should be recorded because mysql_insert_id() wants
        to know about it.
      sql/structs.h:
        A class for "discrete" intervals (intervals of integer numbers with a certain
        increment between them): Discrete_interval, and a class for a list of such
        intervals: Discrete_intervals_list
      tests/mysql_client_test.c:
        tests of behaviour of mysql_insert_id(): there were no such tests, while in
        our manual we document its behaviour. In comments you'll notice the behaviour
        changes introduced (there are 5).
      60272e75
    • unknown's avatar
      * Mixed replication mode * : · 81a80049
      unknown authored
      1) Fix for BUG#19630 "stored function inserting into two auto_increment breaks
      statement-based binlog":
      a stored function inserting into two such tables may fail to replicate
      (inserting wrong data in the slave's copy of the second table) if the slave's
      second table had an internal auto_increment counter different from master's.
      Because the auto_increment value autogenerated by master for the 2nd table
      does not go into binlog, only the first does, so the slave lacks information.
      To fix this, if running in mixed binlogging mode, if the stored function or
      trigger plans to update two different tables both having auto_increment
      columns, we switch to row-based for the whole function.
      We don't have a simple solution for statement-based binlogging mode, there
      the bug remains and will be documented as a known problem.
      Re-enabling rpl_switch_stm_row_mixed.
      2) Fix for BUG#20630 "Mixed binlogging mode does not work with stored
      functions, triggers, views", which was a documented limitation (in mixed
      mode, we didn't detect that a stored function's execution needed row-based
      binlogging (due to some UUID() call for example); same for
      triggers, same for views (a view created from a SELECT UUID(), and doing
      INSERT INTO sometable SELECT theview; would not replicate row-based).
      This is implemented by, after parsing a routine's body, remembering in sp_head
      that this routine needs row-based binlogging. Then when this routine is used,
      the caller is marked to require row-based binlogging too.
      Same for views: when we parse a view and detect that its SELECT needs
      row-based binary logging, we mark the calling LEX as such.
      3) Fix for BUG#20499 "mixed mode with temporary table breaks binlog":
      a temporary table containing e.g. UUID has its changes not binlogged,
      so any query updating a permanent table with data from the temporary table
      will run wrongly on slave. Solution: in mixed mode we don't switch back
      from row-based to statement-based when there exists temporary tables.
      4) Attempt to test mysqlbinlog on a binlog generated by mysqlbinlog;
      impossible due to BUG#11312 and BUG#20329, but test is in place for when
      they are fixed.
      
      
      mysql-test/r/rpl_switch_stm_row_mixed.result:
        testing BUG#19630 "stored function inserting into two auto_increment breaks
        statement-based binlog",
        testing BUG#20930 "Mixed binlogging mode does not work with stored functions,
        triggers, views.
        testing BUG#20499 "mixed mode with temporary table breaks binlog".
        I have carefully checked this big result file, it is correct.
      mysql-test/t/disabled.def:
        re-enabling test
      mysql-test/t/rpl_switch_stm_row_mixed.test:
        Test for BUG#19630 "stored function inserting into two auto_increment breaks
        statement-based binlog":
        we test that it goes row-based, but only when needed;
        without the bugfix, master and slave's data differed.
        Test for BUG#20499 "mixed mode with temporary table breaks binlog":
        without the bugfix, slave had 2 rows, not 3.
        Test for BUG#20930 "Mixed binlogging mode does not work with stored
        functions, triggers, views".
        Making strings used more different, for easier tracking of "by which routine
        was this binlog line generated".
        Towards the end, an attempt to test mysqlbinlog on a binlog generated by
        the mixed mode; attempt failed because of BUG#11312 and BUG#20929.
      sql/item_create.cc:
        fix for build without row-based replication
      sql/set_var.cc:
        cosmetic: in_sub_stmt is exactly meant to say if we are in stored
        function/trigger, so better use it.
      sql/sp.cc:
        When a routine adds its tables to the top statement's tables, if this routine
        needs row-based binlogging, mark the entire top statement as well.
        Same for triggers.
        Needed for making the mixed replication mode work with stored functions
        and triggers.
      sql/sp_head.cc:
        new enum value for sp_head::m_flags, remembers if, when parsing the 
        routine, we found at least one element (UUID(), UDF) requiring row-based
        binlogging.
      sql/sp_head.h:
        new enum value for sp_head::m_flags (see sp_head.cc).
        An utility method, intended for attributes of a routine which need
        to propagate upwards to the caller; so far only used for binlogging
        information, but open to any other attribute.
      sql/sql_base.cc:
        For BUG#19630 "stored function inserting into two auto_increment
        breaks statement-based binlog":
        When we come to locking tables, we have collected all tables used by
        functions, views and triggers, we detect if we're going to update two tables
        having auto_increment columns. If yes, statement-based binlogging won't work
        (Intvar_log_event records only one insert_id) so, if in mixed binlogging
        mode, switch to row-based.
        For making mixed mode work with stored functions using UUID/UDF:
        when we come to locking tables, we have parsed the whole body so know if
        some elements need row-based. Generation of row-based binlog events
        depends on locked tables, so this is the good place to decide of the binlog
        format.
      sql/sql_class.h:
        Fix for BUG#20499 "mixed mode with temporary table breaks binlog".
        Making mixed mode work with stored functions/triggers: don't reset
        back to statement-based if in executing a stored function/trigger.
      sql/sql_lex.cc:
        fix for build without row-based replication.
        binlog_row_based_if_mixed moves from st_lex to Query_tables_list, because
        that boolean should not be affected when a SELECT reads the INFORMATION_SCHEMA
        and thus implicitely parses a view or routine's body: this body may
        contain needing-row-based components like UUID() but the SELECT on
        INFORMATION_SCHEMA should not be affected by that and should not use
        row-based; as Query_tables_list is backed-up/reset/restored when parsing
        the view/routine's body, so does binlog_row_based_if_mixed and the
        top SELECT is not affected.
      sql/sql_lex.h:
        fix for build without row-based replication.
        binlog_row_based_if_mixed moves from st_lex to Query_tables_list
        (see sql_lex.cc)
      sql/sql_parse.cc:
        For the mixed mode to work with stored functions using UUID and UDF, we need
        to move the switch-back-from-row-to-statement out of
        mysql_execute_command() (which is executed for each statement, causing
        the binlogging mode to change in the middle of the function, which would
        not work)
        The switch to row-based is now done in lock_tables(), no need to keep it
        in mysql_execute_command(); in lock_tables() we also switch back from 
        row-based to statement-based (so in a stored procedure, all statements
        have their binlogging mode). We must however keep a resetting in
        mysql_reset_thd_for_next_command() as e.g. CREATE PROCEDURE does not call
        lock_tables().
      sql/sql_view.cc:
        When a view's body needs row-based binlogging (e.g. the view is created
        from SELECT UUID()), propagate this fact to the top st_lex.
      sql/sql_yacc.yy:
        use TRUE instead of 1, for binlog_row_based_if_mixed.
      81a80049
  3. 08 Jul, 2006 3 commits
    • unknown's avatar
      BUG#19188 incorrect temporary table name of DROP query in replication · b94d70a6
      unknown authored
      manual merge of 5.0 patch and fixing an issue with closing temp tables when no binlog or RBR.
      Note, that despite temporary_tables is indeed double-linked list in 5.1 (patch for bug #19881) it is still enough to use only 'next' reference, as it was done for 5.0, when the list is sorted and 
      destoyed after.
      
      
      mysql-test/r/rpl_temporary.result:
        results changed
      mysql-test/t/rpl_temporary.test:
        fixing kill stmt for a thread with temp tables. Restoring check of temp table with accent char.
      sql/sql_base.cc:
        manual merge part 2. Leaving only extensively refactored close_temporary_tables from local rep.
      b94d70a6
    • unknown's avatar
      Merge dsl-hkigw8-feb1fb00-100.dhcp.inet.fi:/usr_rh9/home/elkin.rh9/MySQL/TEAM/BARE/5.1 · 1730c0c7
      unknown authored
      into  dsl-hkigw8-feb1fb00-100.dhcp.inet.fi:/usr_rh9/home/elkin.rh9/MySQL/TEAM/FIXES/5.1/bug19188_graved_temp
      
      
      1730c0c7
    • unknown's avatar
      BUG#20821 (INSERT DELAYED failes to write some rows to binlog): · a92e1c4a
      unknown authored
      Fixing typo and potential memory problem.
      Reducing number of concurrent mysqlslap threads since tests fail
      in pushbuild due to too many threads.
      
      
      mysql-test/r/rpl_insert.result:
        Result change.
      mysql-test/t/rpl_insert.test:
        Reducing number of threads since it doesn't pass pushbuild.
      sql/sql_insert.cc:
        Fixing typo and potential memory problem.
      a92e1c4a
  4. 07 Jul, 2006 11 commits
  5. 06 Jul, 2006 8 commits
    • unknown's avatar
      Testcase for BUG#20633 "INSERT DELAYED RAND() or @user_var does not replicate · d2dc70dc
      unknown authored
      statement-based" (bugfix was committed today):
      we verify that now it works in mixed mode. And a comment.
      
      
      mysql-test/r/rpl_switch_stm_row_mixed.result:
        result update
      mysql-test/t/rpl_switch_stm_row_mixed.test:
        testcase for BUG#20633
      sql/sql_insert.cc:
        the #ifdef was not necessary; a comment.
      d2dc70dc
    • unknown's avatar
      Fix for BUG#20349 "mysql-test-run.pl needs to add --debug to · 94b92361
      unknown authored
      mysql_client_test like mysql-test-run". Nothing to document.
      
      
      mysql-test/mysql-test-run.pl:
        if --debug, add debugging of mysql_client_test (useful at least to know what
        insert_id values it receives in the ok packets of INSERT).
      94b92361
    • unknown's avatar
      Merge gbichot3.local:/home/mysql_src/mysql-5.1 · b5faf11a
      unknown authored
      into  gbichot3.local:/home/mysql_src/mysql-5.1-new-WL3146-handler
      
      
      mysql-test/mysql-test-run.pl:
        Auto merged
      mysql-test/r/rpl_row_create_table.result:
        Auto merged
      mysql-test/t/rpl_row_create_table.test:
        Auto merged
      sql/sql_class.h:
        Auto merged
      sql/sql_insert.cc:
        Auto merged
      b5faf11a
    • unknown's avatar
      Fix for BUG#20649 "mixed replication mode does not work with INSERT DELAYED". · 986679a2
      unknown authored
      The bug was that if the server was running in mixed binlogging mode,
      and an INSERT DELAYED used some needing-row-based components like UUID(),
      the server didn't binlog this row-based but statement-based, which
      thus failed to insert correct data on the slave.
      This changeset implements that when a delayed_insert thread is created,
      if the server's global binlog mode is "mixed", that thread will use row-based.
      This also fixes BUG#20633 "INSERT DELAYED RAND() or @user_var does not
      replicate statement-based": we don't fix it in statement-based mode (would
      require bookeeping of rand seeds and user variables used by each row),
      but at least it will now work in mixed mode (as row-based will be used).
      We re-enable rpl_switch_stm_row_mixed.test (so BUG#18590
      which was about re-enabling this test, will be closed) to test the fixes.
      Between when it was disabled and now, some good changes to row-based
      binlogging (no generation of table map events for non-changed tables)
      induce changes in the test's result file.
      
      
      mysql-test/r/rpl_switch_stm_row_mixed.result:
        result update.
        Note that some pieces of binlog are gone, not due to my test but to changes
        to the row-based binlogging code (non-changed tables don't generate
        table map binlog events now) done while the test was disabled.
      mysql-test/t/disabled.def:
        this test works now
      mysql-test/t/rpl_switch_stm_row_mixed.test:
        testing fix to make INSERT DELAYED work in mixed mode
      sql/sql_insert.cc:
        In mixed binlogging mode, the delayed_insert system thread now always
        uses row-based binlogging.
        This makes replication of INSERT DELAYED VALUES(RAND()) or VALUES(@A)
        work in mixed mode (it does not in statement-based).
      986679a2
    • unknown's avatar
      Behaviour change of mysql-test-run.pl: · 81bb604c
      unknown authored
      by default we never run disabled tests (even if they're
      explicitely listed on the command-line). We add an option --enable-disabled
      which will run tests even though they are disabled, and will print, for each
      such test, the comment explaining why it was disabled.
      The reason for the change is when you want to run "all tests which are about
      NDB" for example: mysql-test-run.pl t/*ndb*.test used to run some disabled
      NDB tests, causing failures, causing investigations.
      Code amended and approved by Kent.
      
      
      mysql-test/lib/mtr_cases.pl:
        always detect if a test is listed as disabled, and read the comment why is is.
        If it is listed, don't run the test, except if
        --enable-disabled was given, then mark the test as to-run-even-
        though-it-is-listed-as-disabled.
      mysql-test/lib/mtr_report.pl:
        Report tests which will run though they are listed as disabled
        (does something only if --enable-disabled).
      mysql-test/mysql-test-run.pl:
        New behaviour: by default we never run disabled tests (even if they're
        explicitely listed on the command-line). We add an option --enable-disabled
        which will run tests even though they are disabled, and will print, for each
        such test, the comment explaining why it was disabled.
      81bb604c
    • unknown's avatar
      Merge gbichot@bk-internal.mysql.com:/home/bk/mysql-5.0-rpl · 9ba38382
      unknown authored
      into  gbichot3.local:/home/mysql_src/mysql-5.0
      
      
      9ba38382
    • unknown's avatar
      Merge gbichot3.local:/home/mysql_src/mysql-5.0-20524 · 90cf816f
      unknown authored
      into  gbichot3.local:/home/mysql_src/mysql-5.0
      
      
      sql/handler.cc:
        Auto merged
      sql/handler.h:
        Auto merged
      sql/sql_insert.cc:
        Auto merged
      90cf816f
    • unknown's avatar
      Fix for BUG#20524 "auto_increment_* not observed when inserting · 8646be88
      unknown authored
      a too large value": the bug was that if MySQL generated a value for an
      auto_increment column, based on auto_increment_* variables, and this value
      was bigger than the column's max possible value, then that max possible
      value was inserted (after issuing a warning). But this didn't honour
      auto_increment_* variables (and so could cause conflicts in a master-master
      replication where one master is supposed to generated only even numbers,
      and the other only odd numbers), so now we "round down" this max possible
      value to honour auto_increment_* variables, before inserting it.
      
      
      mysql-test/r/rpl_auto_increment.result:
        result update. Before the fix, the result was that master inserted 127 in t1
        (which didn't honour auto_increment_* variables!),
        instead of failing with "duplicate key 125" like now.
      mysql-test/t/rpl_auto_increment.test:
        Test for BUG#20524 "auto_increment_* not observed when inserting
        a too large value".
        We also check the pathological case (table t2) where it's impossible to
        "round down".
        The fixer of BUG#20573 will be able to use table t2 for testing his fix.
      sql/handler.cc:
        If handler::update_auto_increment() generates a value larger than the field's
        max possible value, we used to simply insert this max possible value
        (after pushing a warning). Now we "round down" this max possible value to
        honour auto_increment_* variables (if at all possible), before trying the
        insertion.
      8646be88
  6. 05 Jul, 2006 4 commits
    • unknown's avatar
      Switching to use INSERT DELAYED, which it should be, for rpl_insert. · ae0e8aff
      unknown authored
      
      mysql-test/t/rpl_insert.test:
        Fixing to use INSERT DELAYED.
      ae0e8aff
    • unknown's avatar
      Merge mysql.com:/home/bkroot/mysql-5.1-new-rpl · 77e82450
      unknown authored
      into  mysql.com:/home/bk/b20821-mysql-5.1-new-rpl
      
      
      sql/sql_class.cc:
        Auto merged
      sql/sql_insert.cc:
        Auto merged
      77e82450
    • unknown's avatar
      BUG#20821 (INSERT DELAYED fails to write some rows to binlog): · 53def7bd
      unknown authored
      Reverting to old behaviour of writing the query before all rows
      have been written.
      
      
      mysql-test/r/rpl_row_delayed_ins.result:
        Result change
      sql/sql_class.cc:
        Adding debug message to binlog_query()
      sql/sql_insert.cc:
        - Changing write_delayed() to use a LEX_STRING for the query.
        - Adding query string to class delayed_row.
        - Removing query string from class delayed_insert.
        - Adding code to copy query string and delete it when the row
          is executed.
        - Logging query at first row instead of after all rows are 
          inserted (reverting to old behaviour).
        - Flushing the pending row event after all rows have been inserted.
          This is necessary since binlog_query() is called before all rows
          instead of after.
      mysql-test/r/rpl_insert.result:
        New BitKeeper file ``mysql-test/r/rpl_insert.result''
      mysql-test/t/rpl_insert.test:
        New BitKeeper file ``mysql-test/t/rpl_insert.test''
      53def7bd
    • unknown's avatar
      Fix for BUG#20188 "REPLACE or ON DUPLICATE KEY UPDATE in · 4e9d7d6c
      unknown authored
      auto_increment breaks binlog":
      if slave's table had a higher auto_increment counter than master's (even
      though all rows of the two tables were identical), then in some cases,
      REPLACE and INSERT ON DUPLICATE KEY UPDATE failed to replicate
      statement-based (it inserted different values on slave from on master).
      write_record() contained a "thd->next_insert_id=0" to force an adjustment
      of thd->next_insert_id after the update or replacement. But it is this
      assigment introduced indeterminism of the statement on the slave, thus
      the bug. For ON DUPLICATE, we replace that assignment by a call to
      handler::adjust_next_insert_id_after_explicit_value() which is deterministic
      (does not depend on slave table's autoinc counter). For REPLACE, this
      assignment can simply be removed (as REPLACE can't insert a number larger
      than thd->next_insert_id).
      We also move a too early restore_auto_increment() down to when we really know
      that we can restore the value.
      
      
      mysql-test/r/rpl_insert_id.result:
        result update, without the bugfix, slave's "3 350" were "4 350".
      mysql-test/t/rpl_insert_id.test:
        test for BUG#20188 "REPLACE or ON DUPLICATE KEY UPDATE in
        auto_increment breaks binlog".
        There is, in this order:
        - a test of the bug for the case of REPLACE
        - a test of basic ON DUPLICATE KEY UPDATE functionality which was not
        tested before
        - a test of the bug for the case of ON DUPLICATE KEY UPDATE
      sql/handler.cc:
        the adjustment of next_insert_id if inserting a big explicit value, is
        moved to a separate method to be used elsewhere.
      sql/handler.h:
        see handler.cc
      sql/sql_insert.cc:
        restore_auto_increment() means "I know I won't use this autogenerated
        autoincrement value, you are free to reuse it for next row". But we were
        calling restore_auto_increment() in the case of REPLACE: if write_row() fails
        inserting the row, we don't know that we won't use the value, as we are going to
        try again by doing internally an UPDATE of the existing row, or a DELETE
        of the existing row and then an INSERT. So I move restore_auto_increment()
        further down, when we know for sure we failed all possibilities for the row.
        Additionally, in case of REPLACE, we don't need to reset THD::next_insert_id:
        the value of thd->next_insert_id will be suitable for the next row.
        In case of ON DUPLICATE KEY UPDATE, resetting thd->next_insert_id is also
        wrong (breaks statement-based binlog), but cannot simply be removed, as
        thd->next_insert_id must be adjusted if the explicit value exceeds it.
        We now do the adjustment by calling
        handler::adjust_next_insert_id_after_explicit_value() (which, contrary to
        thd->next_insert_id=0, does not depend on the slave table's autoinc counter,
        and so is deterministic).
      4e9d7d6c