Solve syntax errors on recent / less strict versions of MySQL

(cherry picked from commit 25ece01a0a3064f9302a3424e9ae944b484168bb)