I was doing some insertion tests in my database and I realized that when the INSERT statement fails, due error 1452, causes the auto_increment value increase by 1. Even though, there wasn't any row inserted in this statement.
Thereby, this behavior causes the next valid insertion skip an available and possible value for the auto_increment.
1st Insert | Result: Success | id(auto_increment_column): 1 | 2nd Insert | Result: Failure | -------- No rows were recorded---- | 3nd Insert | Result: Success | id(auto_increment_column): 3 |
I want to know if someone had this problem before and if this is really a problem.
Errno: 1452 - fk constraint fails. This means that I'm trying to reference some column value in another table and this value doesn't exists there.
- Database: MySQL Ver 14.14 Distrib 5.6.13, for Windows 64-bit
- Storage Engine: InnoDB