Add tests to check that modifying the schema of an FTS content table does not cause a crash in the FTS module. Also disable the deferred token optimization for content=xxx FTS tables.

FossilOrigin-Name: be86c7061b68f403730bf63ea1f7dc0d9ceb0a3b
This commit is contained in:
dan 2011-10-04 16:37:35 +00:00
parent d8e454e19a
commit cc5b81464a
6 changed files with 107 additions and 15 deletions

View File

@ -4048,6 +4048,15 @@ static int fts3EvalSelectDeferred(
int nMinEst = 0; /* The minimum count for any phrase so far. */
int nLoad4 = 1; /* (Phrases that will be loaded)^4. */
/* Tokens are never deferred for FTS tables created using the content=xxx
** option. The reason being that it is not guaranteed that the content
** table actually contains the same data as the index. To prevent this from
** causing any problems, the deferred token optimization is completely
** disabled for content=xxx tables. */
if( pTab->zContentTbl ){
return SQLITE_OK;
}
/* Count the tokens in this AND/NEAR cluster. If none of the doclists
** associated with the tokens spill onto overflow pages, or if there is
** only 1 token, exit early. No tokens to defer in this case. */

View File

@ -225,7 +225,7 @@ struct Fts3Table {
int nPendingData; /* Current bytes of pending data */
sqlite_int64 iPrevDocid; /* Docid of most recently inserted document */
#if defined(SQLITE_DEBUG)
#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
/* State variables used for validating that the transaction control
** methods of the virtual table are called at appropriate times. These
** values do not contribution to the FTS computation; they are used for
@ -246,7 +246,6 @@ struct Fts3Cursor {
i16 eSearch; /* Search strategy (see below) */
u8 isEof; /* True if at End Of Results */
u8 isRequireSeek; /* True if must seek pStmt to %_content row */
u8 isNullRow; /* True for a row of NULLs */
sqlite3_stmt *pStmt; /* Prepared statement in use by the cursor */
Fts3Expr *pExpr; /* Parsed MATCH query string */
int nPhrase; /* Number of matchable phrases in query */

View File

@ -1,5 +1,5 @@
C Add\sexperimental\s'content'\soption\sto\sFTS4.
D 2011-10-04T11:22:59.677
C Add\stests\sto\scheck\sthat\smodifying\sthe\sschema\sof\san\sFTS\scontent\stable\sdoes\snot\scause\sa\scrash\sin\sthe\sFTS\smodule.\sAlso\sdisable\sthe\sdeferred\stoken\soptimization\sfor\scontent=xxx\sFTS\stables.
D 2011-10-04T16:37:35.422
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -62,9 +62,9 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
F ext/fts3/fts3.c 626fcf477e531b470f06aae3d427abcda2d5d31c
F ext/fts3/fts3.c df149056426597b32b2b8488eefbc755258f55d7
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
F ext/fts3/fts3Int.h a335d671d42ca07528a93c5b830e48e0205b26bc
F ext/fts3/fts3Int.h 06f442ce096e6254432a6b16a56b6fe7b24bd372
F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691
F ext/fts3/fts3_expr.c 23791de01b3a5d313d76e02befd2601d4096bc2b
F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914
@ -486,7 +486,7 @@ F test/fts3shared.test 8bb266521d7c5495c0ae522bb4d376ad5387d4a2
F test/fts3snippet.test 8e956051221a34c7daeb504f023cb54d5fa5a8b2
F test/fts3sort.test 9a5176c9317bb545ec5f144d62e6fedb4da6c66e
F test/fts4aa.test 6e7f90420b837b2c685f3bcbe84c868492d40a68
F test/fts4content.test fbafb7160eef1560b6a254b1ad5631acccd388a1
F test/fts4content.test 5c226c7c666e250c175bcbdfbdd4be3f275c73ba
F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca
F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a
@ -621,7 +621,7 @@ F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0
F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16
F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025
F test/permutations.test 7b1c4cb40af3712e42364c82390ace0df207b5e0
F test/permutations.test d850b5000a13baf042d5a20eb747079477dad45e
F test/pragma.test c8108e01da04f16e67e5754e610bc62c1b993f6c
F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947
F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea
@ -966,10 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5
F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2
P eb5da5e1dbe9c198095036827318fb381441cbd0
R 7991a3071fb34636c7b5ed4b010ad95a
T *branch * fts4-content
T *sym-fts4-content *
T -sym-trunk *
P 1d27ea741f61c624e18bdc6a3b1c2d8574a64ddc
R da82d432e1ef8526b881f10f91640d66
U dan
Z 48ff718a3615a321d5bc0764cb014ed4
Z d642325dd5adee7274f24ac6f8449504

View File

@ -1 +1 @@
1d27ea741f61c624e18bdc6a3b1c2d8574a64ddc
be86c7061b68f403730bf63ea1f7dc0d9ceb0a3b

View File

@ -22,6 +22,24 @@ ifcapable !fts3 {
return
}
#-------------------------------------------------------------------------
# Test organization:
#
# 1.* - Warm-body tests.
#
# 2.* - Querying a content=xxx FTS table.
#
# 3.* - Writing to a content=xxx FTS table.
#
# 4.* - The "INSERT INTO fts(fts) VALUES('rebuild')" command.
#
# 5.* - Check that CREATE TABLE, DROP TABLE and ALTER TABLE correctly
# ignore any %_content table when used with the content=xxx option.
#
# 6.* - Test the effects of messing with the schema of table xxx after
# creating a content=xxx FTS index.
#
do_execsql_test 1.1 {
CREATE TABLE t1(a, b, c);
INSERT INTO t1 VALUES('w x', 'x y', 'y z');
@ -363,4 +381,71 @@ do_execsql_test 5.1.7 {
t5 t5_content
}
#-------------------------------------------------------------------------
# Test cases 6.* test
#
do_catchsql_test 6.1.1 {
CREATE VIRTUAL TABLE ft7 USING fts4(content=t7);
} {1 {vtable constructor failed: ft7}}
do_execsql_test 6.2.1 {
CREATE TABLE t7(one, two);
CREATE VIRTUAL TABLE ft7 USING fts4(content=t7);
INSERT INTO t7 VALUES('A B', 'B A');
INSERT INTO t7 VALUES('C D', 'A A');
SELECT * FROM ft7;
} {
{A B} {B A} {C D} {A A}
}
do_catchsql_test 6.2.2 {
DROP TABLE t7;
SELECT * FROM ft7;
} {1 {SQL logic error or missing database}}
db close
sqlite3 db test.db
do_execsql_test 6.2.3 {
SELECT name FROM sqlite_master WHERE name LIKE '%t7%'
} {
ft7 ft7_segments ft7_segdir sqlite_autoindex_ft7_segdir_1
ft7_docsize ft7_stat
}
do_catchsql_test 6.2.4 {
SELECT * FROM ft7;
} {1 {vtable constructor failed: ft7}}
do_execsql_test 6.2.5 {
CREATE TABLE t7(x, y);
INSERT INTO t7 VALUES('A B', 'B A');
INSERT INTO t7 VALUES('C D', 'A A');
SELECT * FROM ft7;
} {
{A B} {B A} {C D} {A A}
}
do_execsql_test 6.2.6 {
INSERT INTO ft7(ft7) VALUES('rebuild');
SELECT rowid FROM ft7 WHERE ft7 MATCH '"A A"';
} {2}
do_execsql_test 6.2.7 {
DROP TABLE t7;
CREATE TABLE t7(x);
}
do_catchsql_test 6.2.8 {
SELECT rowid FROM ft7 WHERE ft7 MATCH '"A A"';
} {1 {SQL logic error or missing database}}
do_catchsql_test 6.2.9 {
SELECT rowid FROM ft7 WHERE ft7 MATCH '"A A"';
} {1 {SQL logic error or missing database}}
db close
sqlite3 db test.db
do_catchsql_test 6.2.10 {
SELECT rowid FROM ft7 WHERE ft7 MATCH '"A A"';
} {0 2}
do_catchsql_test 6.2.11 {
SELECT rowid, * FROM ft7 WHERE ft7 MATCH '"A A"';
} {0 {2 {}}}
finish_test

View File

@ -183,6 +183,8 @@ test_suite "fts3" -prefix "" -description {
fts3fault.test fts3malloc.test fts3matchinfo.test
fts3aux1.test fts3comp1.test fts3auto.test
fts4aa.test fts4content.test
fts3conf.test fts3prefix.test fts3fault2.test fts3corrupt.test
fts3corrupt2.test
}