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.

Robert


----- Original Message ----- From: "Dennis Jenkins" <[EMAIL PROTECTED]>
To: <sqlite-users@sqlite.org>
Sent: Friday, August 26, 2005 12:51 PM
Subject: Re: [sqlite] checking the database status


Robert Simpson wrote:

um ... It's a file. You just check to see if the file exists. No sqlite calls involved.

Robert

That would work in this situation, but what about the inverse? You only want to open the file IF it already exists.

There is a race condition: where you check for the file, don't find it, and then try to open the database, and in the mean time, a different process/thread has done the same?

I do not need this yes, but I can imagine situations where an atomic "create new database ONLY" would be very nice.



Reply via email to