> Paul wrote:
> >> Paul wrote:
> >>> My goal is to make structure initialization of an *abstract* database 
> >>> atomic.
> >>> [...] if database file is missing it must be created and initialized.
> >>
> >> <http://www.sqlite.org/transactional.html>
> >>
> >> Just do the check for the database structure and the initialization inside
> >> a transaction.
> >
> > Yeah, but you didn't read my statements carefully. I was talking about an 
> > abstract database.
> > It's wrappers responsibility to call *on_create* so it's wrappers 
> > responsibility to check.
> > How do you check if structure is initializad in an abstract databse?
> 
> By calling a non-abstract function?
> 
> I fear this description is too abstract to be useful.
> Please show some concrete (pseudo)code.

What non-abstract function do you mean? I think the fact that it's a callback 
means abstraction.

Ahyway, what I mean is (in C++):

struct SqliteDatabase {
...

/// Callback is called once database is created. Strictly one time.
    virtual bool on_create();
...
};

struct FooDatabase : public SqliteDatabase
{
    bool on_create()
    {
        return EXEC_SQL("CREATE TABLE foo (id INTEGER);");
    }

};


...or something like that

> 
> >>> SQLITE_OPEN_EXCLUSIVE
> >>
> >> This flag does not mean what you think it means, and is used only
> >> internally; you are not allowed to use it.
> >
> > Please explain, why am I not allowed to use it in sqlite3_open_v2()?
> 
> That's what the documentation says (<http://www.sqlite.org/c3ref/open.html>):
> | The flags parameter to sqlite3_open_v2() can take one of the following
> | three values, optionally combined with the SQLITE_OPEN_NOMUTEX,
> | SQLITE_OPEN_FULLMUTEX, SQLITE_OPEN_SHAREDCACHE, SQLITE_OPEN_PRIVATECACHE,
> | and/or SQLITE_OPEN_URI flags:
> | SQLITE_OPEN_READONLY [...]
> | SQLITE_OPEN_READWRITE [...]
> | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE [...]
> 
> ... and also what the code actually does:
> 
> /* Remove harmful bits from the flags parameter
> **
> ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were
> ** dealt with in the previous code block. Besides these, the only
> ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY,
> ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE,
> ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask
> ** off all other flags.
> */
> flags &= ~( SQLITE_OPEN_DELETEONCLOSE |
> SQLITE_OPEN_EXCLUSIVE |
> SQLITE_OPEN_MAIN_DB |
> SQLITE_OPEN_TEMP_DB |
> SQLITE_OPEN_TRANSIENT_DB |
> SQLITE_OPEN_MAIN_JOURNAL |
> SQLITE_OPEN_TEMP_JOURNAL |
> SQLITE_OPEN_SUBJOURNAL |
> SQLITE_OPEN_MASTER_JOURNAL |
> SQLITE_OPEN_NOMUTEX |
> SQLITE_OPEN_FULLMUTEX |
> SQLITE_OPEN_WAL
> );
> 

Hmm... I thought I can at least use this flag to know if this database 
connection is the creator of database :(

So, there are no standard means I guess?
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to