[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-users
Subject:    Re: [sqlite] Nested transactions
From:       Darren Duncan <darren () darrenduncan ! net>
Date:       2013-11-23 10:30:05
Message-ID: 529083AD.8070305 () darrenduncan ! net
[Download RAW message or body]

On 2013.11.23 1:31 AM, Clemens Ladisch wrote:
> Igor Korot wrote:
>> If I understand correctly, I can do this (pseudo-code):
>>
>> BEGIN TRANSACTION;
>> // some SQL statements
>> BEGIN TRANSACTION;
>
> sqlite> begin; begin;
> Error: cannot start a transaction within a transaction
>
>> This scenario will not end up with with unfinished transaction and I
>> don't have to use SAVEPOINT/RELEASE in this case.
>
> You have to use SAVEPOINT/RELEASE.
>
> (Why don't you want to use it?)

I agree.  The concept of nested transactions is identical behaviorally to 
savepoints; they are just different syntax for the same thing, which is to let 
you undo a portion of the current transaction rather than the whole thing.  But 
only the parentmost transaction is a real transaction, with the ACID properties, 
eg only the parentmost committing actually saves anything for good.

Maybe what you're wanting is "autonomous transactions", which can be useful, but 
you can also implement that yourself just by having a second connection to the 
database from your application, which is behaviorally the same.  Although with 
SQLite it may not be helpful if one connection would block for the other, but 
other DBMSs that don't lock the whole database they may be useful with.

-- Darren Duncan


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic