Use named mysql error constants rather than raw magic numbers.

There were a few too many magic numbers in this file for my liking, so this PR just makes them named constants.