Hi Simon,

why is the database corrupted when sqlite3_close() is not called? I thought 
that I might lose data but the database is actually corrupted and not 
accessible anymore!

Can you explain what happens?

Regards,
Hartwig

Am 07.08.2011 um 22:43 schrieb Simon Slavin:

> 
> On 7 Aug 2011, at 9:19pm, skywind mailing lists wrote:
> 
>> A few user have reported that when the iPhone/iPad runs out of batteries the 
>> SQLite3 database may become corrupted. I have received one database back and 
>> it is indeed defect and unrecoverable. Does anybody have an idea what is 
>> going wrong? I tried to reproduce the error by myself but I did not have any 
>> luck so far.
>> For information: only the main thread is writing to the database. There is 
>> no other thread having access to the database and there is also no read 
>> operation from the main thread. The write operation is not within an 
>> explicit transaction.
> 
> Don't worry about transactions, your key question is when you run 
> sqlite3_close().  If your database is being corrupted by low-battery-shutoff 
> then you are failing to correctly trap the 'application will quit' 
> notification, because the iPhone sends this to all apps before it shuts down 
> due to low batteries.
> 
> (Following is for those less used to iOS development.)
> 
> There are two common tactics for iPhone apps.  One is to close database 
> handles whenever the application is notified it will be switched to the 
> background.  The other is to close your database handles whenever your 
> application gets notified that it will be terminated.  There are 
> notifications for both of these, and they're easy to react to.  It's possible 
> those users have found an obscure bug in some version of iOS where it's not 
> notifying apps properly, but I think this is unlikely.  I've not seen such 
> problems reported elsewhere.
> 
> Since you say only your main thread writes to the database your best tactic 
> comes down to whether your app is one that has background functionality (like 
> something that logs your GPS movements while you're doing other things) or 
> one which only really has functionality when it's the front app.
> 
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

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

Reply via email to