mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Fix fts3 to not have the VACUUM bug from fts2. %_content.docid is an
alias to fix the rowid for documents, %_segments.blockid is an alias to fix the rowid for segment blocks. Unit test for the problem. (CVS 4280) FossilOrigin-Name: 6eb2d74a8cfce322930f05c97d4ec255f3711efb
This commit is contained in:
106
test/fts3b.test
Normal file
106
test/fts3b.test
Normal file
@ -0,0 +1,106 @@
|
||||
# 2007 August 20
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#*************************************************************************
|
||||
# This file implements regression tests for SQLite library. This
|
||||
# script tests for the fts2 rowid-versus-vacuum problem (ticket #2566).
|
||||
#
|
||||
# $Id: fts3b.test,v 1.1 2007/08/23 20:23:37 shess Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
db eval {
|
||||
CREATE VIRTUAL TABLE t1 USING fts3(c);
|
||||
INSERT INTO t1 (c) VALUES('this is a test');
|
||||
INSERT INTO t1 (c) VALUES('that was a test');
|
||||
INSERT INTO t1 (c) VALUES('this is fun');
|
||||
DELETE FROM t1 WHERE c = 'that was a test';
|
||||
}
|
||||
|
||||
# Baseline test.
|
||||
do_test fts3b-1.1 {
|
||||
execsql {
|
||||
SELECT rowid FROM t1 WHERE c MATCH 'this';
|
||||
}
|
||||
} {1 3}
|
||||
|
||||
db eval {VACUUM}
|
||||
|
||||
# The VACUUM renumbered the t1_content table in fts2, which breaks
|
||||
# this.
|
||||
do_test fts3b-1.2 {
|
||||
execsql {
|
||||
SELECT rowid FROM t1 WHERE c MATCH 'this';
|
||||
}
|
||||
} {1 3}
|
||||
|
||||
# The t2 table is unfortunately pretty contrived. We need documents
|
||||
# that are bigger than ROOT_MAX (1024) to force segments out of the
|
||||
# segdir and into %_segments. We also need to force segment merging
|
||||
# to generate a hole in the %_segments table, which needs more than 16
|
||||
# docs. Beyond that, to test correct operation of BLOCK_SELECT_STMT,
|
||||
# we need to merge a mult-level tree, which is where the 10,000 comes
|
||||
# from. Which is slow, thus the set of transactions, with the 500
|
||||
# being a number such that 10,000/500 > 16.
|
||||
set text {
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
|
||||
iaculis mollis ipsum. Praesent rhoncus placerat justo. Duis non quam
|
||||
sed turpis posuere placerat. Curabitur et lorem in lorem porttitor
|
||||
aliquet. Pellentesque bibendum tincidunt diam. Vestibulum blandit
|
||||
ante nec elit. In sapien diam, facilisis eget, dictum sed, viverra
|
||||
at, felis. Vestibulum magna. Sed magna dolor, vestibulum rhoncus,
|
||||
ornare vel, vulputate sit amet, felis. Integer malesuada, tellus at
|
||||
luctus gravida, diam nunc porta nibh, nec imperdiet massa metus eu
|
||||
lectus. Aliquam nisi. Nunc fringilla nulla at lectus. Suspendisse
|
||||
potenti. Cum sociis natoque penatibus et magnis dis parturient
|
||||
montes, nascetur ridiculus mus. Pellentesque odio nulla, feugiat eu,
|
||||
suscipit nec, consequat quis, risus.
|
||||
}
|
||||
append text $text
|
||||
|
||||
db eval {CREATE VIRTUAL TABLE t2 USING fts3(c)}
|
||||
set res {}
|
||||
db eval {BEGIN}
|
||||
for {set ii 0} {$ii<10000} {incr ii} {
|
||||
db eval {INSERT INTO t2 (c) VALUES ($text)}
|
||||
lappend res [expr {$ii+1}]
|
||||
if {($ii%500)==0} {
|
||||
db eval {
|
||||
COMMIT;
|
||||
BEGIN;
|
||||
}
|
||||
}
|
||||
}
|
||||
db eval {COMMIT}
|
||||
|
||||
do_test fts3b-2.1 {
|
||||
execsql {
|
||||
SELECT rowid FROM t2 WHERE c MATCH 'lorem';
|
||||
}
|
||||
} $res
|
||||
|
||||
db eval {VACUUM}
|
||||
|
||||
# The VACUUM renumbered the t2_segment table in fts2, which would
|
||||
# break the following.
|
||||
do_test fts3b-2.2 {
|
||||
execsql {
|
||||
SELECT rowid FROM t2 WHERE c MATCH 'lorem';
|
||||
}
|
||||
} $res
|
||||
|
||||
finish_test
|
Reference in New Issue
Block a user