On Thu, 6 Apr 2017, Simon Slavin wrote:


On 6 Apr 2017, at 2:38pm, Bob Friesenhahn <bfrie...@simple.dallas.tx.us> wrote:

Is calling sqlite3_close() prior to exiting a requirement in general for 
sqlite? I was not aware of this requirement.

Do you explicitly call sqlite3_shutdown() ?  If not, when are you expecting 
SQLite to close the file for you ?

I expect the operating system to close the file if the program quits (e.g. calls exit()) or the file to not be closed at all if the program aborts (e.g. calls abort() or segmentation faults) or the host system abruptly reboots or loses power.

Do you also routinely omit close(), fclose(), and sync() ?  Don’t you have 
problems with unflushed buffers ?

Under adverse curcumstances, the answer to this is definitely 'yes'.

It is not uncommon for programs to quit without explicitly releasing all 
resources (e.g. calling sqlite3_close()) when a problem occurs.

It depends on whether the software understands the problem, and on whether that problem relates to SQLite. If your program crashed because of a divide-by-zero error you probably still want it to close any databases it was using. If it crashed because it ran out of disk space, you probably don’t.

Software seldom understands problems since adding AI to a program is extremely difficult. Problems are solved by giving up, retrying a few times, or quitting entirely.

It is uncommon for SQLite programs not to close files correctly. The only time I see this done is code demonstrating a feature, where the file is never going to be used again. What’s not common is for

It is common for programs which always keep their connections open, or use a connection pool, for the connections to not be closed.

Batch type programs typically behave differently than daemon-style programs.

Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to