Added log when sql is invalid.