I have the following code using DBD::Sybase under apache 1.3/mod_perl 1.xx, where AutoCommit is off:
$dbh->{RaiseError} = 1;
eval {
$sth = $dbh->prepare_cached('exec xx ?');
$sth->bind_param(1, $a, { TYPE => SQL_INTEGER });
$sth->execute;
$sth->finish;
[ other non-dbi stuff being done here ... ]
$dbh->commit;
};
if ($@) {
my $prev_error = $@;
eval { $dbh->rollback };
$dbh->{RaiseError} = 0;
return ([ -999, "Got error: $prev_error"]);
}
$dbh->{RaiseError} = 0;I know that the DBI docs say that we technically can simply rollback a dbh without worrying about finishing a sth, but is that certainly the case for all DBDs? I seem to have a problem where if the statement execute fails due to for example a unique index duplicate, the apache process hangs with infinite loop AFTER it successfully fully processes the request and returns properly. That is very weird to say the least.
Any ideas?
Thanks.
