From: Date: June 7 2005 10:51am Subject: bk commit into 5.0 tree (heikki:1.1929) BUG#11005 List-Archive: http://lists.mysql.com/internals/25681 X-Bug: 11005 Message-Id: <200506070851.j578pqb9023111@hundin.mysql.fi> Below is the list of changes that have just been committed into a local 5.0 repository of heikki. When heikki does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.1929 05/06/07 11:51:27 heikki@stripped +1 -0 ha_innodb.cc: Update the InnoDB internal auto-inc counter in ::write_row() if the statement is a REPLACE that fails in a duplicate key error: REPLACE will handle duplicate key error, and the insert will eventually succeed; note that we did NOT change InnoDB's behavior in an UPDATE, because updating the auto-inc counter in an UPDATE would require a bigger patch (Bug #11005) sql/ha_innodb.cc 1.218 05/06/07 11:51:00 heikki@stripped +17 -0 Update the InnoDB internal auto-inc counter in ::write_row() if the statement is a REPLACE that fails in a duplicate key error: REPLACE will handle duplicate key error, and the insert will eventually succeed; note that we did NOT change InnoDB's behavior in an UPDATE, because updating the auto-inc counter in an UPDATE would require a bigger patch (Bug #11005) # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: heikki # Host: hundin.mysql.fi # Root: /home/heikki/mysql-5.0 --- 1.217/sql/ha_innodb.cc Mon Jun 6 21:21:23 2005 +++ 1.218/sql/ha_innodb.cc Tue Jun 7 11:51:00 2005 @@ -3221,6 +3221,23 @@ } } + /* A REPLACE command and LOAD DATA INFILE REPLACE handle a duplicate + key error themselves, and we must update the autoinc counter if we are + performing those statements. */ + + if (error == DB_DUPLICATE_KEY && auto_inc_used + && (user_thd->lex->sql_command == SQLCOM_REPLACE + || user_thd->lex->sql_command == SQLCOM_REPLACE_SELECT + || (user_thd->lex->sql_command == SQLCOM_LOAD + && user_thd->lex->duplicates == DUP_REPLACE))) { + + auto_inc = table->next_number_field->val_int(); + + if (auto_inc != 0) { + dict_table_autoinc_update(prebuilt->table, auto_inc); + } + } + innodb_srv_conc_exit_innodb(prebuilt->trx); error = convert_error_code_to_mysql(error, user_thd);