Quantcast

Does SQLite do any file editing when you close a database ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Does SQLite do any file editing when you close a database ?

Simon Slavin-3
I know that the SQLite "_open()" calls are fakes.  The file is not really opened until the first operation which needs to access it.

However, triggered by another post to this forum I’m not curious about "_close()" calls.  I used to think that SQLite did clear-up work when you closed a file.  For example, truncating or deleting a journal file.  But it seems that these operations are done at the end of transactions, not when the file is closed.

Can anyone point out anything that’s done to files when you close a database ?

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does SQLite do any file editing when you close a database ?

Olivier Mascia
> Le 6 avr. 2017 à 17:44, Simon Slavin <[hidden email]> a écrit :
>
> Can anyone point out anything that’s done to files when you close a database ?

For one thing, when the last database connection on a database file closes SQLite does checkpoint whatever remains in the wal. Which in that case includes deleting the shm/wal files.

https://www.sqlite.org/wal.html#how_to_checkpoint

"By default, SQLite will automatically checkpoint whenever a COMMIT occurs that causes the WAL file to be 1000 pages or more in size, or when the last database connection on a database file closes."

--
Best Regards, Meilleures salutations, Met vriendelijke groeten,
Olivier Mascia, http://integral.software


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Loading...