Re: [sqlite] question about shared cache

2009-03-24 Thread Dan

On Mar 25, 2009, at 12:09 AM, Dave Toll wrote:

> Hello list
>
>
>
> I have been trying to understand how shared cache works under the
> covers, and how a custom VFS should behave when shared cache is  
> enabled
> - can anyone confirm this assumption:
>
>
>
> Journal file handles (opened with SQLITE_OPEN_EXCLUSIVE) are shared
> between database connections opened on the same DB filename. Access  
> to a
> journal file handle is serialised through the BTShared mutex of the
> owning database - there is no explicit locking performed on journal
> files.

That is correct. SQLite will serialize calls on a single file-handle
(sqlite3_file*). You do not need a mutex for each file-handle in the
OS layer.

Dan.



>
>
>
>
> Cheers,
>
> Dave.
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] question about shared cache

2009-03-24 Thread Dave Toll
Hello list

 

I have been trying to understand how shared cache works under the
covers, and how a custom VFS should behave when shared cache is enabled
- can anyone confirm this assumption:

 

Journal file handles (opened with SQLITE_OPEN_EXCLUSIVE) are shared
between database connections opened on the same DB filename. Access to a
journal file handle is serialised through the BTShared mutex of the
owning database - there is no explicit locking performed on journal
files.

 

Cheers,

Dave.

 

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Question about shared cache and read_uncommitted

2007-03-10 Thread Dan Kennedy
On Sat, 2007-03-10 at 22:22 +0900, Brownie wrote:
> Thanks Dan,
> 
> > That the first database file was ATTACHed instead of being opened
> > directly makes no difference.
> 
> A cache of :memory: database also be shared on shared cache mode ?
> Or :memory: database of each connections are irrelevant ?

Shared cache mode does not apply to :memory: databases. It is not
currently possible for more than one database handle to access a 
single in-memory database.

Dan.


> Regards,
> 
> 2007/3/10, Dan Kennedy <[EMAIL PROTECTED]>:
> > On Sat, 2007-03-10 at 14:11 +0900, Brownie wrote:
> > > Hi,
> > >
> > > I have two questions about shared cache mode of SQLite.
> > >
> > > 1. When is shared cache of SQLite deallocated?
> > > A last call of sqlite3_close()? Or end of thread procedure?
> >
> > The former. The shared cache (and shared schema) are reference
> > counted. Resources are released as soon as the number of connections
> > to the shared cache drops to zero.
> >
> > > 2. Can I use read_uncommitted isolation in the following case?
> > >
> > > (Connection1 and Connection2 is established by the same thread
> > > and shared cache mode was enabled)
> > >
> > > Connection1: Opened for :memory:
> > > ATTACH DATABASE 'mydb.db' as mydb;
> > > SELECT myname FROM mydb.mytable;
> > >
> > > Connection2: Opened for mydb.db
> > > INSERT INTO mytable(myname) VALUES('myname');
> >
> > I think so. But I'm not 100% sure I understand the question.
> >
> > If Connection1 is in read_uncommitted mode, then the SELECT will
> > neither block nor be blocked by the INSERT statement executed
> > by Connection2.
> >
> > That the first database file was ATTACHed instead of being opened
> > directly makes no difference.
> >
> > Dan.
> >
> >
> >
> > -
> > To unsubscribe, send email to [EMAIL PROTECTED]
> > -
> >
> >


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Question about shared cache and read_uncommitted

2007-03-10 Thread Brownie

Thanks Dan,


That the first database file was ATTACHed instead of being opened
directly makes no difference.


A cache of :memory: database also be shared on shared cache mode ?
Or :memory: database of each connections are irrelevant ?

Regards,

2007/3/10, Dan Kennedy <[EMAIL PROTECTED]>:

On Sat, 2007-03-10 at 14:11 +0900, Brownie wrote:
> Hi,
>
> I have two questions about shared cache mode of SQLite.
>
> 1. When is shared cache of SQLite deallocated?
> A last call of sqlite3_close()? Or end of thread procedure?

The former. The shared cache (and shared schema) are reference
counted. Resources are released as soon as the number of connections
to the shared cache drops to zero.

> 2. Can I use read_uncommitted isolation in the following case?
>
> (Connection1 and Connection2 is established by the same thread
> and shared cache mode was enabled)
>
> Connection1: Opened for :memory:
> ATTACH DATABASE 'mydb.db' as mydb;
> SELECT myname FROM mydb.mytable;
>
> Connection2: Opened for mydb.db
> INSERT INTO mytable(myname) VALUES('myname');

I think so. But I'm not 100% sure I understand the question.

If Connection1 is in read_uncommitted mode, then the SELECT will
neither block nor be blocked by the INSERT statement executed
by Connection2.

That the first database file was ATTACHed instead of being opened
directly makes no difference.

Dan.



-
To unsubscribe, send email to [EMAIL PROTECTED]
-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Question about shared cache and read_uncommitted

2007-03-09 Thread Dan Kennedy
On Sat, 2007-03-10 at 14:11 +0900, Brownie wrote:
> Hi,
> 
> I have two questions about shared cache mode of SQLite.
> 
> 1. When is shared cache of SQLite deallocated?
> A last call of sqlite3_close()? Or end of thread procedure?

The former. The shared cache (and shared schema) are reference 
counted. Resources are released as soon as the number of connections
to the shared cache drops to zero.

> 2. Can I use read_uncommitted isolation in the following case?
> 
> (Connection1 and Connection2 is established by the same thread
> and shared cache mode was enabled)
> 
> Connection1: Opened for :memory:
> ATTACH DATABASE 'mydb.db' as mydb;
> SELECT myname FROM mydb.mytable;
> 
> Connection2: Opened for mydb.db
> INSERT INTO mytable(myname) VALUES('myname');

I think so. But I'm not 100% sure I understand the question.

If Connection1 is in read_uncommitted mode, then the SELECT will
neither block nor be blocked by the INSERT statement executed
by Connection2.

That the first database file was ATTACHed instead of being opened
directly makes no difference.

Dan.



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Question about shared cache and read_uncommitted

2007-03-09 Thread Brownie

Hi,

I have two questions about shared cache mode of SQLite.

1. When is shared cache of SQLite deallocated?
A last call of sqlite3_close()? Or end of thread procedure?

2. Can I use read_uncommitted isolation in the following case?

(Connection1 and Connection2 is established by the same thread
and shared cache mode was enabled)

Connection1: Opened for :memory:
ATTACH DATABASE 'mydb.db' as mydb;
SELECT myname FROM mydb.mytable;

Connection2: Opened for mydb.db
INSERT INTO mytable(myname) VALUES('myname');

Regards,

-
To unsubscribe, send email to [EMAIL PROTECTED]
-