-
Notifications
You must be signed in to change notification settings - Fork 29
Understanding Transactions in ODBC #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
see Line 4334 in 9cd50a5
There is a way to see if you are in a transaction. Also you are correct this is how you control transactions
Autocommit is not really slow. There is nothing committed in a read. Dave
|
Thanks @davecramer,
From outside the ODBC driver? How?
So to begin a transaction, I would
To commit I would...
Rollback the same but with Error handlingIf I can't commit (deadlock etc.) then it is implicitly a rollback, right? Or should I then call I any case, I would still continue with 2. and 3. _Mark |
Uh oh!
There was an error while loading. Please reload this page.
Hi
thank you for this superb project!
Transactions in ODBC
I have trouble understanding how transactions work in ODBC in general, and with pslqODBC specifically.
ODBC creator Microsoft describes the behavior here: Performing Transactions in ODBC. However it is not entirely clear to me, whether that is ODBC intended standard behavior, or just their SQL Server's.
Most notably, there is no
begin transaction
in ODBC. It seems the ODBC driver is supposed to start a transaction implicitly when the first statement is executed after either setting autocommit off, or afterSQLEndTran()
.This seems very bad ODBC API design, especially as there seems no way to ask the ODBC driver whether a transaction is open or not (?).
If I'm not mistaken, I see this implemented in psqlODBC, here:
psqlodbc/connection.c
Line 1802 in 9cd50a5
But I sometimes still got errors that a transaction is not open. I can't reproduce it right now, but I feel I'm missing something.
What I'd like to achieve
I have (basically) two kinds of db access:
begin
and thecommit
.Reliably switching between the two makes it difficult. I don't want any lingering transactions, that were auto-opened after the last
commit
.I wonder if I should switch autocommit ON after each
SQLEndTran()
. And switch it OFF to actually "simulate" thebegin
of the transaction (it will still only be initiated when the first statement is issued). To make matters worse, I would also have to switch between concurrency isolation levels. How? In what order?I wonder if autocommit is slow. I imagine performing so many commits could be heavy. Maybe I should not use it, but commit the transaction after each top level GUI function call (or similar).
Any advice?
Thanks,
_Mark
The text was updated successfully, but these errors were encountered: