Fix handling of SQLEngine logic in mod_sql, which was contributing to
test failures when regressing Bug#4083.