Bug 8037: (follow-up) bad sql query and variable renaming