[Monetdb-developers] python adapter: transaction semantics and connection.close()

Mark Bucciarelli mkbucc at gmail.com
Wed Jun 30 14:42:40 CEST 2010


Hey Gijs,

I'm seeing a difference in how MonetDB and SQLite
handle transactions inside Django.

Here's my current unit test in Django (it passes w/
SQLite and fails with MonetDB):

        1   : s1 = Simple(name="mark")
        2   : s1.save()
        3   :
        4   : s2 = Simple(name="mark")
        5   : try:
        6   :         s2.save()
        7   : except IntegrityError:
        8   :        pass
        9   :
        10 : s = Simple.objects.get(name="mark")
        11 : print s

What happens under SQLite is the save on line 6
fails, but the select on line 10 works.

In MonetDB, at line 10, I get the error

     current transaction is aborted
     (please ROLLBACK)

Here's the trace of mapi2 commands, starting
from line 2

mapi2.py, cmd, operation = sINSERT INTO "testapp_simple" ("name")
VALUES ('mark');
mapi2.py, cmd, operation = Xreply_size 1
mapi2.py, cmd, operation = sCOMMIT;
mapi2.py, cmd, operation = Xreply_size 1000
mapi2.py, cmd, operation = sINSERT INTO "testapp_simple" ("name")
VALUES ('mark');
mapi2.py, cmd, operation = Xreply_size 1000
mapi2.py, cmd, operation = sSELECT "testapp_simple"."id",
"testapp_simple"."name" FROM "testapp_simple" WHERE
"testapp_simple"."name" =  'mark' ;
mapi2.py, cmd, operation = Xreply_size 1
mapi2.py, cmd, operation = sROLLBACK;

It looks like the ROLLBACK isn't executed until the
connection closes.

With auto commit off, shouldn't the ROLLBACK fire
as soon as the insert fails?

If so, how do I fix this?

Thanks

m




More information about the developers-list mailing list