Robert Simpson wrote:

sqlite3_open() doesn't create/open a file for exclusive access off the bat.

If you want to atomically open a file that already exists,
open it yourself and while its open, call sqlite3_open(), then close your own handle to it.

If you want to atomically create a file and only open it if you created it, create it yourself and while its open, call sqlite3_open() then close your handle.

#1 should not work in all cases on Unix. Someone could unlink the file after you open it the first time and before you open it the second time. The first file will be removed when all open file handles to that file are closed.

#2.. Would that work if you opened the file exclusively? If you don't open it exclusively, theoretically someone else could open it too.


Unless I'm missing something, the only way to atomically create or open a file is to ask the OS to do that operation only once.

Maybe Dr. Hipp can elaborate on why we can pass the file open/creation flags into the sqlite3_open() function.

Maybe these flags do not exist on all platforms (in which case, why not just ignore the flags)? ?

Reply via email to