I have a unique key on username and email address in mysql. In my
application logic, I want to test for that response on failed insert. Error
number 1062 tells me there is a duplicate key, but no way to tell what key
The error string returned is more telling, but seems less than ideal to use
for stability and upgrade issues. It tells me username is key 2 and email
is key 3.
So, if error_string ends with 'key 2' etc etc
I took care to lowercase the error string, so that's covered.
What is not, is that it may not always 'ends with', so I could move to
Anyway, I think you see what my concern is, wonder what the preferred method
to fix is, or if someone can tell me when, if ever, the error string has
ever changed format in mysql.
I could run a insert ahead of time and parse the returned results, but I
would rather not add the overhead of another select ahead of time.