Igor thanks for the respons... I have a few more questions...
Here is the sequence:
(a) open -- Server does a shared cache enable, then
open
(b) open -- Server does a shared cache anble, then
open
(a) begin exclusive
(b) begin exclusive (From my undestanding this should return back a
sqlite_busy
However it does not, it returns
success ).
(a) insert
(b) insert
(a) commit ( success)
(b) commit (Gets a cannot commit - no transaction is active )
Is this correct behaviour? Why?
I understand what youve stated about nested txn's however these are on
seperate connections through a shared cache onto a single database.
It sure would be nice to see better documentation in this area, regarding
locking. I understand the file locking model but there is little documentation
egarding the thread/sql locking and interaction amongst single process
connections.
I can easilty modify the code to handle the above situation. Simple as you
stated. Keeping a counter as follows:
Cmd counter Action
begin 1 sql Begin
begin 2 No -op, cntr > 1
commit 1 sql Commit & sql begin.
commit 0 sql commit
Igor Tandetnik <[EMAIL PROTECTED]> wrote: Ken wrote:
> I've been looking at the server.c file. And have started some
> testing. I'd like to know if the server.c (single process, single
> server thread handling incoming requests) can handle SQL statements
> such as Begin TXn and Commit?
>
> From what I've gathered doing a begin exclusive doesnt really seem
> to work. I get success on 4 concurrent threads. Then later get a
> commit failure indicating "no transaction active"..
Be aware that SQLite doesn't support nested transactions. Suppose you
get a sequence like
BEGIN
BEGIN
COMMIT
COMMIT
First BEGIN starts a transaction. Second is simply ignored. First COMMIT
ends the transaction. Second commit produces the error you quote.
The usual solution is to handle BEGIN and COMMIT statements by
maintaining a counter. Increment it when you see a BEGIN, decrement on
COMMIT. Only actually execute BEGIN statement when counter moves from 0
to 1, and COMMIT when counter moves from 1 to 0.
Igor Tandetnik
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------