Fix bugs introduced from previous commit.

Re-fix MySQL edge case checks.

Sorry, my previous commit introduced some bugs that I only noticed after the pull request was accepted. This should fix them.