On Tue, Jun 26, 2012 at 11:15 AM, Simon Slavin <slav...@bigfraud.org> wrote:
> > On 26 Jun 2012, at 4:11pm, "Black, Michael (IS)" <michael.bla...@ngc.com> > wrote: > > > So...transaction is started at sqlite3_step and stays open until > sqlite3_reset or sqlite3_finalize, right? > > > > sqlite3_close would do what if you didn't finalize? Just a memory leak > or worse? Or would sqlite3_close return an error if there's an open > transaction? > > <http://www.sqlite.org/c3ref/close.html> > > "Applications must finalize all prepared statements and close all BLOB > handles associated with the sqlite3 object prior to attempting to close the > object. If sqlite3_close() is called on a database connection that still > has outstanding prepared statements or BLOB handles, then it returns > SQLITE_BUSY." > > > on the other hand ... > > "If sqlite3_close() is invoked while a transaction is open, the > transaction is automatically rolled back." > > It is not an error to close the file while you're in the middle of a > transaction. It just means you didn't commit the transaction. > The second statement above refers to an explicit transaction created using the BEGIN statement. It does not follow that implied transactions created by running queries are automatically cancelled when you do sqlite3_close(). To cancel the implied transaction, you have to sqlite3_reset() or sqlite3_finalize() the prepared statement that created the transaction in the first place. > > Simon. > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users