AnyEvent::DBI begin_work returns undef in $rc and not true when sucessful

Jerry Lundström jerry.lundstrom at iis.se
Wed Mar 20 10:06:25 CET 2013


Hi,

I'm using AnyEvent::DBI with transactions and noticed that $rc for the begin_work() callback was undef altho there was no error and the transaction started.

I changed req_being_work() to save $rc and Data::Dumper it, saw it was 1, used it in the last return row and still got undef back. Remembering something strange about using 'or' like this I wrapped begin_work() and die in () and it worked a lot better and I got 1 in $rc on the other side.

Here is the small patch, there might be other places and one might use ( x ? 1 : die ) instead to clearly send 1 back on success.

Ubuntu Server LTS 12.04.2
perl 5.14.2-6ubuntu2.3
AnyEvent 6.120-1
AnyEvent::DBI 2.2
DBI 1.616-1build2

Regards,
Jerry

--- DBI.pm.orig    2013-03-18 17:16:57.069082243 +0100
+++ DBI.pm    2013-03-18 17:16:52.825213832 +0100
@@ -110,15 +110,15 @@
}

sub req_begin_work {
-   [1, $DBH->begin_work or die [$DBI::errstr]]
+   [1, ($DBH->begin_work or die [$DBI::errstr])]
}

sub req_commit {
-   [1, $DBH->commit     or die [$DBI::errstr]]
+   [1, ($DBH->commit     or die [$DBI::errstr])]
}

sub req_rollback {
-   [1, $DBH->rollback   or die [$DBI::errstr]]
+   [1, ($DBH->rollback   or die [$DBI::errstr])]
}

sub req_func {

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.schmorp.de/pipermail/anyevent/attachments/20130320/859ec6da/attachment.pgp>


More information about the anyevent mailing list