summaryrefslogtreecommitdiff
path: root/sql/ha_innodb.cc
diff options
context:
space:
mode:
authorunknown <gshchepa/uchum@gshchepa.loc>2007-04-26 02:01:23 +0500
committerunknown <gshchepa/uchum@gshchepa.loc>2007-04-26 02:01:23 +0500
commit209bf25a7f5105fc1329a0b31f96be0298057155 (patch)
tree9ae0db259896b42164c6c74dd6e3acd169f9d956 /sql/ha_innodb.cc
parent5a35befff53cfde52bc5b19561504144aa2af2e7 (diff)
downloadmariadb-git-209bf25a7f5105fc1329a0b31f96be0298057155.tar.gz
Fixed bug #27650:
INSERT into InnoDB table may cause "ERROR 1062 (23000): Duplicate entry..." errors or lost records after multi-row INSERT of the form: "INSERT INTO t (id...) VALUES (NULL...) ON DUPLICATE KEY UPDATE id=VALUES(id)", where "id" is an AUTO_INCREMENT column. It happens because InnoDB handler forgets to save next insert id after updating of auto_increment column with new values. As result of that last insert id stored inside InnoDB dictionary tables differs from it's cached thd->next_insert_id value. sql/ha_innodb.cc: Fixed bug #27650. INSERT into InnoDB table may cause "ERROR 1062 (23000): Duplicate entry..." errors or lost records after multi-row INSERT of the form: "INSERT INTO t (id...) VALUES (NULL...) ON DUPLICATE KEY UPDATE id=VALUES(id)", where "id" is an AUTO_INCREMENT column. It happens because InnoDB handler forgets to save next insert id after updating of auto_increment column with new values. As result of that last insert id stored inside InnoDB dictionary tables differs from it's cached thd->next_insert_id value. ha_innobase::write_row() function has been corrected. mysql-test/t/innodb_mysql.test: Added a test case for bug #27650. mysql-test/r/innodb_mysql.result: Added a test case for bug #27650.
Diffstat (limited to 'sql/ha_innodb.cc')
-rw-r--r--sql/ha_innodb.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 217f59d4b7e..808c3bcd41d 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -3299,6 +3299,8 @@ no_commit:
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_INSERT
+ && user_thd->lex->duplicates == DUP_UPDATE)
|| (user_thd->lex->sql_command == SQLCOM_LOAD
&& user_thd->lex->duplicates == DUP_REPLACE))) {