Further modifications and test cases to improve test coverage of fts3.

FossilOrigin-Name: ea8a0d2ce0cb1ca3f4f18c72fb780d1c26792799acc87e6726f9eaccf2f178bf
This commit is contained in:
dan 2017-04-19 07:33:52 +00:00
parent 0027e98b85
commit a059e99ca8
5 changed files with 123 additions and 16 deletions

View File

@ -3960,7 +3960,7 @@ int sqlite3Fts3Init(sqlite3 *db){
#endif
/* Create the virtual table wrapper around the hash-table and overload
** the two scalar functions. If this is successful, register the
** the four scalar functions. If this is successful, register the
** module with sqlite.
*/
if( SQLITE_OK==rc
@ -4543,7 +4543,7 @@ static int fts3EvalIncrPhraseNext(
** one incremental token. In which case the bIncr flag is set. */
assert( p->bIncr==1 );
if( p->nToken==1 && p->bIncr ){
if( p->nToken==1 ){
rc = sqlite3Fts3MsrIncrNext(pTab, p->aToken[0].pSegcsr,
&pDL->iDocid, &pDL->pList, &pDL->nList
);
@ -4776,6 +4776,7 @@ static void fts3EvalTokenCosts(
** the number of overflow pages consumed by a record B bytes in size.
*/
static int fts3EvalAverageDocsize(Fts3Cursor *pCsr, int *pnPage){
int rc = SQLITE_OK;
if( pCsr->nRowAvg==0 ){
/* The average document size, which is required to calculate the cost
** of each doclist, has not yet been determined. Read the required
@ -4815,11 +4816,10 @@ static int fts3EvalAverageDocsize(Fts3Cursor *pCsr, int *pnPage){
pCsr->nRowAvg = (int)(((nByte / nDoc) + p->nPgsz) / p->nPgsz);
assert( pCsr->nRowAvg>0 );
rc = sqlite3_reset(pStmt);
if( rc!=SQLITE_OK ) return rc;
}
*pnPage = pCsr->nRowAvg;
return SQLITE_OK;
return rc;
}
/*
@ -5169,7 +5169,8 @@ static void fts3EvalNextRow(
pExpr->iDocid = pLeft->iDocid;
pExpr->bEof = (pLeft->bEof || pRight->bEof);
if( pExpr->eType==FTSQUERY_NEAR && pExpr->bEof ){
if( pRight->pPhrase && pRight->pPhrase->doclist.aAll ){
assert( pRight->eType==FTSQUERY_PHRASE );
if( pRight->pPhrase->doclist.aAll ){
Fts3Doclist *pDl = &pRight->pPhrase->doclist;
while( *pRc==SQLITE_OK && pRight->bEof==0 ){
memset(pDl->pList, 0, pDl->nList);
@ -5198,7 +5199,7 @@ static void fts3EvalNextRow(
if( pRight->bEof || (pLeft->bEof==0 && iCmp<0) ){
fts3EvalNextRow(pCsr, pLeft, pRc);
}else if( pLeft->bEof || (pRight->bEof==0 && iCmp>0) ){
}else if( pLeft->bEof || iCmp>0 ){
fts3EvalNextRow(pCsr, pRight, pRc);
}else{
fts3EvalNextRow(pCsr, pLeft, pRc);

View File

@ -1,5 +1,5 @@
C Use\ssqlite3_table_column_metadata()\sinstead\sof\sa\sSELECT\sstatement\sto\scheck\sfor\nthe\sexistence\sof\sa\s%_stat\stable\sin\sfts3.\sThis\sleads\sto\ssmaller\sand\seasier\sto\ntest\scode.
D 2017-04-18T13:50:00.349
C Further\smodifications\sand\stest\scases\sto\simprove\stest\scoverage\sof\sfts3.
D 2017-04-19T07:33:52.121
F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6
@ -70,7 +70,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
F ext/fts3/fts3.c 43dbd764899650e6ee32336fdca2646e2157df7eaf5767693338e30bbfdb0220
F ext/fts3/fts3.c aba99577b605d8d9df62daa4463f0f89dcbd2805ae2d7d361104f522648d74be
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
F ext/fts3/fts3Int.h eb2502000148e80913b965db3e59f29251266d0a
F ext/fts3/fts3_aux.c 9edc3655fcb287f0467d0a4b886a01c6185fe9f1
@ -791,12 +791,12 @@ F test/fts3expr3.test c4d4a7d6327418428c96e0a3a1137c251b8dfbf8
F test/fts3expr4.test c39a15d676b14fc439d9bf845aa7bddcf4a74dc3
F test/fts3expr5.test f9abfffbf5e53d48a33e12a1e8f8ba2c551c9b49
F test/fts3fault.test 268e9589f44f49d6694ef39a293f0e0f80c6230fb01cc6f34325412acceb99ae
F test/fts3fault2.test 0e38e9ccd5b13a9b9ac9b66dff24534f998279a0dd21a991115b0dafaaa88b46
F test/fts3fault2.test 536bbe01fe2946ec24b063a5eee813e8fd90354a6ca0b8f941d299c405edd17e
F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641
F test/fts3join.test 34750f3ce1e29b2749eaf0f1be2fa6301c5d50da
F test/fts3malloc.test b0e4c133b8d61d4f6d112d8110f8320e9e453ef6
F test/fts3matchinfo.test ce864e0bd92429df8008f31cf557269ba172482a
F test/fts3misc.test 744c53bde5969f4c22e9fb4c11cd3a2fc6c2edfb4c254919fd425663b1781137
F test/fts3misc.test 8a4996e62af47165822770ab6ce1550fa2eb46ac58122a7bc4667775b95cfc84
F test/fts3near.test 7e3354d46f155a822b59c0e957fd2a70c1d7e905
F test/fts3offsets.test b85fd382abdc78ebce721d8117bd552dfb75094c
F test/fts3prefix.test fa794eaab0bdae466494947b0b153d7844478ab2
@ -1575,8 +1575,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 41c27bc0ff1d3135cdb6273ede4595f5bb0c0e1e1d470ea1633cb525674cf431
Q +86e7aa7bf18345d7b441e5531fedb9d6cd1d73a886058c08b8ef4d9bcdce59d5
R 4fb545dcbfffcc885ec5f2ba82a6abb0
P dc2a48020a3c856a8b4cfa2309c290f0508b991e92cc0e4de680d19aae7872fc
Q +36bfef8778c9f493c711d317e6831b048a992a5181ac8ca93bc85ebcd27da3c5
R 02520d892c38a2ba5d5b628278b7ff8f
U dan
Z 7fd413bdcf275f7c0ed7ce06ea528b64
Z a14baf958f8e5420b98f8d2e39f6512b

View File

@ -1 +1 @@
dc2a48020a3c856a8b4cfa2309c290f0508b991e92cc0e4de680d19aae7872fc
ea8a0d2ce0cb1ca3f4f18c72fb780d1c26792799acc87e6726f9eaccf2f178bf

View File

@ -190,6 +190,60 @@ do_faultsim_test 7.1 -faults oom* -body {
faultsim_test_result {0 {1 2}}
}
#-------------------------------------------------------------------------
# Inject faults into a opening an existing fts3 table that has been
# upgraded to add an %_stat table.
#
reset_db
do_execsql_test 8.0 {
CREATE VIRTUAL TABLE t8 USING fts3;
INSERT INTO t8 VALUES('the quick brown fox');
INSERT INTO t8 VALUES('jumped over the');
INSERT INTO t8 VALUES('lazy dog');
INSERT INTO t8(t8) VALUES('automerge=8');
SELECT name FROM sqlite_master WHERE name LIKE 't8%';
} {
t8 t8_content t8_segments t8_segdir t8_stat
}
faultsim_save_and_close
do_faultsim_test 8.1 -faults oom* -prep {
faultsim_restore_and_reopen
} -body {
execsql { INSERT INTO t8 VALUES('one two three') }
} -test {
faultsim_test_result {0 {}}
}
do_faultsim_test 8.2 -faults oom* -prep {
faultsim_restore_and_reopen
} -body {
execsql { ALTER TABLE t8 RENAME TO t8ii }
} -test {
faultsim_test_result {0 {}}
}
#-------------------------------------------------------------------------
reset_db
set chunkconfig [fts3_configure_incr_load 1 1]
do_execsql_test 9.0 {
PRAGMA page_size = 512;
CREATE VIRTUAL TABLE t9 USING fts3;
WITH s(i) AS (
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50
)
INSERT INTO t9 SELECT 'one two three' FROM s;
}
do_faultsim_test 8.2 -faults io* -body {
execsql { SELECT count(*) FROM t9 WHERE t9 MATCH '"one two three"' }
} -test {
faultsim_test_result {0 50}
}
eval fts3_configure_incr_load $chunkconfig
finish_test

View File

@ -102,6 +102,7 @@ do_execsql_test 2.5 {
181 182 183 184 185 186 187 188 189 190 191 198 199
}
#-------------------------------------------------------------------------
# Range constraints on the docid using non-integer values.
#
do_execsql_test 2.6 {
@ -120,5 +121,56 @@ do_execsql_test 2.8 {
29 30 31 34 35 38 39 42 43 46 47 48
}
#-------------------------------------------------------------------------
# Phrase query tests.
#
do_execsql_test 3.1.1 {
CREATE VIRTUAL TABLE t3 USING fts3;
INSERT INTO t3 VALUES('a b c');
INSERT INTO t3 VALUES('d e f');
INSERT INTO t3 VALUES('a b d');
INSERT INTO t3 VALUES('1 2 3 4 5 6 7 8 9 10 11');
}
do_execsql_test 3.1.2 {
SELECT * FROM t3 WHERE t3 MATCH '"a b x y"' ORDER BY docid DESC
}
do_execsql_test 3.1.3 {
SELECT * FROM t3 WHERE t3 MATCH '"a b c" OR "a b x y"' ORDER BY docid DESC
} {{a b c}}
do_execsql_test 3.1.4 {
SELECT * FROM t3 WHERE t3 MATCH '"a* b* x* a*"'
}
do_execsql_test 3.1.5 {
SELECT rowid FROM t3 WHERE t3 MATCH '"2 3 4 5 6 7 8 9"'
} {4}
#-------------------------------------------------------------------------
#
reset_db
do_execsql_test 4.0 {
PRAGMA page_size = 512;
CREATE VIRTUAL TABLE t4 USING fts4;
WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<8000 )
INSERT INTO t4 SELECT 'a b c a b c a b c' FROM s;
}
do_execsql_test 4.1 {
SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"'
} {8000}
do_execsql_test 4.2 {
SELECT quote(value) from t4_stat where id=0
} {X'C03EC0B204C0A608'}
do_execsql_test 4.3 {
UPDATE t4_stat SET value = X'C03EC0B204C0A60800' WHERE id=0;
}
do_catchsql_test 4.4 {
SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"'
} {1 {database disk image is malformed}}
do_execsql_test 4.5 {
UPDATE t4_stat SET value = X'00C03EC0B204C0A608' WHERE id=0;
}
do_catchsql_test 4.6 {
SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"'
} {1 {database disk image is malformed}}
finish_test