Re: [sqlite] Error handling
On 2/15/2017 10:42 PM, Igor Korot wrote: Now I presume that calling sqlite3_finalize() on the NULL handle is safe? Yes; the documentation explicitly states that. -- Igor Tandetnik ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Error handling
Hi, Richard, On Wed, Feb 15, 2017 at 8:20 PM, Richard Hippwrote: > On 2/15/17, Igor Korot wrote: >> >> Well, my question here is a bit different - if sqlite3_step () returns an >> error >> should the statement be released? >> > > You still need to invoke either sqlite3_finalize() or sqlite3_reset() > on the statement. Use sqlite3_finalize() if you will never use that > statement again, and sqlite3_reset() if you want to reuse it. Just be > cause it got an error on one go doesn' t mean that it cannot be > reused, if that is what you are asking. Basically I was asking if the failure on the sqlite3_step() release the statement handle or not. So thank you for confirming it is not. Now I presume that calling sqlite3_finalize() on the NULL handle is safe? Because I am planning to call this function only once - after the loop. Thank you. > > -- > D. Richard Hipp > d...@sqlite.org > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Error handling
On 2/15/17, Igor Korotwrote: > > Well, my question here is a bit different - if sqlite3_step () returns an > error > should the statement be released? > You still need to invoke either sqlite3_finalize() or sqlite3_reset() on the statement. Use sqlite3_finalize() if you will never use that statement again, and sqlite3_reset() if you want to reuse it. Just be cause it got an error on one go doesn' t mean that it cannot be reused, if that is what you are asking. -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Error handling
Hi, Igor, On Feb 15, 2017 7:16 PM, "Igor Tandetnik"wrote: 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. Ok. 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. Well, my question here is a bit different - if sqlite3_step () returns an error should the statement be released? Thank you. -- Igor Tandetnik ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Error handling
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
Re: [sqlite] Error handling anomaly ...
Rob Sciuk <[EMAIL PROTECTED]> wrote: > In a test harness, I'm using a sqlite3_prepare/bind/step/finalize > sequence to add rows to a table, and then add them again, > intentionally violating the unique index constraints. It appears > that sqlite3_step reports the violation (sqlite3_errorMessage), and > then the details (the offending column numbers) are only reported > when I check the error in the sqlite3_finalize() routine ... http://sqlite.org/c3ref/prepare.html Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Error handling.
On 8/27/06, Anders Aagaard <[EMAIL PROTECTED]> wrote: Jay Sprenkle wrote: > On 8/26/06, Anders Aagaard <[EMAIL PROTECTED]> wrote: >> Hi >> >> Is there any way to handle the different error messages from sqlite >> without doing strcmp? For example SQLITE_CONSTRAINT? > > will the conflict handling options do what you need? > http://www.sqlite.org/lang_conflict.html Unfortunately not :/, all I'd need is to return a different error code to the system based on which constraint it is. But string parsing to get the error codes seems awfully inefficient to me :/ I don't believe that particular error is delimited in the return codes. Maybe DRH would consider adding it in the future. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Error handling.
Jay Sprenkle wrote: On 8/26/06, Anders Aagaard <[EMAIL PROTECTED]> wrote: Hi Is there any way to handle the different error messages from sqlite without doing strcmp? For example SQLITE_CONSTRAINT? will the conflict handling options do what you need? http://www.sqlite.org/lang_conflict.html Unfortunately not :/, all I'd need is to return a different error code to the system based on which constraint it is. But string parsing to get the error codes seems awfully inefficient to me :/ -- SqliteImporter and SqliteReplicator: Command line utilities for Sqlite http://www.reddawn.net/~jsprenkl/Sqlite OSX version now available Cthulhu Bucks! http://www.cthulhubucks.com - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Error handling.
On 8/26/06, Anders Aagaard <[EMAIL PROTECTED]> wrote: Hi Is there any way to handle the different error messages from sqlite without doing strcmp? For example SQLITE_CONSTRAINT? will the conflict handling options do what you need? http://www.sqlite.org/lang_conflict.html -- SqliteImporter and SqliteReplicator: Command line utilities for Sqlite http://www.reddawn.net/~jsprenkl/Sqlite OSX version now available Cthulhu Bucks! http://www.cthulhubucks.com - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Error handling.
Looks like you're not alone... http://www.gatago.com/comp/databases/20027474.html /m - To unsubscribe, send email to [EMAIL PROTECTED] -