From: "Marcus Welz" <[EMAIL PROTECTED]>
Reply-To: sqlite-users@sqlite.org
To: <sqlite-users@sqlite.org>
Subject: RE: [sqlite] BEGIN TRANSACTION name
Date: Thu, 3 Nov 2005 12:46:39 -0500

I actually have a question regarding nested transactions. Maybe I'm missing
something, but isn't it true that the outermost transaction must be
committed successfully in order for any of the nested transactions to also
be committed successfully?

For example if I have:

BEGIN TRANSACTION a;

BEGIN TRANSACTION b;

[some sql code]

COMMIT;

[some sql code that errors out]

ROLLBACK;


Wouldn't that mean that, even though transaction "b" was successful, since
the whole thing was embedded into transaction "a" it would fail anyway?

So, couldn't SQLite simply internally keep track of nested transaction
through a counter that is incremented every time "BEGIN TRANSACTION" is
encountered and decremented whenever "COMMIT" is encountered, and only truly
COMMIT when that counter has reached 0 again?

(That's what I implemented for an in-house abstraction layer.)

Just wondering if I'm missing something critical.


Thanks.

You are exactly right on all points. In fact, as I understand it, this is actually what MS SQL Server does internally.

IMHO knowing that there isn't any real benefit to nested transactions then a developer should normally be able to design code that doesn't use nested transactions.

--Preston


Reply via email to