Subject: | Bug in statement cache management |
Date: | Fri, 04 May 2007 01:38:54 +0200 |
To: | bug-DBIx-Simple [...] rt.cpan.org |
From: | Stanis Trendelenburg <stanis.trendelenburg [...] pluto.uni-freiburg.de> |
Hi,
there is a small bug in the handling of the statement cache in query(),
which causes identical statements to be inserted into the cache multiple
times if the existing entry is at position 0.
Checking for definedness fixes this (see diff).
Thanks for a great module!
--- DBIx/Simple.pm.orig 2007-05-04 01:23:25.000000000 +0200
+++ DBIx/Simple.pm 2007-05-04 01:23:03.000000000 +0200
@@ -134,7 +134,7 @@
my $old = $old_statements{$self};
- if (my $i = (grep $old->[$_][0] eq $query, 0..$#$old)[0]) {
+ if (defined( my $i = (grep $old->[$_][0] eq $query, 0..$#$old)[0] )) {
$st = splice(@$old, $i, 1)->[1];
$sth = $st->{sth};
} else {