• unknown's avatar
    Fixed bug #27650: · 209bf25a
    unknown authored
    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.
    209bf25a
innodb_mysql.test 15.3 KB