On 2/15/2017 7:02 PM, Igor Korot wrote:
My question is: how many calls to "sqlite3_finalize() should be there?

For every successful call to sqlite3_prepare[_v2], there should eventually be a call to sqlite3_finalize; otherwise, you'd leak a statement, and prevent the database handle from closing cleanly.

Do I need one inside lines 2-6?

You don't. If sqlite3_prepare_v2 fails, you wouldn't have a valid handle to pass to sqlite3_finalize.

And how to properly handle failure with statement release?

sqlite3_finalize() itself never fails. Through a quirk of history, it may return an error code from the most recent failed sqlite3_step() call (see Goofy Interface Alert section at https://sqlite.org/c3ref/step.html ). Since you are using sqlite3_prepare_v2, you may ignore the return value of sqlite3_finalize.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to