From 726440ae80791553c9bae5831da4eca0e94e081b Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Thu, 15 Oct 2009 01:20:12 +0000 Subject: [PATCH] DBD::SQLite: added a failing test (WARNING: this test may cause segfaults now!), adapted from RT #50503 posted by sendai --- t/rt_50503_fts3.t | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 t/rt_50503_fts3.t diff --git a/t/rt_50503_fts3.t b/t/rt_50503_fts3.t new file mode 100644 index 0000000..c864823 --- /dev/null +++ b/t/rt_50503_fts3.t @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use t::lib::Test; +use Test::More; +use Test::NoWarnings; + +plan tests => 6; + +my $dbh = connect_ok( RaiseError => 1, AutoCommit => 0 ); + +$dbh->do(<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")) { + # The result may vary with or without an output, + # but anyway, either case seems failing at the destruction. + ok %$row; + #ok %$row, join ',', %$row; + } +} + +$dbh->commit; + +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; +}