On Tue, 15 Oct 2002 18:55:06 +0100, Kate L Pugh wrote:
>     if ($@) { 
>         my $error = $@; 
>         $dbh->rollback; 
>         $dbh->{AutoCommit} = 1; 
>         if ($error =~ /Can't serialize access due to concurrent update/) { 
>             return 0; 
>         } else { 
>             croak $error; 
>         } 
> 
> -- is that evil?  Relying on DBI to give me the right error message?

Yes; error messages will always change in the future. You could test $dbh->err
or $dbh->state for more robust checking. Just remember to grab it before you
do anything else with $dbh, like rollback.

> Note this is in the code, not the test.  An alternative would be to
> always return 0, but that'd mean flagging an actual error as a
> conflict, and I'd like to keep those separate since a conflict isn't
> really an error.)

It's still an error if you don't retry the transaction. This is why I don't
like serialised transactions - they require too much extra work. Of course,
for some scenarios they're essential, but I don't have any of those.

-- 
        Peter Haworth   [EMAIL PROTECTED]
"f y cn rd ths y mst hv bn sng nx"

Reply via email to