I have to say, using the sqlite3 api, it all made perfect sense to me,
except that these very functions were missing.  The silent create-if-needed
behavior of Open() seems counter-intuitive to me.  I would think that many
consumers would have to do what I did: examine the file system themselves to
determine if the file already exists, etc, to get their setup logic right.

--Ned.

-----Original Message-----
From: Darren Duncan [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 08, 2004 1:23 AM
To: [EMAIL PROTECTED]
Subject: Re: [sqlite] new Ticket 949: add user-level test for file validity

At 12:22 PM +1000 10/8/04, [EMAIL PROTECTED] wrote:
>Darren,
>Are you asking for a pragma integrity_check (which already exists) or are
>you just wanting to verify the magic string at the beginning of the file?

The magic string.  I want an elegant way for a user to explicitly 
check the magic string, that is built into the SQLite library itself, 
and which means not issuing a superflous select.

>Personally, I think it would be nice to have some means to say "Open this
>file if it already exists and is an sqlite file: Don't create it if it
>doesn't exist". I'm not sure I've found any cases where it is entirely
>necessary, though.
>Benjamin.

You're absolutely right.  In fact, I very much want that too.

1. I want a command that is explicitly for creating a new file, that 
will fail with an error if the file already exists.

2. I want a command that is explicitly for opening an existing file, 
that will fail with an error if the file does not exist.

3. While we're at it, maybe an explicit built-in command to delete a 
database (done by the SQLite library since it knows best how to clean 
up after itself).

Perhaps an elegant solution for this and similar things be to add a third
argument to open() called "mode" which simply takes one of a list of 
defined numerical codes (or alternately, a single bitmask) 
representing the behaviour we want.  Example values could be: 1. "new 
or fail"; 2. "existing or fail"; 3. "new or existing" (the default). 
Possibly the thing about checking the magic number could be a fourth 
and fifth option (to complement 2 and 3), unless that is simply asked 
for separately.

Any thoughts on this idea?

-- Darren Duncan


Reply via email to