Hi all,

I use SQLite in an iPhone application, and for my own convenience I have 
wrapped it up in an object-oriented wrapper of my own devising.

I would like to close the database connection if it is safe to do so when my 
app is suspended, so that the -wal file can be erased saving the user some 
space, and also because I hear that improves the efficiency of subsequent 
queries.

I always finalize my prepared statements; I don't use BLOB handles; and my 
application code executes on a single thread. So sqlite3_close() should 
complete if I call it, and it would as a matter of course roll-back any open 
transaction.

I don't want to roll-back open transactions - if a transaction is open I want 
to leave the database connection open so that the app can carry on with it when 
it is resumed (or it can be rolled back if the app is forcibly terminated).

The only method I have come up with thus far is to issue BEGIN then if that 
works I can call sqlite3_close().

However, I would like to be as efficient as possible because apps are meant to 
be as efficient as possible at this point in processing: 
sqlite3_prepare("BEGIN;"), sqlite3_step(), sqlite3_finalize() is three API 
calls with a bunch of side-effects I don't want (altering the value of 
sqlite3_errmsg() and friends for instance), which seems a bit heavy for such a 
simple thing.

Is there already a better way? If not, would it be difficult for me to add it 
to sqlite3_db_status(), and would anyone else want that patch?

Best Regards,

Phil Willoughby
-- 
Managing Director, StrawberryCat Limited

StrawberryCat Limited is registered in England and Wales with Company No. 
7234809.

The registered office address of StrawberryCat Limited is:

107 Morgan Le Fay Drive
Eastleigh
SO53 4JH

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to