I have a table - with id which is auto_increment and a email column which is defined to be UNIQUE.
Consider the auto_increment to be set to 1.
In my stored procedure when I INSERT a new row with a unique email id the auto_increment column is incremented. Correct behavior.
Now when I try to INSERT the same email again UNIQUE KEY is violated. I check this and do a ROLLBACK. However the auto_increment is set to 2 now. Why?
In the third attempt of INSERT, this time with a unique email the row is inserted however the id field has value 3. Not good.
Is there a way I can decrement the value back to 2.
 
     
     
    