[DBD-SQLite] Error handling: $sth->execute returns nothing after SQL error

Yuriy Kaminskiy yumkam at mail.ru
Tue Oct 4 19:29:24 GMT 2011


Hello!
I noticed strange problem on error path handling.

Not sure if this sqlite error, DBD::SQLite error, or some misunderstanding on my
part.

Verified on DBD::SQLite-1.33 and 1.34_1 (with bundled sqlite.c) and DBI-1.616.

my $sth=$dbh->prepare("SELECT * FROM t");
$sth->execute; # success - 0E0
my $row1 = $sth->fetch; # returns [1]
$sth->finish;
sleep 5;
# ^^ here another instance issued BEGIN EXCLUSIVE ...
$sth->execute; # ... so this returns "database is locked";
# it's legitimate/expected behavior
#
$sth->finish; # just in case (clears error)
#
sleep 5;
# ^^ here another instance already COMMIT'ed, DB is not locked anymore
#
$sth->execute; # success - 0E0
my $row2 = $sth->fetch; # returns undef
#
# WTF?
#
# If I prepare another statement (cloned from first!),
# it returns row as expected:
#
my $sth2 = $dbh->prepare($sth->{Statement});
$sth2->execute; # success
my $row3 = $sth2->fetch; # returns [1]




More information about the DBD-SQLite mailing list