Fix array index out of bounds issue in Planner

Reviewable, simple fix, waiting for Jenkins Blue.
What's your reasoning for not needing to uppercase the sql?  I think SQL will allow keywords to be mixed-case, so would "UpSert" and "uPsErT" continue to work?