Package: libdbd-sqlite3-perl
Version: 1.14-1
Severity: normal
The program foo.pl below run as "perl foo.pl" produces
DBD::SQLite::st execute failed: column x is not unique(19) at dbdimp.c line
403 at foo.pl line 17.
Segmentation fault
where I hoped it wouldn't seg fault, but just print the error message
and otherwise succeed.
I suspect that when sqlite_st_execute gets an "insert" error like this
it ends up freeing the underlying "sqlite3_stmt" object, so that a
further execute of it bombs. I think the free is done by the following
line in sqlite_st_execute (the first one, at "return -5"),
/* There are bug reports that say this should be sqlite3_reset() */
sqlite3_finalize(imp_sth->stmt);
I think the comment is right, under gdb you can see the stmt pointer
value getting used again on the next execute of the same perl-level
$sth. Actually I saw that stmt space getting overwritten with the error
message string "column x is not unique ...", which made me wonder if was
some sort of pointer juggling mixup, but I think it's just coincidence
that it's related data ending up there after the space has been free()ed
and then handed out by malloc() again. (Results vary if for instance
you turn on $dbh->trace()s.)
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i586)
Kernel: Linux 2.6.22-2-486
Locale: LANG=en_AU, LC_CTYPE=en_AU (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash
Versions of packages libdbd-sqlite3-perl depends on:
ii libc6 2.6.1-2 GNU C Library: Shared libraries
ii libdbi-perl 1.601-1 Perl5 database interface by Tim Bu
ii libsqlite3-0 3.4.2-2 SQLite 3 shared library
ii perl 5.8.8-11.1 Larry Wall's Practical Extraction
ii perl-base [perlapi-5.8.8] 5.8.8-11.1 The Pathologically Eclectic Rubbis
libdbd-sqlite3-perl recommends no packages.
-- no debconf information
use strict;
use warnings;
use DBI;
my $filename = '/tmp/foo.db';
unlink ($filename);
my $dbh = DBI->connect ("dbi:SQLite:dbname=$filename", '', '',
{RaiseError=>0, PrintError=>1});
$dbh->do ('CREATE TABLE bar (x TEXT, y TEXT, PRIMARY KEY (x))');
{
my $sth = $dbh->prepare ("INSERT INTO bar (x, y) VALUES (?,?)");
$sth->execute ('a', 'b');
$sth->finish;
$sth->execute ('a', 'b');
$sth->finish;
$sth->execute ('c', 'd');
$sth->finish;
}