Michael Ekstrand wrote:
[EMAIL PROTECTED] wrote:
The ROWID is generated after the BEFORE triggers fire and
before the row is inserted.
OK, I think I'm getting it. The INSERT statement generates the ROWID,
fires triggers, then inserts the row. When the transaction is
committed, all that is committed; when the transaction is rolled back,
it pretends it didn't happen.
What happens to the ROWID when the transaction is rolled back? Is it
as if the record with that ROWID was deleted?
Yes
If I understand it correctly, connection C1 can do an INSERT, get
ROWID 4, C2 does an INSERT, gets 5, and commits, and then C1 commits,
with its 4; if C1 rolled back, there's no 4 in the database, just 5
and whatever else, correct?
No, this can't happen. As soon as C1 does its insert, it acquires an
exclusive lock on the database. C2 can't do an insert until C1 either
commits or rolls back and releases the lock. If C1 committed, then C2
will get 5, if C1 rolled back, then C2 will get 4.
HTH
Dennis Cote
- Re: [sqlite] Transactions and sqlite3_last_insert_rowid Dennis Cote
-