Subject: | Segfault with fts3 |
The attached script fails on 1.25 and 1.26_04. It does one of three things:
- segfaults
- gives a double free error
- hangs without any cpu activity
Which of the above three it does depends on the exact script (adding or
removing a print line can change its behavior), but it always fails.
Here are a couple sample error messages:
*** glibc detected *** double free or corruption (!prev):
0x000000000083c480 ***
Abort (core dumped)
Segmentation fault (core dumped)
The database doesn't appear to be corrupted after the failure -- running
an integrity check with the sqlite3 command line binary says the db is okay.
The equivalent code without the fts3 module works fine.
I did a quick test with the DBD::SQLite packaged with the latest Ubuntu
(1.14), and that version seems to work.
Subject: | fts3.pl |
#!/usr/bin/perl
#
#use lib '/tmp/DBD-SQLite-1.26_04/blib/lib';
#use lib '/tmp/DBD-SQLite-1.26_04/blib/arch';
use lib '/home/ewing/tmp/DBD-SQLite-1.25/blib/lib';
use lib '/home/ewing/tmp/DBD-SQLite-1.25/blib/arch';
use DBI;
use Data::Dumper;
my $DB = "/tmp/test1.db";
sub insert_data {
my($dbh, $inc_num, $date, $text) = @_;
# "OR REPLACE" isn't standard SQL, but it sure is useful
my $sth = $dbh->prepare('INSERT OR REPLACE INTO incident_fts (incident_id, all_text) VALUES (?, ?)');
$sth->execute($inc_num, $text) || die "execute failed\n";
$dbh->commit;
}
unlink $DB;
my $dbh = DBI->connect("dbi:SQLite:$DB");
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
$dbh->do(<<EOF);
CREATE VIRTUAL TABLE incident_fts
USING fts3 (incident_id VARCHAR, all_text VARCHAR, TOKENIZE simple)
EOF
$dbh->commit;
insert_data($dbh, '595', time(), "sample text foo bar baz");
insert_data($dbh, '595', time(), "sample text foo bar baz");
insert_data($dbh, '595', time(), "sample text foo bar baz");
insert_data($dbh, '595', time(), "sample text foo bar baz");
$dbh->commit;
my $sth = $dbh->prepare("SELECT * FROM incident_fts WHERE all_text MATCH 'bar'");
$sth->execute();
while (my $row = $sth->fetchrow_hashref("NAME_lc")) {
print Dumper $row;
}
$dbh->commit;