[Mono-dev] More ODBC questions: AutoCommit and BeginTransaction

Mads Bondo Dydensborg mbd at dbc.dk
Mon Sep 24 06:46:49 EDT 2007


fredag 21 September 2007 skrev Amc Gmail:
> Hi, Mads,
> 
> it seems to be you are right and i am also getting ugly transaction
> state errors from db2 odbc with mono. i wrote quick dirty patch :) to
> fix OdbcTransaction.cs and it would be great if you can try it (diff
> and svn diff attached, use any for your convenience). unfortunately i
> can't even compile it before mid-october and so sorry (in advance) if
> that code has any bugs.

Hi Amc.

I just tried your patch, and it works very nicely. There was a small problem 
in getting it to compile, because your patch actually exposes a bug, IMHO, in 
the existing codebase. Please find attached a patch against current svn.

To the ODBC maintainer: Please review this patch for inclusion in mono. I 
believe it solves two things:
- setting autocommit back to on (default for ODBC), when leaving a transaction
- actually throws, if the isolationlevel of a transaction can not be set 
through the odbc driver.

Regards,

Mads


> 
> i hope it would help :)
> -- amc
> 
> 
> On 9/21/07, Mads Bondo Dydensborg <mbd at dbc.dk> wrote:
> > mandag 03 September 2007 skrev Mads Bondo Dydensborg:
> > Hi again.
> >
> > I still can not resolve this question. But I did discover, that there is 
no
> > public way to change the autocommit mode through the mono stack, meaning,
> > that if one uses a transaction, one can never return to autocommit mode.
> >
> > Is this really the right way to do things?
> >
> > Regards
> >
> > Mads
> >
> >
> > > Hi all
> > >
> > > I am not posting a bug, because I have no idea if this is a bug. Perhaps
> > this
> > > is the intended way:
> > >
> > > For ODBC connections, the default mode is "autocommit": Each statement 
is
> > > followed by an commit, done by the driver, client side. This can be 
disabled
> > > programmatically.
> > >
> > > When an ODBC transaction is created in mono, we change the attributes in
> > > OdbcTransaction.cs:
> > >
> > >      51                 internal OdbcTransaction(OdbcConnection conn,
> > > IsolationLevel isolationlevel)
> > >      52                 {
> > >      53                         // Set Auto-commit (102) to false
> > >      54                         OdbcReturn
> > > ret=libodbc.SQLSetConnectAttr(conn.hDbc, 
OdbcConnectionAttribute.AutoCommit,
> > > IntPtr.Zero, 0);
> > >
> > > We have to do that, obviously, but my question is wheter mono should
> > > reestablish the state of autocommit upon completion of the transaction?
> > > Currently it does not, but is this to be expected? I think, from my 
reading
> > > that it is, but would very much like a confirmation.
> > >
> > > Currently I am not able to check out the behavoiur using MS .NET.
> > >
> > > Thanks,
> > >
> > > Regards
> > >
> > > Mads
> > >
> > > --
> > > Med venlig hilsen/Regards
> > >
> > > Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo
> > Dydensborg
> > > Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 
77
> > 34
> > >
> > > _______________________________________________
> > > Mono-devel-list mailing list
> > > Mono-devel-list at lists.ximian.com
> > > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> > >
> > >
> >
> >
> >
> > --
> > Med venlig hilsen/Regards
> >
> > Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo 
Dydensborg
> > Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 
77 34
> >
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> >
> 



-- 
Med venlig hilsen/Regards

Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo Dydensborg
Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 77 34
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OdbcTransaction-autocommit-isolationlevel-20090924.diff
Type: text/x-diff
Size: 2742 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070924/61da1875/attachment.bin 


More information about the Mono-devel-list mailing list