[yunqa.de] Re: DiSqlite - Intransaction bug?

  • From: Clyde England <clyde@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Wed, 6 Jan 2010 00:08:37 +0800

> 1. From reading our past conversation on TDISQLite3Database.InTransaction,
> the fix provides a way to work around your practice of mixing
> TDISQLite3Database.Execute("BEGIN") with TDISQLite3Database.InTransaction.
>

Database.Intransaction logic still seems flawed to me. My original problem
was that I was getting this error: "SQLite Error 1 - cannot commit - no
transaction is active" when trying to do database.commit when
database.Intransaction = True

I had removed all uses of TDISQLite3Database.Execute("BEGIN") and replaced
with TDISQLite3Database.StartTransaction. However I still ran into the
problem (with the original "before fix" code)

I think I have tracked down the cause and it would appear that the
transaction counter is not reset on a close of the database.

Shouldn't the counter be reset when you close a database (even though the
transaction has not been committed)?

Take for example the following code:

database.open;
database.starttransaction;
database.close;
database.open;

At this point database.intransaction returns true, and if you try to execute
database.commit you get my original error.

I would have thought that closing the database would have reset the
transaction counter so that database.intransaction would now return false.

Even opening a different database, database.intransaction is still true.
Example:

database.databasename := 'c:\temp\yyy.db3')
database.open;
database.starttransaction;
database.close;
dbs.databasename := 'c:\temp\xxx.db3';
database.open;

I am having trouble understanding how we can still be in a transaction here.
Can transactions persist across opening and closing of databases?

Perhaps it is just my ignorance of how database.intransaction is working in
this scenario. If you could please explain it would be appreciated.

Note: The "after" fix code correctly seems to report database.intransaction
= false for all the above sample code.

Thanks
Clyde

Other related posts: