Was there a bug there in the original code?
This doesn't look like it is mysql 5.6 specific.

If yes, can you extract this in a different patch (you can keep it in the same pull request)?