From: shess Date: Tue, 29 Jul 2008 20:24:46 +0000 (+0000) Subject: Add some simple tests to make sure that the different fulltextFilter X-Git-Tag: version-3.6.10~679 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9eb7c2ad832023be884068416fdfccbd81641339;p=thirdparty%2Fsqlite.git Add some simple tests to make sure that the different fulltextFilter query paths are being exercised. (CVS 5498) FossilOrigin-Name: ae96d960e6e31315d25c7e5c3fb8363ed1b35350 --- diff --git a/manifest b/manifest index 8bc73b11d3..ebf686f06d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C finally\smake\stemporary\sand\sjournal\sfiles\shidden\sin\srelease\sbuilds\son\sOS/2\s(CVS\s5497) -D 2008-07-29T18:49:29 +C Add\ssome\ssimple\stests\sto\smake\ssure\sthat\sthe\sdifferent\sfulltextFilter\nquery\spaths\sare\sbeing\sexercised.\s(CVS\s5498) +D 2008-07-29T20:24:46 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in bbb62eecc851379aef5a48a1bf8787eb13e6ec06 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -339,6 +339,7 @@ F test/fts3atoken.test 25c2070e1e8755d414bf9c8200427b277a9f99fa F test/fts3b.test b3a25180a633873d37d86e1ccd00ed690d37237a F test/fts3c.test 4c7ef29b37aca3e8ebb6a39b57910caa6506034e F test/fts3d.test d92a47fe8ed59c9e53d2d8e6d2685bb380aadadc +F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 F test/fts3near.test 2d4dadcaac5025ab65bb87e66c45f39e92966194 F test/func.test 20973677b5be7e9f199854779dae85053cc6438d F test/fuzz.test 62fc19dd36a427777fd671b569df07166548628a @@ -612,7 +613,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 6eac49f046d089dac90c0bf72e8c3fc583694dcd -R 37db558a63fbbe7b21086d8a66873964 -U pweilbacher -Z 8f64b0555e1ee664441fa92b59a45394 +P c449a95c4f7abd2bfb92bed0e3a9ae874350ce79 +R b698c84f6b41998f7179c968db38e9a8 +U shess +Z 8007ccac7fb34b00a3c12fd8cb677718 diff --git a/manifest.uuid b/manifest.uuid index b16b20bbf7..cf6a2a0921 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c449a95c4f7abd2bfb92bed0e3a9ae874350ce79 \ No newline at end of file +ae96d960e6e31315d25c7e5c3fb8363ed1b35350 \ No newline at end of file diff --git a/test/fts3e.test b/test/fts3e.test new file mode 100644 index 0000000000..03caaf85f2 --- /dev/null +++ b/test/fts3e.test @@ -0,0 +1,125 @@ +# 2008 July 29 +# +# 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. +# +#************************************************************************* +# These tests exercise the various types of fts3 cursors. +# +# $Id: fts3e.test,v 1.1 2008/07/29 20:24:46 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 +} + +#************************************************************************* +# Test table scan (QUERY_GENERIC). This kind of query happens for +# queries with no WHERE clause, or for WHERE clauses which cannot be +# satisfied by an index. +db eval { + DROP TABLE IF EXISTS t1; + CREATE VIRTUAL TABLE t1 USING fts3(c); + INSERT INTO t1 (docid, c) VALUES (1, 'This is a test'); + INSERT INTO t1 (docid, c) VALUES (2, 'That was a test'); + INSERT INTO t1 (docid, c) VALUES (3, 'This is a test'); +} + +do_test fts3e-1.1 { + execsql { + SELECT docid FROM t1 ORDER BY docid; + } +} {1 2 3} + +do_test fts3e-1.2 { + execsql { + SELECT docid FROM t1 WHERE c LIKE '%test' ORDER BY docid; + } +} {1 2 3} + +do_test fts3e-1.3 { + execsql { + SELECT docid FROM t1 WHERE c LIKE 'That%' ORDER BY docid; + } +} {2} + +#************************************************************************* +# Test lookup by docid (QUERY_DOCID). This kind of query happens for +# queries which select by the docid/rowid implicit index. +db eval { + DROP TABLE IF EXISTS t1; + DROP TABLE IF EXISTS t2; + CREATE VIRTUAL TABLE t1 USING fts3(c); + CREATE TABLE t2(id INTEGER PRIMARY KEY AUTOINCREMENT, weight INTEGER UNIQUE); + INSERT INTO t2 VALUES (null, 10); + INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'This is a test'); + INSERT INTO t2 VALUES (null, 5); + INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'That was a test'); + INSERT INTO t2 VALUES (null, 20); + INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'This is a test'); +} + +# TODO(shess): This actually is doing QUERY_GENERIC? I'd have +# expected QUERY_DOCID in this case, as for a very large table the +# full scan is less efficient. +do_test fts3e-2.1 { + execsql { + SELECT docid FROM t1 WHERE docid in (1, 2, 10); + SELECT rowid FROM t1 WHERE rowid in (1, 2, 10); + } +} {1 2 1 2} + +do_test fts3e-2.2 { + execsql { + SELECT docid, weight FROM t1, t2 WHERE t2.id = t1.docid ORDER BY weight; + SELECT t1.rowid, weight FROM t1, t2 WHERE t2.id = t1.rowid ORDER BY weight; + } +} {2 5 1 10 3 20 2 5 1 10 3 20} + +do_test fts3e-2.3 { + execsql { + SELECT docid, weight FROM t1, t2 + WHERE t2.weight>5 AND t2.id = t1.docid ORDER BY weight; + SELECT t1.rowid, weight FROM t1, t2 + WHERE t2.weight>5 AND t2.id = t1.rowid ORDER BY weight; + } +} {1 10 3 20 1 10 3 20} + +#************************************************************************* +# Test lookup by MATCH (QUERY_FULLTEXT). This is the fulltext index. +db eval { + DROP TABLE IF EXISTS t1; + DROP TABLE IF EXISTS t2; + CREATE VIRTUAL TABLE t1 USING fts3(c); + CREATE TABLE t2(id INTEGER PRIMARY KEY AUTOINCREMENT, weight INTEGER UNIQUE); + INSERT INTO t2 VALUES (null, 10); + INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'This is a test'); + INSERT INTO t2 VALUES (null, 5); + INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'That was a test'); + INSERT INTO t2 VALUES (null, 20); + INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'This is a test'); +} + +do_test fts3e-3.1 { + execsql { + SELECT docid FROM t1 WHERE t1 MATCH 'this' ORDER BY docid; + } +} {1 3} + +do_test fts3e-3.2 { + execsql { + SELECT docid, weight FROM t1, t2 + WHERE t1 MATCH 'this' AND t1.docid = t2.id ORDER BY weight; + } +} {1 10 3 20} + +finish_test