Re: [sqlite] Re: Transactions on a shared database connection

2007-11-06 Thread Trevor Talbot
On 11/6/07, John Firebaugh <[EMAIL PROTECTED]> wrote: > > You're confusing threads with the context of the connection. When you > > call sqlite3_open() you get a single connection to a db. That > > connection can then be used across threads, but it is for all intents > > and purposes a single

Re: [sqlite] Re: Transactions on a shared database connection

2007-11-06 Thread Richard Klein
Richard Klein wrote: John Firebaugh wrote: I take it this mean that if, say, thread A begins a transaction, and modifies the database, then thread B modifies the database, then thread A commits the transactions, B's modifications are also committed? Nope. Once thread A begins a transaction,

[sqlite] Re: Transactions on a shared database connection

2007-11-06 Thread John Firebaugh
> John Firebaugh wrote: > > I take it this mean that if, say, thread A begins a transaction, and > > modifies the database, then thread B modifies the database, > then thread > > A commits the transactions, B's modifications are also committed? > > Nope. Once thread A begins a transaction, no

Re: [sqlite] Re: Transactions on a shared database connection

2007-11-06 Thread Richard Klein
John Firebaugh wrote: I take it this mean that if, say, thread A begins a transaction, and modifies the database, then thread B modifies the database, then thread A commits the transactions, B's modifications are also committed? Nope. Once thread A begins a transaction, no other thread (or

Re: [sqlite] Re: Transactions on a shared database connection

2007-11-06 Thread John Stanton
A transaction state is dependent upon the lock state, and the lock is at database level because the database is the resource being shared by user initiated connections. Locks are held by individual connections and those connections can be at process or thread level. The Sqlite locks are

RE: [sqlite] Re: Transactions on a shared database connection

2007-11-06 Thread John Firebaugh
> Note that your example of two threads attempting to update the same > record at the same time is consistent with this theory -- in > either case SQLITE_BUSY (or similar) is likely to occur on one of the > threads. I see now that I am also likely wrong about this. In the shared connection

[sqlite] Re: Transactions on a shared database connection

2007-11-06 Thread John Firebaugh
> You're confusing threads with the context of the connection. When you > call sqlite3_open() you get a single connection to a db. That > connection can then be used across threads, but it is for all intents > and purposes a single line of communication with a database (using it > twice at the

Re: [sqlite] Re: Transactions on a shared database connection

2007-11-06 Thread Stephan Beal
On Nov 6, 2007 7:45 PM, John Firebaugh <[EMAIL PROTECTED]> wrote: > "Restrictions on the use of the same database connection by multiple > threads have been dropped. It is now safe for multiple threads to use > the same database connection at the same time." This suggests to me that > operations

RE: [sqlite] Re: Transactions on a shared database connection

2007-11-06 Thread John Firebaugh
> > I would have expected the "no transaction > > nesting" restriction to be enforced per-thread, not per-connection. > > And what made you believe so? How is supporting nested transactions in > multiple threads any easier than supporting them in a single thread? I have no idea; the main

[sqlite] Re: Transactions on a shared database connection

2007-11-06 Thread Igor Tandetnik
John Firebaugh wrote: With SQLite 3.5.1, when a connection is shared between two threads, if the second thread attempts to begin a transaction while a transaction is in progress on the first thread, sqlite3_exec( "begin transaction" ) returns SQLITE_ERROR with a status message "cannot start a