Bug #78934 | Failed INSERT(Dup entry) still change LAST_INSERT_ID() for auto_increment col | ||
---|---|---|---|
Submitted: | 23 Oct 2015 4:14 | Modified: | 26 Oct 2015 13:37 |
Reporter: | Su Dylan | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S3 (Non-critical) |
Version: | 5.7.8 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[23 Oct 2015 4:14]
Su Dylan
[26 Oct 2015 13:37]
MySQL Verification Team
Hello Su Dylan, Thank you for the report. Imho if you insert multiple rows using a single INSERT statement, LAST_INSERT_ID() returns the value generated for the first inserted row only. Also, for transactional tables, if the statement is rolled back due to an error, the value of LAST_INSERT_ID() is left undefined. For manual ROLLBACK, the value of LAST_INSERT_ID() is not restored to that before the transaction; it remains as it was at the point of the ROLLBACK. Please see https://dev.mysql.com/doc/refman/5.7/en/information-functions.html#function_last-insert-id “Lost” auto-increment values and sequence gaps in https://dev.mysql.com/doc/refman/5.7/en/innodb-auto-increment-configurable.html Thanks, Umesh