diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index cabae111d2..780e8e268b 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -1056,10 +1056,11 @@ static Fts5Structure *fts5StructureRead(Fts5Index *p, int iIdx){ */ static int fts5StructureCountSegments(Fts5Structure *pStruct){ int nSegment = 0; /* Total number of segments */ - int iLvl; /* Used to iterate through levels */ - - for(iLvl=0; iLvlnLevel; iLvl++){ - nSegment += pStruct->aLevel[iLvl].nSeg; + if( pStruct ){ + int iLvl; /* Used to iterate through levels */ + for(iLvl=0; iLvlnLevel; iLvl++){ + nSegment += pStruct->aLevel[iLvl].nSeg; + } } return nSegment; @@ -3882,7 +3883,6 @@ static void fts5SetupPrefixIter( int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){ Fts5Config *pConfig = p->pConfig; int iIdx; /* Used to iterate through indexes */ - int rc; /* Return code */ u64 cksum2 = 0; /* Checksum based on contents of indexes */ /* Check that the checksum of the index matches the argument checksum */ @@ -3915,11 +3915,10 @@ int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){ fts5MultiIterFree(p, pIter); fts5StructureRelease(pStruct); } - rc = p->rc; - if( rc==SQLITE_OK && cksum!=cksum2 ) rc = FTS5_CORRUPT; + if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT; /* Check that the internal nodes of each segment match the leaves */ - for(iIdx=0; rc==SQLITE_OK && iIdx<=pConfig->nPrefix; iIdx++){ + for(iIdx=0; p->rc==SQLITE_OK && iIdx<=pConfig->nPrefix; iIdx++){ Fts5Structure *pStruct = fts5StructureRead(p, iIdx); if( pStruct ){ int iLvl, iSeg; @@ -3931,10 +3930,9 @@ int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){ } } fts5StructureRelease(pStruct); - rc = p->rc; } - return rc; + return fts5IndexReturn(p); } diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index b82db3e4a4..8e31721977 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -706,10 +706,12 @@ static int fts5StorageCount(Fts5Storage *p, const char *zSuffix, i64 *pnRow){ }else{ sqlite3_stmt *pCnt = 0; rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pCnt, 0); - if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pCnt) ){ - *pnRow = sqlite3_column_int64(pCnt, 0); + if( rc==SQLITE_OK ){ + if( SQLITE_ROW==sqlite3_step(pCnt) ){ + *pnRow = sqlite3_column_int64(pCnt, 0); + } + rc = sqlite3_finalize(pCnt); } - rc = sqlite3_finalize(pCnt); } sqlite3_free(zSql); @@ -968,7 +970,7 @@ int sqlite3Fts5StorageConfigValue( sqlite3_stmt *pReplace = 0; int rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_CONFIG, &pReplace, 0); if( rc==SQLITE_OK ){ - sqlite3_bind_text(pReplace, 1, z, -1, SQLITE_TRANSIENT); + sqlite3_bind_text(pReplace, 1, z, -1, SQLITE_STATIC); sqlite3_bind_value(pReplace, 2, pVal); sqlite3_step(pReplace); rc = sqlite3_reset(pReplace); diff --git a/ext/fts5/test/fts5aa.test b/ext/fts5/test/fts5aa.test index 2360122dd8..450539e889 100644 --- a/ext/fts5/test/fts5aa.test +++ b/ext/fts5/test/fts5aa.test @@ -369,6 +369,16 @@ do_test 14.3 { set nRow } {200} +do_execsql_test 15.0 { + INSERT INTO t1(t1) VALUES('integrity-check'); +} +do_execsql_test 15.1 { + UPDATE t1_content SET c1 = 'xyz xyz xyz xyz xyz abc' WHERE rowid = 1; +} +do_catchsql_test 15.2 { + INSERT INTO t1(t1) VALUES('integrity-check'); +} {1 {database disk image is malformed}} + finish_test diff --git a/ext/fts5/test/fts5ah.test b/ext/fts5/test/fts5ah.test index 37c014fcf1..69cdb38299 100644 --- a/ext/fts5/test/fts5ah.test +++ b/ext/fts5/test/fts5ah.test @@ -28,18 +28,26 @@ ifcapable !fts5 { do_test 1.0 { execsql { CREATE VIRTUAL TABLE t1 USING fts5(a) } execsql { INSERT INTO t1(t1, rank) VALUES('pgsz', 128) } + set v {w w w w w w w w w w w w w w w w w w w w} + execsql { INSERT INTO t1(rowid, a) VALUES(0, $v) } for {set i 1} {$i <= 10000} {incr i} { set v {x x x x x x x x x x x x x x x x x x x x} if {($i % 2139)==0} {lset v 3 Y ; lappend Y $i} if {($i % 1577)==0} {lset v 5 W ; lappend W $i} execsql { INSERT INTO t1 VALUES($v) } } + set v {w w w w w w w w w w w w w w w w w w w w} + execsql { INSERT INTO t1 VALUES($v) } } {} -do_execsql_test 1.1 { +do_execsql_test 1.1.1 { SELECT rowid FROM t1 WHERE t1 MATCH 'x AND w' } [lsort -integer -decr $W] +do_execsql_test 1.1.2 { + SELECT rowid FROM t1 WHERE t1 MATCH 'x* AND w*' +} [lsort -integer -decr $W] + do_execsql_test 1.2 { SELECT rowid FROM t1 WHERE t1 MATCH 'y AND x' } [lsort -integer -decr $Y] diff --git a/ext/fts5/test/fts5fault1.test b/ext/fts5/test/fts5fault1.test index 310f5caf9f..4392f13c97 100644 --- a/ext/fts5/test/fts5fault1.test +++ b/ext/fts5/test/fts5fault1.test @@ -31,7 +31,7 @@ ifcapable !fts5 { # # -if 0 { +if 1 { faultsim_save_and_close do_faultsim_test 1 -prep { @@ -108,8 +108,6 @@ foreach {tn expr res} { } -} - #------------------------------------------------------------------------- # The following tests use a larger database populated with random data. # @@ -212,7 +210,7 @@ do_faultsim_test 5.5.4 -faults oom* -body { faultsim_test_result [list 0 1] } -finish_test +} #------------------------------------------------------------------------- # @@ -254,6 +252,31 @@ do_faultsim_test 6.1 -faults oom* -prep { } } +do_faultsim_test 6.2 -faults oom* -prep { + faultsim_restore_and_reopen +} -body { + execsql { INSERT INTO x1(x1, rank) VALUES('pgsz', 32) } +} -test { + faultsim_test_result [list 0 {}] +} + +do_faultsim_test 6.3 -faults oom-* -prep { + faultsim_restore_and_reopen +} -body { + execsql { INSERT INTO x1(x1) VALUES('integrity-check') } +} -test { + faultsim_test_result [list 0 {}] +} + +do_faultsim_test 6.4 -faults oom-* -prep { + faultsim_restore_and_reopen +} -body { + execsql { INSERT INTO x1(x1) VALUES('optimize') } +} -test { + faultsim_test_result [list 0 {}] +} + + #------------------------------------------------------------------------- do_faultsim_test 7.0 -faults oom* -prep { catch { db close } diff --git a/ext/fts5/test/fts5rowid.test b/ext/fts5/test/fts5rowid.test index e828e521ac..c33c9adea3 100644 --- a/ext/fts5/test/fts5rowid.test +++ b/ext/fts5/test/fts5rowid.test @@ -151,5 +151,33 @@ do_execsql_test 4.2 { SELECT count(fts5_decode(rowid, block)) FROM x3_data; } $res +#------------------------------------------------------------------------- +# Position lists with large values. +# +set strlist [list \ + "[string repeat {w } 400]a" \ + "[string repeat {x } 400]a" \ + "[string repeat {y } 400]a" \ + "[string repeat {z } 400]a" \ +] +do_test 5.0 { + execsql { + BEGIN; + CREATE VIRTUAL TABLE x4 USING fts5(a); + INSERT INTO x4(x4, rank) VALUES('pgsz', 32); + } + foreach str $strlist { execsql { INSERT INTO x4 VALUES($str) } } + execsql COMMIT +} {} + +do_execsql_test 5.1 { + SELECT rowid FROM x4 WHERE x4 MATCH 'a' +} {4 3 2 1} + +set res [db one {SELECT count(*) FROM x4_data}] +do_execsql_test 5.2 { + SELECT count(fts5_decode(rowid, block)) FROM x4_data; +} $res + finish_test diff --git a/manifest b/manifest index 4052b8bf9d..7f398a24bf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sfts5\sissue\swith\sloading\sdoclist-indexes\sfor\sa\sterm\sthat\sis\sthe\slast\sthing\son\sits\sleaf\spage. -D 2015-01-21T18:23:25.625 +C Further\stests\sand\sfixes\sfor\sfts5. +D 2015-01-21T20:30:14.830 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5407a688f4d77a05c18a8142be8ae5a2829dd610 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -112,22 +112,22 @@ F ext/fts5/fts5_buffer.c 32dd3c950392346ca69a0f1803501766c5c954f9 F ext/fts5/fts5_config.c 33534ca25198cc62c54ff7d285d455c57ad19399 F ext/fts5/fts5_expr.c 8a0e643768666dc2bffe74104141274809699808 F ext/fts5/fts5_hash.c 63fa8379c5f2ac107d47c2b7d9ac04c95ef8a279 -F ext/fts5/fts5_index.c 7decfde6535f73c50acb009e41946ade38e9c1b7 -F ext/fts5/fts5_storage.c 8bc9e5b6654e1545e9513def277ef3f025921664 +F ext/fts5/fts5_index.c baf26bfee5bd776194c0e508e3c101964ae851c6 +F ext/fts5/fts5_storage.c d56722960982d0c48ba1b88d9001fefed8cff1a4 F ext/fts5/fts5_tcl.c 1293fac2bb26903fd3d5cdee59c5885ba7e620d5 F ext/fts5/fts5_tokenize.c 7c61d5c35c3449597bdeaa54dd48afe26852c7b0 F ext/fts5/fts5_unicode2.c 9c7dd640d1f014bf5c3ee029759adfbb4d7e95a9 F ext/fts5/fts5parse.y 777da8e5819f75c217982c79c29d014c293acac9 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl 08e939096a07eb77a7a986613e960f31d3cab2cc -F ext/fts5/test/fts5aa.test 770dbb37108a8d3531ec1240b71a404121adb554 +F ext/fts5/test/fts5aa.test 8ddbbcbedab67101dc9a86fd5c39d78b0e06515f F ext/fts5/test/fts5ab.test 91a3faac09ad9fab5f71494db6e4071963281536 F ext/fts5/test/fts5ac.test 48181b7c873da0e3b4a3316760fcb90d88e7fbd8 F ext/fts5/test/fts5ad.test 3b01eec8516d5631909716514e2e585a45ef0eb1 F ext/fts5/test/fts5ae.test 014d5be2f5f70407fb032d4f27704116254797c3 F ext/fts5/test/fts5af.test c2501ec2b61d6b179c305f5d2b8782ab3d4f832a F ext/fts5/test/fts5ag.test ec3e119b728196620a31507ef503c455a7a73505 -F ext/fts5/test/fts5ah.test 749855d1f457ecbf8e54b25a92e55a84cc689151 +F ext/fts5/test/fts5ah.test 17ba8e197a781ca10548b7260e39ed8269d24b93 F ext/fts5/test/fts5ai.test f20e53bbf0c55bc596f1fd47f2740dae028b8f37 F ext/fts5/test/fts5aj.test 05b569f5c16ea3098fb1984eec5cf50dbdaae5d8 F ext/fts5/test/fts5ak.test dc7bcd087dea0451ec40bba173962a0ba3a1d8ce @@ -136,13 +136,13 @@ F ext/fts5/test/fts5auxdata.test c69b86092bf1a157172de5f9169731af3403179b F ext/fts5/test/fts5content.test 4234e0b11e003fe1e80472aa637f70464396fdd0 F ext/fts5/test/fts5ea.test 04695560a444fcc00c3c4f27783bdcfbf71f030c F ext/fts5/test/fts5eb.test 728a1f23f263548f5c29b29dfb851b5f2dbe723e -F ext/fts5/test/fts5fault1.test 73b55c5b777f6dfb18022abd5cec2e569464e21c +F ext/fts5/test/fts5fault1.test 405886f4ecd255fa7a7077c021a65c9f8eaa4804 F ext/fts5/test/fts5near.test 3f9f64e16cac82725d03d4e04c661090f0b3b947 F ext/fts5/test/fts5optimize.test 0028c90a7817d3e576d1148fc8dff17d89054e54 F ext/fts5/test/fts5porter.test 50322599823cb8080a99f0ec0c39f7d0c12bcb5e F ext/fts5/test/fts5prefix.test 4610dfba4460d92f23a8014874a46493f1be77b5 F ext/fts5/test/fts5rebuild.test 2a5e98205393487b4a732c8290999af7c0b907b4 -F ext/fts5/test/fts5rowid.test bdff2ee094bf66bd163e0cdfb36a7fc7715a12d3 +F ext/fts5/test/fts5rowid.test db482328fe9bf78bb6a09f2dbf055e2caeaac00a F ext/fts5/test/fts5tokenizer.test b34ae592db66f6e89546d791ce1f905ba0b3395c F ext/fts5/test/fts5unicode.test 79b3e34eb29ce4929628aa514a40cb467fdabe4d F ext/fts5/test/fts5unicode2.test 64a5267fd6082fcb46439892ebd0cbaa5c38acee @@ -1282,7 +1282,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f8699a1a3b0f3bb612aff87a2729f912d709c534 -R 17960da1ca932a330a75bf04374dfc20 +P e0d614425f7f5ffe266fdc03642931b1ec19ad25 +R c0a23f610b9ed738a5e0737db6938cae U dan -Z c1930a6e112ceedd9aced2b05e742853 +Z 2e4179b4673c6b65260289e1eab737a6 diff --git a/manifest.uuid b/manifest.uuid index 721ef32452..0492abfca8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e0d614425f7f5ffe266fdc03642931b1ec19ad25 \ No newline at end of file +c020a291ed293a66d21c5885e50a7fee04aa6366 \ No newline at end of file