Index: ext/fts5/fts5_index.c ================================================================== --- ext/fts5/fts5_index.c +++ ext/fts5/fts5_index.c @@ -270,33 +270,15 @@ ) #define FTS5_SEGMENT_ROWID(segid, height, pgno) fts5_dri(segid, 0, height, pgno) #define FTS5_DLIDX_ROWID(segid, height, pgno) fts5_dri(segid, 1, height, pgno) -#if 0 -/* -** The height of segment b-trees is actually limited to one less than -** (1<pReader = 0; sqlite3_blob_close(pReader); } } -/* -** Check if row iRowid exists in the %_data table, and that it contains -** a blob value. If so, return SQLITE_ERROR (yes - SQLITE_ERROR, not -** SQLITE_OK). If not, return SQLITE_CORRUPT_VTAB. -** -** If an error occurs (e.g. OOM or IOERR), return the relevant error code. -** -** This function does not need to be efficient. It is part of vary rarely -** invoked error handling code only. -*/ -#if 0 -static int fts5CheckMissingRowid(Fts5Index *p, i64 iRowid){ - const char *zFmt = "SELECT typeof(block)=='blob' FROM '%q'.%Q WHERE id=%lld"; - int bOk = 0; - int rc; - char *zSql; - - zSql = sqlite3_mprintf(zFmt, p->pConfig->zDb, p->zDataTbl, iRowid); - if( zSql==0 ){ - rc = SQLITE_NOMEM; - }else{ - sqlite3_stmt *pStmt; - rc = sqlite3_prepare_v2(p->pConfig->db, zSql, -1, &pStmt, 0); - if( rc==SQLITE_OK ){ - if( SQLITE_ROW==sqlite3_step(pStmt) ){ - bOk = sqlite3_column_int(pStmt, 0); - } - rc = sqlite3_finalize(pStmt); - } - sqlite3_free(zSql); - } - - if( rc==SQLITE_OK ){ - rc = bOk ? SQLITE_ERROR : FTS5_CORRUPT; - } - - return rc; -} -#endif - static Fts5Data *fts5DataReadOrBuffer( Fts5Index *p, Fts5Buffer *pBuf, i64 iRowid ){ @@ -976,24 +918,10 @@ sqlite3_bind_int64(p->pDeleter, 2, iLast); sqlite3_step(p->pDeleter); p->rc = sqlite3_reset(p->pDeleter); } -/* -** Close the sqlite3_blob handle used to read records from the %_data table. -** And discard any cached reads. This function is called at the end of -** a read transaction or when any sub-transaction is rolled back. -*/ -#if 0 -static void fts5DataReset(Fts5Index *p){ - if( p->pReader ){ - sqlite3_blob_close(p->pReader); - p->pReader = 0; - } -} -#endif - /* ** Remove all records associated with segment iSegid. */ static void fts5DataRemoveSegment(Fts5Index *p, int iSegid){ i64 iFirst = FTS5_SEGMENT_ROWID(iSegid, 0, 0); @@ -3307,26 +3235,10 @@ fts5WriteFlushLeaf(p, pWriter); } } } -#if 0 -static void fts5WriteAppendPoslistInt( - Fts5Index *p, - Fts5SegWriter *pWriter, - int iVal -){ - if( p->rc==SQLITE_OK ){ - Fts5PageWriter *pPage = &pWriter->aWriter[0]; - fts5BufferAppendVarint(&p->rc, &pPage->buf, iVal); - if( pPage->buf.n>=p->pConfig->pgsz ){ - fts5WriteFlushLeaf(p, pWriter); - } - } -} -#endif - static void fts5WriteAppendPoslistData( Fts5Index *p, Fts5SegWriter *pWriter, const u8 *aData, int nData @@ -3572,15 +3484,10 @@ /* Read input from all segments in the input level */ nInput = pLvl->nSeg; } bOldest = (pLvlOut->nSeg==1 && pStruct->nLevel==iLvl+2); -#if 0 -fprintf(stdout, "merging %d segments from level %d!", nInput, iLvl); -fflush(stdout); -#endif - assert( iLvl>=0 ); for(fts5MultiIterNew(p, pStruct, 0, 0, 0, 0, iLvl, nInput, &pIter); fts5MultiIterEof(p, pIter)==0; fts5MultiIterNext(p, pIter, 0, 0) ){ Index: ext/fts5/test/fts5aux.test ================================================================== --- ext/fts5/test/fts5aux.test +++ ext/fts5/test/fts5aux.test @@ -217,8 +217,28 @@ my_phrasesize(t1, 0), my_phrasesize(t1, 1), my_phrasesize(t1, 2) FROM t1 WHERE t1 MATCH 'a OR b+c' } {0 1 2 0} + +#------------------------------------------------------------------------- +# +do_execsql_test 8.0 { + CREATE VIRTUAL TABLE x1 USING fts5(a); +} + +foreach {tn lRow res} { + 4 {"a a a" "b" "a d"} {"[a] [a] [a]" "[a] d"} + 1 {"b d" "a b"} {"[b] [d]" "[a] b"} + 2 {"d b" "a d"} {"[d] [b]" "[a] d"} + 3 {"a a d"} {"[a] [a] d"} +} { + execsql { DELETE FROM x1 } + foreach row $lRow { execsql { INSERT INTO x1 VALUES($row) } } + breakpoint + do_execsql_test 8.$tn { + SELECT highlight(x1, 0, '[', ']') FROM x1 WHERE x1 MATCH 'a OR (b AND d)'; + } $res +} finish_test Index: ext/fts5/test/fts5fault5.test ================================================================== --- ext/fts5/test/fts5fault5.test +++ ext/fts5/test/fts5fault5.test @@ -74,17 +74,17 @@ CREATE VIRTUAL TABLE tv USING fts5vocab(tt, 'row'); INSERT INTO tt(tt, rank) VALUES('pgsz', 32); BEGIN; } for {set i 0} {$i < 20} {incr i} { - set str [string repeat "$i " 20] + set str [string repeat "$i " 50] execsql { INSERT INTO tt VALUES($str) } } execsql COMMIT } {} -do_faultsim_test 2.1 -faults oom-t* -body { +do_faultsim_test 3.1 -faults oom-t* -body { db eval { SELECT term FROM tv; } } -test { faultsim_test_result {0 {0 1 10 11 12 13 14 15 16 17 18 19 2 3 4 5 6 7 8 9}}