title: MySQL autoincrement value increases even when insertion fails due to error
body: <p>As I receive data from the user, I validate the format of the input every time (PHP). The only thing I can't validate (or I wouldn't want to) is the constraint (for example foreign key) violation. I let the DML to raise and error and the database driver to throw an exception. After catching it I just print out some error message by MySQL's error code.</p>
  
  <p>The problem is, even when insertion fails, I see that the <code>autoincrement</code> sequence still grows, increases. How can I prevent that?</p>