MySQL autocommit and starttransaction issue.

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
MJFShark
Expert Boarder
Expert Boarder
Posts: 211
Joined: 04.06.2020, 13:59

MySQL autocommit and starttransaction issue.

Post by MJFShark »

Hi All!

If MySQL is in autocommit mode, then if you call:

StartTransaction
Update/insert/delete
Commit

My understanding is that calling Commit will automatically put the driver back into autocommit mode, but it doesn't (or I should say that the Autocommit properties are set correctly, but the underlying call to mysql_autocommit(FHandle, 1) is never made.) The Commit method has:

Code: Select all

    AutoCommit := True;
I think that the line that says AutoCommit := True is supposed to be calling SetAutocommit(True). I've made that change (in commit and rollback) in my source and it seems to fix the issue, but there may be more to it.

-Mark
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: MySQL autocommit and starttransaction issue.

Post by EgonHugeist »

Now we've loads of tests fails now. However i think you're right.

I'll implement the explicit "START TRANSACTION" syntax.

Mark i never was able to find a problem with the current logic. Can you give me an example where it did fail? -> for the tests
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
MJFShark
Expert Boarder
Expert Boarder
Posts: 211
Joined: 04.06.2020, 13:59

Re: MySQL autocommit and starttransaction issue.

Post by MJFShark »

Hi Michael,

I was able to find and diagnose the problem using two separate connections and transactionally updating records, then reading them from the second session to test if autocommit had been turned back on. In my steps above, the autocommit flag was set, but SetAutoCommit was never called at the driver level. The easiest way to diagnosed it is by putting a breakpoint on the mysql_autocommit(FHandle, 1) line. You should see that it's never called after the commit or rollback. I see you've changed the code, so I'll retest it.

So my steps to show the issue was just:

Make sure autocommit is on.
Start Transaction
Make change 1 (update a record)
Commit
Make change 2
disconnect

And see that change 2 was rolled back instead of being "autocommited" I guess the test would check if change 2 occurred.

Thanks!

-Mark
MJFShark
Expert Boarder
Expert Boarder
Posts: 211
Joined: 04.06.2020, 13:59

Re: MySQL autocommit and starttransaction issue.

Post by MJFShark »

Hi Michael,

I've done some testing on the new code and it looks great! The nested transaction support is quite nice as well. Thanks for your great work!

-Mark
Post Reply