From: shess Date: Wed, 29 Nov 2006 21:03:00 +0000 (+0000) Subject: Test that terms longer than interior nodes work correctly. A bug X-Git-Tag: version-3.6.10~2645 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d53f898f517c1113b710991ecafc37c1a7540618;p=thirdparty%2Fsqlite.git Test that terms longer than interior nodes work correctly. A bug prior to fts2.c r1.10 meant that such large terms caused an eventual stack overflow. (CVS 3523) FossilOrigin-Name: 66581162daa188d23078c9d21fd5b2563d4d238a --- diff --git a/manifest b/manifest index f9fb3f3f1d..e0c0ed8366 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Added\sthe\sspeed1.test\sscript\s(CVS\s3522) -D 2006-11-29T20:53:00 +C Test\sthat\sterms\slonger\sthan\sinterior\snodes\swork\scorrectly.\s\sA\sbug\nprior\sto\sfts2.c\sr1.10\smeant\sthat\ssuch\slarge\sterms\scaused\san\seventual\nstack\soverflow.\s(CVS\s3523) +D 2006-11-29T21:03:01 F Makefile.in 8e14898d41a53033ecb687d93c9cd5d109fb9ae3 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -214,6 +214,7 @@ F test/fts2d.test b7eaa671ca9a16997f3e5b158ee777ae21052b0b F test/fts2e.test 2da13dbc2d009105f42196845c1e1ce136c03d38 F test/fts2f.test b5f2dde48199d79e859f59d3d857c17dd62a0129 F test/fts2g.test c69a8ab43ec77d123976ba6cf9422d647ae63032 +F test/fts2h.test 223af921323b409d4b5b18ff4e51619541b174bb F test/func.test 0ed54b5aeaad319f68016c033acfebef56f5874a F test/hook.test 7e7645fd9a033f79cce8fdff151e32715e7ec50a F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d @@ -422,7 +423,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P 18142fdb6d1f5bfdbb1155274502b9a602885fcb -R 590b2542fbd343bc6050f65cab5d384c -U drh -Z f39cd1a25039ed82be237a01b15c2aa9 +P 30355dfbd920f3b6a78110aaf370371f620324b7 +R 54e92d25d9c8044ff80933a9c6310e49 +U shess +Z f1a89a15a1180a5b8ccca04f66d7e8a3 diff --git a/manifest.uuid b/manifest.uuid index 84835a3216..a4debc8d2e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -30355dfbd920f3b6a78110aaf370371f620324b7 \ No newline at end of file +66581162daa188d23078c9d21fd5b2563d4d238a \ No newline at end of file diff --git a/test/fts2h.test b/test/fts2h.test new file mode 100644 index 0000000000..72561d85bc --- /dev/null +++ b/test/fts2h.test @@ -0,0 +1,76 @@ +# 2006 October 31 (scaaarey) +# +# The author disclaims copyright to this source code. +# +#************************************************************************* +# This file implements regression tests for SQLite library. The focus +# here is testing correct handling of excessively long terms. +# +# $Id: fts2h.test,v 1.1 2006/11/29 21:03:01 shess Exp $ +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# If SQLITE_ENABLE_FTS2 is defined, omit this file. +ifcapable !fts2 { + finish_test + return +} + +# Generate a term of len copies of char. +proc bigterm {char len} { + for {set term ""} {$len>0} {incr len -1} { + append term $char + } + return $term +} + +# Generate a document of bigterms based on characters from the list +# chars. +proc bigtermdoc {chars len} { + set doc "" + foreach char $chars { + append doc " " [bigterm $char $len] + } + return $doc +} + +set len 5000 +set doc1 [bigtermdoc {a b c d} $len] +set doc2 [bigtermdoc {b d e f} $len] +set doc3 [bigtermdoc {a c e} $len] + +set aterm [bigterm a $len] +set bterm [bigterm b $len] +set xterm [bigterm x $len] + +db eval { + CREATE VIRTUAL TABLE t1 USING fts2(content); + INSERT INTO t1 (rowid, content) VALUES(1, $doc1); + INSERT INTO t1 (rowid, content) VALUES(2, $doc2); + INSERT INTO t1 (rowid, content) VALUES(3, $doc3); +} + +# No hits at all. Returns empty doclists from termSelect(). +do_test fts2h-1.1 { + execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'} +} {} + +do_test fts2h-1.2 { + execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm} +} {1 3} + +do_test fts2h-1.2 { + execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm} +} {} + +do_test fts2h-1.3 { + execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'" +} {1 3} + +do_test fts2h-1.4 { + execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'" +} {1} + +finish_test