Improve return code checking in sqlite_impl code thanks to Mulhern/Mulkieran