Fix SQL compilation errors (pinging @gregwebs)