Subject: | affected_rows_length inaccurate after error |
Date: | Sun, 10 Jan 2010 03:04:30 +0100 |
To: | bug-Net-MySQL [...] rt.cpan.org |
From: | Florian Demmer <florian [...] demmer.org> |
Hi,
... I found the following minor issue with Net::MySQL 0.09. I ran into
it, because I misused the affected rows count as a way to determine if
my insert was successful. I am using is_error now ;)
However...:
- assuming a lot of insert statements, one after the other.
- first insert is successful, affected_rows_length = 1
- next insert fails because eg. of unmet foreign key constrain (error
1452..)
... affected_rows_length is still 1, because it is not reset after the
execute_command.
fix is easy; add it to _reset_status:
sub _reset_status
{
my $self = shift;
$self->{insert_id} = 0;
$self->{server_message} = '';
$self->{error_code} = undef;
$self->{selected_record} = undef;
$self->{affected_rows_length} = 0;
}
br,
Florian