mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
Fix a problem to do with loading the value of the FTS automerge setting from the database.
FossilOrigin-Name: 7268119f74602929b372b88eca7b3c3b4964f7d5
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix fts4growth
|
||||
set testprefix fts4growth2
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 {
|
||||
@@ -30,13 +30,12 @@ fts_kjv_genesis
|
||||
|
||||
proc tt {val} {
|
||||
execsql {
|
||||
BEGIN;
|
||||
DELETE FROM x1
|
||||
WHERE docid IN (SELECT docid FROM t1 WHERE (rowid-1)%4==$val+0);
|
||||
INSERT INTO x1(docid, content)
|
||||
SELECT docid, words FROM t1 WHERE (rowid%4)==$val+0;
|
||||
COMMIT;
|
||||
DELETE FROM x1
|
||||
WHERE docid IN (SELECT docid FROM t1 WHERE (rowid-1)%4==$val+0);
|
||||
INSERT INTO x1(docid, content)
|
||||
SELECT docid, words FROM t1 WHERE (rowid%4)==$val+0;
|
||||
}
|
||||
#puts [db eval {SELECT level, idx, end_block FROM x1_segdir}]
|
||||
}
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
@@ -45,24 +44,24 @@ do_execsql_test 1.1 {
|
||||
}
|
||||
|
||||
do_test 1.2 {
|
||||
for {set i 0} {$i < 100} {incr i} {
|
||||
for {set i 0} {$i < 40} {incr i} {
|
||||
tt 0 ; tt 1 ; tt 2 ; tt 3
|
||||
}
|
||||
execsql {
|
||||
SELECT max(level) FROM x1_segdir;
|
||||
SELECT count(*) FROM x1_segdir WHERE level=4;
|
||||
SELECT count(*) FROM x1_segdir WHERE level=3;
|
||||
}
|
||||
} {4 1}
|
||||
} {3 1}
|
||||
|
||||
do_test 1.3 {
|
||||
for {set i 0} {$i < 100} {incr i} {
|
||||
for {set i 0} {$i < 40} {incr i} {
|
||||
tt 0 ; tt 1 ; tt 2 ; tt 3
|
||||
}
|
||||
execsql {
|
||||
SELECT max(level) FROM x1_segdir;
|
||||
SELECT count(*) FROM x1_segdir WHERE level=4;
|
||||
SELECT count(*) FROM x1_segdir WHERE level=2;
|
||||
}
|
||||
} {4 1}
|
||||
} {2 1}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
@@ -53,6 +53,50 @@ do_execsql_test 2.2 { SELECT count(*) FROM t1_segdir; } 35
|
||||
do_execsql_test 2.3 { INSERT INTO t1(t1) VALUES('optimize') } {}
|
||||
do_execsql_test 2.4 { SELECT count(*) FROM t1_segdir; } 1
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Now test that the automerge=? option appears to work.
|
||||
#
|
||||
do_execsql_test 2.1 { CREATE VIRTUAL TABLE t2 USING fts4; }
|
||||
|
||||
set doc ""
|
||||
foreach c1 "a b c d e f g h i j" {
|
||||
foreach c2 "a b c d e f g h i j" {
|
||||
foreach c3 "a b c d e f g h i j" {
|
||||
lappend doc "$c1$c2$c3"
|
||||
}
|
||||
}
|
||||
}
|
||||
set doc [string repeat $doc 10]
|
||||
|
||||
foreach {tn am expected} {
|
||||
1 {automerge=2} {1 1 2 1 4 1 6 1}
|
||||
2 {automerge=4} {1 2 2 1 3 1}
|
||||
3 {automerge=8} {0 4 1 3 2 1}
|
||||
4 {automerge=1} {0 4 1 3 2 1}
|
||||
} {
|
||||
foreach {tn2 openclose} {1 {} 2 { db close ; sqlite3 db test.db }} {
|
||||
do_test 2.2.$tn.$tn2 {
|
||||
execsql { DELETE FROM t2 }
|
||||
execsql { INSERT INTO t2(t2) VALUES($am) };
|
||||
|
||||
eval $openclose
|
||||
|
||||
for {set i 0} {$i < 100} {incr i} {
|
||||
execsql {
|
||||
BEGIN;
|
||||
INSERT INTO t2 VALUES($doc);
|
||||
INSERT INTO t2 VALUES($doc);
|
||||
INSERT INTO t2 VALUES($doc);
|
||||
INSERT INTO t2 VALUES($doc);
|
||||
INSERT INTO t2 VALUES($doc);
|
||||
COMMIT;
|
||||
}
|
||||
}
|
||||
|
||||
execsql { SELECT level, count(*) FROM t2_segdir GROUP BY level }
|
||||
} [list {*}$expected]
|
||||
}
|
||||
}
|
||||
|
||||
sqlite3_enable_shared_cache $::enable_shared_cache
|
||||
finish_test
|
||||
|
||||
@@ -112,7 +112,7 @@ set allquicktests [test_set $alltests -exclude {
|
||||
incrvacuum_ioerr.test autovacuum_crash.test btree8.test shared_err.test
|
||||
vtab_err.test walslow.test walcrash.test walcrash3.test
|
||||
walthread.test rtree3.test indexfault.test securedel2.test
|
||||
fts3growth2.test
|
||||
fts4growth.test fts4growth2.test
|
||||
}]
|
||||
if {[info exists ::env(QUICKTEST_INCLUDE)]} {
|
||||
set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
|
||||
|
||||
Reference in New Issue
Block a user