21 messages in com.mysql.lists.perlRe: undefined behaviour for sub-trans...
FromSent OnAttachments
Tyler MacDonald14 Nov 2005 23:00 
Jochen Wiedmann14 Nov 2005 23:16 
Tyler MacDonald14 Nov 2005 23:41 
Jochen Wiedmann14 Nov 2005 23:51 
Tyler MacDonald15 Nov 2005 00:22 
Jochen Wiedmann15 Nov 2005 00:32 
Tyler MacDonald15 Nov 2005 00:45 
Tyler MacDonald15 Nov 2005 00:57 
Jochen Wiedmann15 Nov 2005 00:59 
Tim Bunce15 Nov 2005 05:20 
Tyler MacDonald29 Nov 2005 10:49 
Tim Bunce29 Nov 2005 11:43 
Andrew Sullivan30 Nov 2005 13:18 
Tyler MacDonald30 Nov 2005 13:31 
Jaime Casanova30 Nov 2005 13:44 
Michael Fuhr30 Nov 2005 13:57 
Tyler MacDonald30 Nov 2005 14:33 
Tim Bunce30 Nov 2005 15:35 
Jochen Wiedmann30 Nov 2005 21:04 
Andrew Sullivan01 Dec 2005 04:45 
Michael Fuhr01 Dec 2005 10:21 
Subject:Re: undefined behaviour for sub-transactions?
From:Tyler MacDonald (tyl@yi.org)
Date:11/14/2005 11:00:50 PM
List:com.mysql.lists.perl

Paul DuBois <pa@snake.net> wrote:

MySQL doesn't have sub-transactions (nested transactions). You can set savepoints within a transaction and roll back to a given savepoint and then continue the transaction from there.

Hopefully it will some day. :) I'm guessing other DBI drivers have this behaviour too... when DBI talks to a driver, does it know if it supports sub-transactions? For that matter, does it know if there is a transaction already in progress?

I'm trying to support multiple database drivers at once. I have methods that do small tasks (such as updating a table), and methods that glue these small tasks together into big tasks (such as updating a table and all of it's foreign keys). Whether it is a small task or a large task that is being done, I would like the operation to be completely atomic.

I have each small task do it's own "begin_work/commit", and then each large task wraps the whole thing in it's own "begin_work/commit". With an engine that supports nested transactions, this works perfectly. With MySQL, all of the SQL is still executed and comitted, but I get a warning on the last commit, even it PrintWarn is set to 0.

I'd rather not have to investigate / guess what every single DBD driver does and add change the behviour based on $dbh->{Driver}->{Name}.

Is there a way to ask DBI if it is already in a transaction? If it knows this and I can get that information out of it, I could make this package a lot more useable.

Thanks, Tyler