From b0df96346553ba7d5aa58f077c0e462e874ba1a2 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 16 Oct 2015 23:55:08 +0000 Subject: [PATCH 01/20] Fix a comment in expr.c and add a CORRUPT_DB to an assert() in btree.c. FossilOrigin-Name: 0df371d1a51c2028aefa4c704707773750317689 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/btree.c | 4 +++- src/expr.c | 4 ++++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index d339fd779d..8845573c60 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhancements\sto\sthe\sMSVC\smakefile. -D 2015-10-16T20:13:57.036 +C Fix\sa\scomment\sin\sexpr.c\sand\sadd\sa\sCORRUPT_DB\sto\san\sassert()\sin\sbtree.c. +D 2015-10-16T23:55:08.882 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -280,7 +280,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c c3a9c4209439b806c44cf30daf466955727bf46c F src/bitvec.c d1f21d7d91690747881f03940584f4cc548c9d3d F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 0b74bc28b2dc907cba03b5b4b3b81584273be699 +F src/btree.c ea8c62f65e57e49bd6b0988cd681aca7246b51af F src/btree.h 40189aefdc2b830d25c8b58fd7d56538481bfdd7 F src/btreeInt.h 8177c9ab90d772d6d2c6c517e05bed774b7c92c0 F src/build.c d6162335d690396dfc5c4bd59e8b2b0c14ba6285 @@ -290,7 +290,7 @@ F src/ctime.c 509ef9c64d1321f42448f111da86400b1799218a F src/date.c fb1c99172017dcc8e237339132c91a21a0788584 F src/dbstat.c e637e7a7ff40ef32132a418c6fdf1cfb63aa27c7 F src/delete.c 35c939eb8bacc9dd8a6715964e5f69feb8c20e44 -F src/expr.c e8765542b21bc7ff801ca82d5cf11f0b13a219af +F src/expr.c d9896fda47a8f67d0ed203e1fa981444424200c6 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 F src/func.c ecdd69ec6a1e406f04cc73324be2ebbf6354197f @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P eb2317429fc3fc81ccd92e6f84f873585829259d -R c8195ddfd54e61d102ea2ab84cfcbce4 -U mistachkin -Z 0b9815ef53884597c48f7e60955b08c9 +P 39e8a5d93fa370afb03223bf0c20ea0f3448b9fc +R 7f916530a28273810e372e1a6552332a +U drh +Z 831fa17e60715846d1a74c0ef53a246d diff --git a/manifest.uuid b/manifest.uuid index 2d3dfc6c5d..c38b191fbe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -39e8a5d93fa370afb03223bf0c20ea0f3448b9fc \ No newline at end of file +0df371d1a51c2028aefa4c704707773750317689 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 2c1a9983e5..b26a95c801 100644 --- a/src/btree.c +++ b/src/btree.c @@ -4499,7 +4499,9 @@ static int accessPayload( /* If required, populate the overflow page-list cache. */ if( (pCur->curFlags & BTCF_ValidOvfl)!=0 ){ - assert(!pCur->aOverflow[iIdx] || pCur->aOverflow[iIdx]==nextPage); + assert( pCur->aOverflow[iIdx]==0 + || pCur->aOverflow[iIdx]==nextPage + || CORRUPT_DB ); pCur->aOverflow[iIdx] = nextPage; } diff --git a/src/expr.c b/src/expr.c index a93bab991d..02cb4a5b47 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3356,6 +3356,10 @@ void sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){ ** ** The SQLITE_ECEL_FACTOR argument allows constant arguments to be ** factored out into initialization code. +** +** The SQLITE_ECEL_REF flag means that expressions in the list with +** ExprList.a[].u.x.iOrderByCol>0 have already been evaluated and stored +** in registers at srcReg, and so the value can be copied from there. */ int sqlite3ExprCodeExprList( Parse *pParse, /* Parsing context */ From 05903e6a87865386de086f3de2a6b150f4bbae4c Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 17 Oct 2015 19:49:01 +0000 Subject: [PATCH 02/20] Handle equality and range constraints on the "term" column of fts5vocab tables. Also have the same module report columns using names instead of indexes. FossilOrigin-Name: 6020d96ab47a0bebe41f691a3f44fd55d8b2d2b7 --- ext/fts5/fts5Int.h | 2 +- ext/fts5/fts5_index.c | 4 +- ext/fts5/fts5_main.c | 12 +-- ext/fts5/fts5_vocab.c | 179 ++++++++++++++++++++++++++++------- ext/fts5/test/fts5vocab.test | 143 ++++++++++++++++++++++++++-- manifest | 22 ++--- manifest.uuid | 2 +- 7 files changed, 299 insertions(+), 65 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 3671da1f12..bef185b07b 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -475,7 +475,7 @@ int sqlite3Fts5GetTokenizer( char **pzErr ); -Fts5Index *sqlite3Fts5IndexFromCsrid(Fts5Global*, i64, int*); +Fts5Index *sqlite3Fts5IndexFromCsrid(Fts5Global*, i64, Fts5Config **); /* ** End of interface to code in fts5.c. diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 5f3316f623..e006c9b36d 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4597,9 +4597,7 @@ int sqlite3Fts5IndexQuery( Fts5Buffer buf = {0, 0, 0}; /* If the QUERY_SCAN flag is set, all other flags must be clear. */ - assert( (flags & FTS5INDEX_QUERY_SCAN)==0 - || (flags & FTS5INDEX_QUERY_SCAN)==FTS5INDEX_QUERY_SCAN - ); + assert( (flags & FTS5INDEX_QUERY_SCAN)==0 || flags==FTS5INDEX_QUERY_SCAN ); if( sqlite3Fts5BufferGrow(&p->rc, &buf, nToken+1)==0 ){ memcpy(&buf.p[1], pToken, nToken); diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index a301a82f24..a133cf41b9 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -2021,20 +2021,20 @@ static void fts5ApiCallback( ** Given cursor id iId, return a pointer to the corresponding Fts5Index ** object. Or NULL If the cursor id does not exist. ** -** If successful, set *pnCol to the number of indexed columns in the -** table before returning. +** If successful, set *ppConfig to point to the associated config object +** before returning. */ Fts5Index *sqlite3Fts5IndexFromCsrid( - Fts5Global *pGlobal, - i64 iCsrId, - int *pnCol + Fts5Global *pGlobal, /* FTS5 global context for db handle */ + i64 iCsrId, /* Id of cursor to find */ + Fts5Config **ppConfig /* OUT: Configuration object */ ){ Fts5Cursor *pCsr; Fts5Table *pTab; pCsr = fts5CursorFromCsrid(pGlobal, iCsrId); pTab = (Fts5Table*)pCsr->base.pVtab; - *pnCol = pTab->pConfig->nCol; + *ppConfig = pTab->pConfig; return pTab->pIndex; } diff --git a/ext/fts5/fts5_vocab.c b/ext/fts5/fts5_vocab.c index adbe526b7b..f47a7d3ec5 100644 --- a/ext/fts5/fts5_vocab.c +++ b/ext/fts5/fts5_vocab.c @@ -55,16 +55,18 @@ struct Fts5VocabCursor { int bEof; /* True if this cursor is at EOF */ Fts5IndexIter *pIter; /* Term/rowid iterator object */ + int nLeTerm; /* Size of zLeTerm in bytes */ + char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */ + /* These are used by 'col' tables only */ - int nCol; + Fts5Config *pConfig; /* Fts5 table configuration */ int iCol; i64 *aCnt; i64 *aDoc; - /* Output values */ + /* Output values used by 'row' and 'col' tables */ i64 rowid; /* This table's current rowid value */ Fts5Buffer term; /* Current value of 'term' column */ - i64 aVal[3]; /* Up to three columns left of 'term' */ }; #define FTS5_VOCAB_COL 0 @@ -73,6 +75,14 @@ struct Fts5VocabCursor { #define FTS5_VOCAB_COL_SCHEMA "term, col, doc, cnt" #define FTS5_VOCAB_ROW_SCHEMA "term, doc, cnt" +/* +** Bits for the mask used as the idxNum value by xBestIndex/xFilter. +*/ +#define FTS5_VOCAB_TERM_EQ 0x01 +#define FTS5_VOCAB_TERM_GE 0x02 +#define FTS5_VOCAB_TERM_LE 0x04 + + /* ** Translate a string containing an fts5vocab table type to an ** FTS5_VOCAB_XXX constant. If successful, set *peType to the output @@ -230,6 +240,46 @@ static int fts5VocabBestIndexMethod( sqlite3_vtab *pVTab, sqlite3_index_info *pInfo ){ + int i; + int iTermEq = -1; + int iTermGe = -1; + int iTermLe = -1; + int idxNum = 0; + int nArg = 0; + + for(i=0; inConstraint; i++){ + struct sqlite3_index_constraint *p = &pInfo->aConstraint[i]; + if( p->usable==0 ) continue; + if( p->iColumn==0 ){ /* term column */ + if( p->op==SQLITE_INDEX_CONSTRAINT_EQ ) iTermEq = i; + if( p->op==SQLITE_INDEX_CONSTRAINT_LE ) iTermLe = i; + if( p->op==SQLITE_INDEX_CONSTRAINT_LT ) iTermLe = i; + if( p->op==SQLITE_INDEX_CONSTRAINT_GE ) iTermGe = i; + if( p->op==SQLITE_INDEX_CONSTRAINT_GT ) iTermGe = i; + } + } + + if( iTermEq>=0 ){ + idxNum |= FTS5_VOCAB_TERM_EQ; + pInfo->aConstraintUsage[iTermEq].argvIndex = ++nArg; + pInfo->aConstraintUsage[iTermEq].omit = 1; + pInfo->estimatedCost = 100; + }else{ + pInfo->estimatedCost = 1000000; + if( iTermGe>=0 ){ + idxNum |= FTS5_VOCAB_TERM_GE; + pInfo->aConstraintUsage[iTermGe].argvIndex = ++nArg; + pInfo->estimatedCost = pInfo->estimatedCost / 2; + } + if( iTermLe>=0 ){ + idxNum |= FTS5_VOCAB_TERM_LE; + pInfo->aConstraintUsage[iTermLe].argvIndex = ++nArg; + pInfo->estimatedCost = pInfo->estimatedCost / 2; + } + } + + pInfo->idxNum = idxNum; + return SQLITE_OK; } @@ -242,12 +292,11 @@ static int fts5VocabOpenMethod( ){ Fts5VocabTable *pTab = (Fts5VocabTable*)pVTab; Fts5Index *pIndex = 0; - int nCol = 0; + Fts5Config *pConfig = 0; Fts5VocabCursor *pCsr = 0; int rc = SQLITE_OK; sqlite3_stmt *pStmt = 0; char *zSql = 0; - int nByte; zSql = sqlite3Fts5Mprintf(&rc, "SELECT t.%Q FROM %Q.%Q AS t WHERE t.%Q MATCH '*id'", @@ -262,7 +311,7 @@ static int fts5VocabOpenMethod( if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){ i64 iId = sqlite3_column_int64(pStmt, 0); - pIndex = sqlite3Fts5IndexFromCsrid(pTab->pGlobal, iId, &nCol); + pIndex = sqlite3Fts5IndexFromCsrid(pTab->pGlobal, iId, &pConfig); } if( rc==SQLITE_OK && pIndex==0 ){ @@ -276,14 +325,17 @@ static int fts5VocabOpenMethod( } } - nByte = nCol * sizeof(i64) * 2 + sizeof(Fts5VocabCursor); - pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte); + if( rc==SQLITE_OK ){ + int nByte = pConfig->nCol * sizeof(i64) * 2 + sizeof(Fts5VocabCursor); + pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte); + } + if( pCsr ){ pCsr->pIndex = pIndex; pCsr->pStmt = pStmt; - pCsr->nCol = nCol; + pCsr->pConfig = pConfig; pCsr->aCnt = (i64*)&pCsr[1]; - pCsr->aDoc = &pCsr->aCnt[nCol]; + pCsr->aDoc = &pCsr->aCnt[pConfig->nCol]; }else{ sqlite3_finalize(pStmt); } @@ -296,6 +348,9 @@ static void fts5VocabResetCursor(Fts5VocabCursor *pCsr){ pCsr->rowid = 0; sqlite3Fts5IterClose(pCsr->pIter); pCsr->pIter = 0; + sqlite3_free(pCsr->zLeTerm); + pCsr->nLeTerm = -1; + pCsr->zLeTerm = 0; } /* @@ -319,16 +374,17 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor; Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab; int rc = SQLITE_OK; + int nCol = pCsr->pConfig->nCol; pCsr->rowid++; if( pTab->eType==FTS5_VOCAB_COL ){ - for(pCsr->iCol++; pCsr->iColnCol; pCsr->iCol++){ + for(pCsr->iCol++; pCsr->iColiCol++){ if( pCsr->aCnt[pCsr->iCol] ) break; } } - if( pTab->eType==FTS5_VOCAB_ROW || pCsr->iCol>=pCsr->nCol ){ + if( pTab->eType==FTS5_VOCAB_ROW || pCsr->iCol>=nCol ){ if( sqlite3Fts5IterEof(pCsr->pIter) ){ pCsr->bEof = 1; }else{ @@ -336,10 +392,18 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ int nTerm; zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm); + if( pCsr->nLeTerm>=0 ){ + int nCmp = MIN(nTerm, pCsr->nLeTerm); + int bCmp = memcmp(pCsr->zLeTerm, zTerm, nCmp); + if( bCmp<0 || (bCmp==0 && pCsr->nLeTermbEof = 1; + return SQLITE_OK; + } + } + sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm); - memset(pCsr->aVal, 0, sizeof(pCsr->aVal)); - memset(pCsr->aCnt, 0, pCsr->nCol * sizeof(i64)); - memset(pCsr->aDoc, 0, pCsr->nCol * sizeof(i64)); + memset(pCsr->aCnt, 0, nCol * sizeof(i64)); + memset(pCsr->aDoc, 0, nCol * sizeof(i64)); pCsr->iCol = 0; assert( pTab->eType==FTS5_VOCAB_COL || pTab->eType==FTS5_VOCAB_ROW ); @@ -353,9 +417,9 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ if( rc==SQLITE_OK ){ if( pTab->eType==FTS5_VOCAB_ROW ){ while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){ - pCsr->aVal[1]++; + pCsr->aCnt[0]++; } - pCsr->aVal[0]++; + pCsr->aDoc[0]++; }else{ int iCol = -1; while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){ @@ -369,9 +433,12 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ } rc = sqlite3Fts5IterNextScan(pCsr->pIter); } + if( rc==SQLITE_OK ){ zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm); - if( nTerm!=pCsr->term.n || memcmp(zTerm, pCsr->term.p, nTerm) ) break; + if( nTerm!=pCsr->term.n || memcmp(zTerm, pCsr->term.p, nTerm) ){ + break; + } if( sqlite3Fts5IterEof(pCsr->pIter) ) break; } } @@ -380,9 +447,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ if( pCsr->bEof==0 && pTab->eType==FTS5_VOCAB_COL ){ while( pCsr->aCnt[pCsr->iCol]==0 ) pCsr->iCol++; - pCsr->aVal[0] = pCsr->iCol; - pCsr->aVal[1] = pCsr->aDoc[pCsr->iCol]; - pCsr->aVal[2] = pCsr->aCnt[pCsr->iCol]; + assert( pCsr->iColpConfig->nCol ); } return rc; } @@ -399,10 +464,46 @@ static int fts5VocabFilterMethod( ){ Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor; int rc; - const int flags = FTS5INDEX_QUERY_SCAN; + + int iVal = 0; + int f = FTS5INDEX_QUERY_SCAN; + const char *zTerm = 0; + int nTerm = 0; + + sqlite3_value *pEq = 0; + sqlite3_value *pGe = 0; + sqlite3_value *pLe = 0; fts5VocabResetCursor(pCsr); - rc = sqlite3Fts5IndexQuery(pCsr->pIndex, 0, 0, flags, 0, &pCsr->pIter); + if( idxNum & FTS5_VOCAB_TERM_EQ ) pEq = apVal[iVal++]; + if( idxNum & FTS5_VOCAB_TERM_GE ) pGe = apVal[iVal++]; + if( idxNum & FTS5_VOCAB_TERM_LE ) pLe = apVal[iVal++]; + + if( pEq ){ + zTerm = sqlite3_value_text(pEq); + nTerm = sqlite3_value_bytes(pEq); + f = 0; + }else{ + if( pGe ){ + zTerm = sqlite3_value_text(pGe); + nTerm = sqlite3_value_bytes(pGe); + } + if( pLe ){ + const char *zCopy = sqlite3_value_text(pLe); + pCsr->nLeTerm = sqlite3_value_bytes(pLe); + pCsr->zLeTerm = sqlite3_malloc(pCsr->nLeTerm+1); + if( pCsr->zLeTerm==0 ){ + rc = SQLITE_NOMEM; + }else{ + memcpy(pCsr->zLeTerm, zCopy, pCsr->nLeTerm+1); + } + } + } + + + if( rc==SQLITE_OK ){ + rc = sqlite3Fts5IndexQuery(pCsr->pIndex, zTerm, nTerm, f, 0, &pCsr->pIter); + } if( rc==SQLITE_OK ){ rc = fts5VocabNextMethod(pCursor); } @@ -425,17 +526,29 @@ static int fts5VocabColumnMethod( int iCol /* Index of column to read value from */ ){ Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor; - switch( iCol ){ - case 0: /* term */ - sqlite3_result_text( - pCtx, (const char*)pCsr->term.p, pCsr->term.n, SQLITE_TRANSIENT - ); - break; - default: - assert( iCol<4 && iCol>0 ); - sqlite3_result_int64(pCtx, pCsr->aVal[iCol-1]); - break; + if( iCol==0 ){ + sqlite3_result_text( + pCtx, (const char*)pCsr->term.p, pCsr->term.n, SQLITE_TRANSIENT + ); + } + else if( ((Fts5VocabTable*)(pCursor->pVtab))->eType==FTS5_VOCAB_COL ){ + assert( iCol==1 || iCol==2 || iCol==3 ); + if( iCol==1 ){ + const char *z = pCsr->pConfig->azCol[pCsr->iCol]; + sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC); + }else if( iCol==2 ){ + sqlite3_result_int64(pCtx, pCsr->aDoc[pCsr->iCol]); + }else{ + sqlite3_result_int64(pCtx, pCsr->aCnt[pCsr->iCol]); + } + }else{ + assert( iCol==1 || iCol==2 ); + if( iCol==1 ){ + sqlite3_result_int64(pCtx, pCsr->aDoc[0]); + }else{ + sqlite3_result_int64(pCtx, pCsr->aCnt[0]); + } } return SQLITE_OK; } diff --git a/ext/fts5/test/fts5vocab.test b/ext/fts5/test/fts5vocab.test index c95f50b835..fd898d958e 100644 --- a/ext/fts5/test/fts5vocab.test +++ b/ext/fts5/test/fts5vocab.test @@ -56,7 +56,7 @@ do_execsql_test 1.4.1 { do_execsql_test 1.4.2 { SELECT * FROM v2; -} {x 0 2 4 y 0 1 1 z 0 1 1} +} {x one 2 4 y one 1 1 z one 1 1} do_execsql_test 1.5.1 { BEGIN; @@ -67,7 +67,7 @@ do_execsql_test 1.5.1 { do_execsql_test 1.5.2 { SELECT * FROM v2 WHERE term<'d'; COMMIT; -} {a 0 1 1 b 0 1 1 c 0 1 1} +} {a one 1 1 b one 1 1 c one 1 1} do_execsql_test 1.6 { DELETE FROM t1 WHERE one = 'a b c'; @@ -91,14 +91,14 @@ do_execsql_test 2.0 { } set res_col { - a 0 6 11 a 1 7 9 - b 0 6 7 b 1 7 7 - c 0 6 12 c 1 5 8 - d 0 4 6 d 1 9 13 - e 0 6 7 e 1 6 6 - f 0 9 10 f 1 7 10 - g 0 5 7 g 1 5 7 - x 0 1 1 y 1 1 1 + a a 6 11 a b 7 9 + b a 6 7 b b 7 7 + c a 6 12 c b 5 8 + d a 4 6 d b 9 13 + e a 6 7 e b 6 6 + f a 9 10 f b 7 10 + g a 5 7 g b 5 7 + x a 1 1 y b 1 1 } set res_row { a 10 20 b 9 14 c 9 20 d 9 19 @@ -213,5 +213,128 @@ do_catchsql_test 6.2 { SELECT * FROM vocab3; } {1 {no such fts5 table: main.lll}} +#------------------------------------------------------------------------- +# Test single term queries on fts5vocab tables (i.e. those with term=? +# constraints in the WHERE clause). +# +do_execsql_test 7.0 { + CREATE VIRTUAL TABLE tx USING fts5(one, two); + INSERT INTO tx VALUES('g a ggg g a b eee', 'cc d aa ff g ee'); + INSERT INTO tx VALUES('dd fff i a i jjj', 'f fff hh jj e f'); + INSERT INTO tx VALUES('ggg a f f fff dd aa', 'd ggg f f j gg ddd'); + INSERT INTO tx VALUES('e bb h jjj ii gg', 'e aa e f c fff'); + INSERT INTO tx VALUES('j ff aa a h', 'h a j bbb bb'); + INSERT INTO tx VALUES('cc i ff c d f', 'dd ii fff f c cc d'); + INSERT INTO tx VALUES('jjj g i bb cc eee', 'hhh iii aaa b bbb aaa'); + INSERT INTO tx VALUES('hhh hhh hhh bb fff f', 'fff gg aa ii h a'); + INSERT INTO tx VALUES('b c cc aaa iii ggg f', 'iii ff ee a ff c cc'); + INSERT INTO tx VALUES('hhh b hhh aaa j i i', 'dd ee ee aa bbb iii'); + INSERT INTO tx VALUES('hh dd h b g ff i', 'ccc bb cc ccc f a d'); + INSERT INTO tx VALUES('g d b ggg jj', 'fff jj ff jj g gg ee'); + INSERT INTO tx VALUES('g ee ggg ggg cc bb eee', 'aa j jjj bbb dd eee ff'); + INSERT INTO tx VALUES('c jjj hh ddd dd h', 'e aaa h jjj gg'); + + CREATE VIRTUAL TABLE txr USING fts5vocab(tx, row); + CREATE VIRTUAL TABLE txc USING fts5vocab(tx, col); +} + +proc cont {L elem} { + set n 0 + foreach e $L { if {$elem==$e} {incr n} } + set n +} +db func cont cont + +foreach {term} { + a aa aaa + b bb bbb + c cc ccc + d dd ddd + e ee eee + f ff fff + g gg ggg + h hh hhh + i ii iii + j jj jjj +} { + set resr [db eval { + SELECT $term, + sum(cont(one || ' ' || two, $term) > 0), + sum(cont(one || ' ' || two, $term)) + FROM tx + }] + if {[lindex $resr 1]==0} {set resr [list]} + + set r1 [db eval { + SELECT $term, 'one', sum(cont(one, $term)>0), sum(cont(one, $term)) FROM tx + }] + if {[lindex $r1 2]==0} {set r1 [list]} + + set r2 [db eval { + SELECT $term, 'two', sum(cont(two, $term)>0), sum(cont(two, $term)) FROM tx + }] + if {[lindex $r2 2]==0} {set r2 [list]} + + set resc [concat $r1 $r2] + do_execsql_test 7.$term.1 {SELECT * FROM txc WHERE term=$term} $resc + do_execsql_test 7.$term.2 {SELECT * FROM txr WHERE term=$term} $resr +} + +do_execsql_test 7.1 { + CREATE TABLE txr_c AS SELECT * FROM txr; + CREATE TABLE txc_c AS SELECT * FROM txc; +} + +# Test range queries on the fts5vocab tables created above. +# +foreach {tn a b} { + 1 a jjj + 2 bb j + 3 ccc ddd + 4 dd xyz + 5 xzy dd + 6 h hh +} { + do_execsql_test 7.2.$tn.1 { + SELECT * FROM txr WHERE term>=$a + } [db eval {SELECT * FROM txr_c WHERE term>=$a}] + do_execsql_test 7.2.$tn.2 { + SELECT * FROM txr WHERE term<=$b + } [db eval {SELECT * FROM txr_c WHERE term <=$b}] + do_execsql_test 7.2.$tn.3 { + SELECT * FROM txr WHERE term>=$a AND term<=$b + } [db eval {SELECT * FROM txr_c WHERE term>=$a AND term <=$b}] + + do_execsql_test 7.2.$tn.4 { + SELECT * FROM txc WHERE term>=$a + } [db eval {SELECT * FROM txc_c WHERE term>=$a}] + do_execsql_test 7.2.$tn.5 { + SELECT * FROM txc WHERE term<=$b + } [db eval {SELECT * FROM txc_c WHERE term <=$b}] + do_execsql_test 7.2.$tn.6 { + SELECT * FROM txc WHERE term>=$a AND term<=$b + } [db eval {SELECT * FROM txc_c WHERE term>=$a AND term <=$b}] + + do_execsql_test 7.2.$tn.7 { + SELECT * FROM txr WHERE term>$a + } [db eval {SELECT * FROM txr_c WHERE term>$a}] + do_execsql_test 7.2.$tn.8 { + SELECT * FROM txr WHERE term<$b + } [db eval {SELECT * FROM txr_c WHERE term<$b}] + do_execsql_test 7.2.$tn.9 { + SELECT * FROM txr WHERE term>$a AND term<$b + } [db eval {SELECT * FROM txr_c WHERE term>$a AND term <$b}] + + do_execsql_test 7.2.$tn.10 { + SELECT * FROM txc WHERE term>$a + } [db eval {SELECT * FROM txc_c WHERE term>$a}] + do_execsql_test 7.2.$tn.11 { + SELECT * FROM txc WHERE term<$b + } [db eval {SELECT * FROM txc_c WHERE term<$b}] + do_execsql_test 7.2.$tn.12 { + SELECT * FROM txc WHERE term>$a AND term<$b + } [db eval {SELECT * FROM txc_c WHERE term>$a AND term <$b}] +} + finish_test diff --git a/manifest b/manifest index 8845573c60..844d674b9e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scomment\sin\sexpr.c\sand\sadd\sa\sCORRUPT_DB\sto\san\sassert()\sin\sbtree.c. -D 2015-10-16T23:55:08.882 +C Handle\sequality\sand\srange\sconstraints\son\sthe\s"term"\scolumn\sof\sfts5vocab\stables.\sAlso\shave\sthe\ssame\smodule\sreport\scolumns\susing\snames\sinstead\sof\sindexes. +D 2015-10-17T19:49:01.860 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -103,21 +103,21 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 8b9a13b309b180e9fb88ea5666c0d8d73c6102d9 -F ext/fts5/fts5Int.h 38667e39859ff3f3bc91f47efe672023a145a118 +F ext/fts5/fts5Int.h 0332d12fdca0f4fe2231df71bd7544b3cef81122 F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 9a3aa73a4e7b26b1c805b9c92c1344ba3d19d2a8 F ext/fts5/fts5_config.c 88a77f5d5e4dfbb2355b8f6cc9969b7f02d94685 F ext/fts5/fts5_expr.c 28b15c9ae296204bc0a2e5cf7a667d840a9d2900 F ext/fts5/fts5_hash.c a9d4c1efebc2a91d26ad7ebdfcbf2678ceac405f -F ext/fts5/fts5_index.c c76d636d6cd22e3b82b1dbf3a3993447091c3bed -F ext/fts5/fts5_main.c d3fde32e1fdd7962dc7062400d1d8c7ec2297acf +F ext/fts5/fts5_index.c 632fdcb1971f6c9d7d6b2bd31f6c41e4189162bb +F ext/fts5/fts5_main.c 520a29136ba07448331f73bdc36d0ffa1e9dcfef F ext/fts5/fts5_storage.c 9b30115742b758706de70595a8d1d084e940c978 F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd F ext/fts5/fts5_test_mi.c e96be827aa8f571031e65e481251dc1981d608bf F ext/fts5/fts5_tokenize.c 12c5d925286491a71bb3dad7c8924ce9cfd18320 F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 -F ext/fts5/fts5_vocab.c 85ebf2e93089c9d3d136cc69163370592fc040f3 +F ext/fts5/fts5_vocab.c f7c03dabb858896d42165bc54e4aa4f82650ecea F ext/fts5/fts5parse.y e83dca6028e3309178d05b5bd920e372dc295d35 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl 51f7ef3af444b89c6f6ce3896a0ac349ff4e996d @@ -180,7 +180,7 @@ F ext/fts5/test/fts5unicode2.test c1dd890ba32b7609adba78e420faa847abe43b59 F ext/fts5/test/fts5unicode3.test 35c3d02aa7acf7d43d8de3bfe32c15ba96e8928e F ext/fts5/test/fts5unindexed.test e9539d5b78c677315e7ed8ea911d4fd25437c680 F ext/fts5/test/fts5version.test 978f59541d8cef7e8591f8be2115ec5ccb863e2e -F ext/fts5/test/fts5vocab.test cdf97b9678484e9bad5062edf9c9106e5c3b0c5c +F ext/fts5/test/fts5vocab.test 7dec771fd2388c11f7c336d6d155d31e12e4001a F ext/fts5/tool/fts5txt2db.tcl 3d19fb8ffb234031d33d7d2151acfbc55e9cfcc4 F ext/fts5/tool/loadfts5.tcl 58e90407cc5c2b1770460119488fd7c0090d4dd3 F ext/fts5/tool/mkfts5c.tcl 09ce6a7997440508360f5ba1651ab7e923a8bf31 @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 39e8a5d93fa370afb03223bf0c20ea0f3448b9fc -R 7f916530a28273810e372e1a6552332a -U drh -Z 831fa17e60715846d1a74c0ef53a246d +P 0df371d1a51c2028aefa4c704707773750317689 +R 97767b5f8bc213fefd21674fa8888cb4 +U dan +Z b5428af5c06a042c6ac8c829b1afb62f diff --git a/manifest.uuid b/manifest.uuid index c38b191fbe..6b22c8a106 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0df371d1a51c2028aefa4c704707773750317689 \ No newline at end of file +6020d96ab47a0bebe41f691a3f44fd55d8b2d2b7 \ No newline at end of file From 0206920e27d48c9b7cd22e2716f45fd9c26c5ad2 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 17 Oct 2015 20:34:49 +0000 Subject: [PATCH 03/20] Add tests to cover new branches added to the fts5 code by the previous commit. FossilOrigin-Name: cf618334a8a05a067e844236e4d461b2e5706da6 --- ext/fts5/fts5_vocab.c | 1 - ext/fts5/test/fts5fault5.test | 8 ++++++++ ext/fts5/test/fts5vocab.test | 9 +++++++++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_vocab.c b/ext/fts5/fts5_vocab.c index f47a7d3ec5..80e3455900 100644 --- a/ext/fts5/fts5_vocab.c +++ b/ext/fts5/fts5_vocab.c @@ -262,7 +262,6 @@ static int fts5VocabBestIndexMethod( if( iTermEq>=0 ){ idxNum |= FTS5_VOCAB_TERM_EQ; pInfo->aConstraintUsage[iTermEq].argvIndex = ++nArg; - pInfo->aConstraintUsage[iTermEq].omit = 1; pInfo->estimatedCost = 100; }else{ pInfo->estimatedCost = 1000000; diff --git a/ext/fts5/test/fts5fault5.test b/ext/fts5/test/fts5fault5.test index c14f394eb6..41de5208b2 100644 --- a/ext/fts5/test/fts5fault5.test +++ b/ext/fts5/test/fts5fault5.test @@ -90,6 +90,14 @@ do_faultsim_test 3.1 -faults oom-t* -body { faultsim_test_result {0 {0 1 10 11 12 13 14 15 16 17 18 19 2 3 4 5 6 7 8 9}} } +do_faultsim_test 3.2 -faults oom-t* -body { + db eval { + SELECT term FROM tv WHERE term BETWEEN '1' AND '2'; + } +} -test { + faultsim_test_result {0 {1 10 11 12 13 14 15 16 17 18 19 2}} +} + finish_test diff --git a/ext/fts5/test/fts5vocab.test b/ext/fts5/test/fts5vocab.test index fd898d958e..dc5099c6e3 100644 --- a/ext/fts5/test/fts5vocab.test +++ b/ext/fts5/test/fts5vocab.test @@ -336,5 +336,14 @@ foreach {tn a b} { } [db eval {SELECT * FROM txc_c WHERE term>$a AND term <$b}] } +do_execsql_test 7.3.1 { + SELECT count(*) FROM txr, txr_c WHERE txr.term = txr_c.term; +} {30} + +do_execsql_test 7.3.2 { + SELECT count(*) FROM txc, txc_c + WHERE txc.term = txc_c.term AND txc.col=txc_c.col; +} {57} + finish_test diff --git a/manifest b/manifest index 844d674b9e..955c828ace 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Handle\sequality\sand\srange\sconstraints\son\sthe\s"term"\scolumn\sof\sfts5vocab\stables.\sAlso\shave\sthe\ssame\smodule\sreport\scolumns\susing\snames\sinstead\sof\sindexes. -D 2015-10-17T19:49:01.860 +C Add\stests\sto\scover\snew\sbranches\sadded\sto\sthe\sfts5\scode\sby\sthe\sprevious\scommit. +D 2015-10-17T20:34:49.498 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -117,7 +117,7 @@ F ext/fts5/fts5_test_mi.c e96be827aa8f571031e65e481251dc1981d608bf F ext/fts5/fts5_tokenize.c 12c5d925286491a71bb3dad7c8924ce9cfd18320 F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 -F ext/fts5/fts5_vocab.c f7c03dabb858896d42165bc54e4aa4f82650ecea +F ext/fts5/fts5_vocab.c 4bf7e418bd3f857c7aea8221fc2c159283d30c6b F ext/fts5/fts5parse.y e83dca6028e3309178d05b5bd920e372dc295d35 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl 51f7ef3af444b89c6f6ce3896a0ac349ff4e996d @@ -152,7 +152,7 @@ F ext/fts5/test/fts5fault1.test 7a562367cb4a735b57b410dbdb62dcc8d971faec F ext/fts5/test/fts5fault2.test 28c36c843bb39ae855ba79827417ecc37f114341 F ext/fts5/test/fts5fault3.test d6e9577d4312e331a913c72931bf131704efc8f3 F ext/fts5/test/fts5fault4.test 762991d526ee67c2b374351a17248097ea38bee7 -F ext/fts5/test/fts5fault5.test 54da9fd4c3434a1d4f6abdcb6469299d91cf5875 +F ext/fts5/test/fts5fault5.test f2b8645053d48982e8979749e93994c43011c118 F ext/fts5/test/fts5fault6.test 9682664d679643ac6736e90c225526cc84073cda F ext/fts5/test/fts5fault7.test 01be274bfc8d9bf22451a3bf5892e9399d044f1b F ext/fts5/test/fts5full.test 6f6143af0c6700501d9fd597189dfab1555bb741 @@ -180,7 +180,7 @@ F ext/fts5/test/fts5unicode2.test c1dd890ba32b7609adba78e420faa847abe43b59 F ext/fts5/test/fts5unicode3.test 35c3d02aa7acf7d43d8de3bfe32c15ba96e8928e F ext/fts5/test/fts5unindexed.test e9539d5b78c677315e7ed8ea911d4fd25437c680 F ext/fts5/test/fts5version.test 978f59541d8cef7e8591f8be2115ec5ccb863e2e -F ext/fts5/test/fts5vocab.test 7dec771fd2388c11f7c336d6d155d31e12e4001a +F ext/fts5/test/fts5vocab.test c88a5554d0409494da95ba647bbdb4879b2624b0 F ext/fts5/tool/fts5txt2db.tcl 3d19fb8ffb234031d33d7d2151acfbc55e9cfcc4 F ext/fts5/tool/loadfts5.tcl 58e90407cc5c2b1770460119488fd7c0090d4dd3 F ext/fts5/tool/mkfts5c.tcl 09ce6a7997440508360f5ba1651ab7e923a8bf31 @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0df371d1a51c2028aefa4c704707773750317689 -R 97767b5f8bc213fefd21674fa8888cb4 +P 6020d96ab47a0bebe41f691a3f44fd55d8b2d2b7 +R 22a259a71e3233ba8022de14ef31c49b U dan -Z b5428af5c06a042c6ac8c829b1afb62f +Z d5f5675976d14f9fce086eaa482cce6e diff --git a/manifest.uuid b/manifest.uuid index 6b22c8a106..8e55d16504 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6020d96ab47a0bebe41f691a3f44fd55d8b2d2b7 \ No newline at end of file +cf618334a8a05a067e844236e4d461b2e5706da6 \ No newline at end of file From 3c060c2aef3b99abe24f409064321ef0b1452140 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 19 Oct 2015 15:59:08 +0000 Subject: [PATCH 04/20] Fix a problem in the fts5txt2db.tcl script causing it to fail when creating tables with more than 8 columns. FossilOrigin-Name: 68ee426a6432ac63655909ff70cb22bde33cf28c --- ext/fts5/tool/fts5txt2db.tcl | 25 +++++-------------------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/ext/fts5/tool/fts5txt2db.tcl b/ext/fts5/tool/fts5txt2db.tcl index 23f607a801..c22c5dae72 100644 --- a/ext/fts5/tool/fts5txt2db.tcl +++ b/ext/fts5/tool/fts5txt2db.tcl @@ -25,7 +25,7 @@ is exhausted. exit -1 } -set O(aColsize) [list 10 10 10] +set O(aColSize) [list 10 10 10] set O(tblname) t1 set O(fts) fts5 @@ -61,22 +61,7 @@ if {$i > [llength $argv]-2} usage set O(db) [lindex $argv $i] set O(files) [lrange $argv [expr $i+1] end] -foreach {k v} [lrange $argv 0 end-2] { - switch -- $k { - -colsize { - set O(aColSize) $v - } - - -colsize { - set O(aColSize) $v - } - } - -} - sqlite3 db $O(db) -load_static_extension db fts5 - # Create the FTS table in the db. Return a list of the table columns. # @@ -84,7 +69,7 @@ proc create_table {} { global O set cols [list a b c d e f g h i j k l m n o p q r s t u v w x y z] - set nCol [llength $O(aColsize)] + set nCol [llength $O(aColSize)] set cols [lrange $cols 0 [expr $nCol-1]] set sql "CREATE VIRTUAL TABLE IF NOT EXISTS $O(tblname) USING $O(fts) (" @@ -117,14 +102,14 @@ set i 0 set cols [create_table] set sql "INSERT INTO $O(tblname) VALUES(\$[lindex $cols 0]" foreach c [lrange $cols 1 end] { - append sql ", \$$c" + append sql ", \$A($c)" } append sql ")" db eval BEGIN while {$i < $N} { - foreach c $cols s $O(aColsize) { - set $c [lrange $tokens $i [expr $i+$s-1]] + foreach c $cols s $O(aColSize) { + set A($c) [lrange $tokens $i [expr $i+$s-1]] incr i $s } db eval $sql diff --git a/manifest b/manifest index 955c828ace..2671464cd0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sto\scover\snew\sbranches\sadded\sto\sthe\sfts5\scode\sby\sthe\sprevious\scommit. -D 2015-10-17T20:34:49.498 +C Fix\sa\sproblem\sin\sthe\sfts5txt2db.tcl\sscript\scausing\sit\sto\sfail\swhen\screating\stables\swith\smore\sthan\s8\scolumns. +D 2015-10-19T15:59:08.318 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -181,7 +181,7 @@ F ext/fts5/test/fts5unicode3.test 35c3d02aa7acf7d43d8de3bfe32c15ba96e8928e F ext/fts5/test/fts5unindexed.test e9539d5b78c677315e7ed8ea911d4fd25437c680 F ext/fts5/test/fts5version.test 978f59541d8cef7e8591f8be2115ec5ccb863e2e F ext/fts5/test/fts5vocab.test c88a5554d0409494da95ba647bbdb4879b2624b0 -F ext/fts5/tool/fts5txt2db.tcl 3d19fb8ffb234031d33d7d2151acfbc55e9cfcc4 +F ext/fts5/tool/fts5txt2db.tcl c374c4c4797e8cdfadabdfaeeb5412dcd6686e84 F ext/fts5/tool/loadfts5.tcl 58e90407cc5c2b1770460119488fd7c0090d4dd3 F ext/fts5/tool/mkfts5c.tcl 09ce6a7997440508360f5ba1651ab7e923a8bf31 F ext/fts5/tool/showfts5.tcl 9eaf6c3df352f98a2ab5ce1921dd94128ab1381d @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6020d96ab47a0bebe41f691a3f44fd55d8b2d2b7 -R 22a259a71e3233ba8022de14ef31c49b +P cf618334a8a05a067e844236e4d461b2e5706da6 +R 30a0ced4e8757449657c5453f9890b65 U dan -Z d5f5675976d14f9fce086eaa482cce6e +Z 120618455a1082447e4825d9f82b93ec diff --git a/manifest.uuid b/manifest.uuid index 8e55d16504..0d152ea1ff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cf618334a8a05a067e844236e4d461b2e5706da6 \ No newline at end of file +68ee426a6432ac63655909ff70cb22bde33cf28c \ No newline at end of file From 5e5b454cd818e226005ffd4ae6fabbc838e5411c Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 19 Oct 2015 17:43:24 +0000 Subject: [PATCH 05/20] Another tweak to improve performance of fts5 prefix queries. FossilOrigin-Name: 69be427c864dc3de804ca3c5f1c6addcd33cd188 --- ext/fts5/fts5_index.c | 46 +++++++++++++++++++++++-------------------- manifest | 12 +++++------ manifest.uuid | 2 +- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index e006c9b36d..cf4f3d8bb3 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4111,15 +4111,6 @@ static int fts5AppendPoslist( int iSv2; int iData; - /* Append iDelta */ - iSv1 = pBuf->n; - fts5BufferSafeAppendVarint(pBuf, iDelta); - - /* WRITEPOSLISTSIZE */ - iSv2 = pBuf->n; - fts5BufferSafeAppendVarint(pBuf, pSeg->nPos*2); - iData = pBuf->n; - if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf && (pColset==0 || pColset->nCol==1) ){ @@ -4127,24 +4118,37 @@ static int fts5AppendPoslist( int nPos; if( pColset ){ nPos = fts5IndexExtractCol(&pPos, pSeg->nPos, pColset->aiCol[0]); + if( nPos==0 ) return 1; }else{ nPos = pSeg->nPos; } + assert( nPos>0 ); + fts5BufferSafeAppendVarint(pBuf, iDelta); + fts5BufferSafeAppendVarint(pBuf, nPos*2); fts5BufferSafeAppendBlob(pBuf, pPos, nPos); }else{ - fts5SegiterPoslist(p, pSeg, pColset, pBuf); - } + /* Append iDelta */ + iSv1 = pBuf->n; + fts5BufferSafeAppendVarint(pBuf, iDelta); - if( pColset ){ - int nActual = pBuf->n - iData; - if( nActual!=pSeg->nPos ){ - if( nActual==0 ){ - pBuf->n = iSv1; - return 1; - }else{ - int nReq = sqlite3Fts5GetVarintLen((u32)(nActual*2)); - while( iSv2<(iData-nReq) ){ pBuf->p[iSv2++] = 0x80; } - sqlite3Fts5PutVarint(&pBuf->p[iSv2], nActual*2); + /* WRITEPOSLISTSIZE */ + iSv2 = pBuf->n; + fts5BufferSafeAppendVarint(pBuf, pSeg->nPos*2); + iData = pBuf->n; + + fts5SegiterPoslist(p, pSeg, pColset, pBuf); + + if( pColset ){ + int nActual = pBuf->n - iData; + if( nActual!=pSeg->nPos ){ + if( nActual==0 ){ + pBuf->n = iSv1; + return 1; + }else{ + int nReq = sqlite3Fts5GetVarintLen((u32)(nActual*2)); + while( iSv2<(iData-nReq) ){ pBuf->p[iSv2++] = 0x80; } + sqlite3Fts5PutVarint(&pBuf->p[iSv2], nActual*2); + } } } } diff --git a/manifest b/manifest index 2671464cd0..84b919c298 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sthe\sfts5txt2db.tcl\sscript\scausing\sit\sto\sfail\swhen\screating\stables\swith\smore\sthan\s8\scolumns. -D 2015-10-19T15:59:08.318 +C Another\stweak\sto\simprove\sperformance\sof\sfts5\sprefix\squeries. +D 2015-10-19T17:43:24.360 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -109,7 +109,7 @@ F ext/fts5/fts5_buffer.c 9a3aa73a4e7b26b1c805b9c92c1344ba3d19d2a8 F ext/fts5/fts5_config.c 88a77f5d5e4dfbb2355b8f6cc9969b7f02d94685 F ext/fts5/fts5_expr.c 28b15c9ae296204bc0a2e5cf7a667d840a9d2900 F ext/fts5/fts5_hash.c a9d4c1efebc2a91d26ad7ebdfcbf2678ceac405f -F ext/fts5/fts5_index.c 632fdcb1971f6c9d7d6b2bd31f6c41e4189162bb +F ext/fts5/fts5_index.c 8468e41855bba133107760badda415bc7f86c12c F ext/fts5/fts5_main.c 520a29136ba07448331f73bdc36d0ffa1e9dcfef F ext/fts5/fts5_storage.c 9b30115742b758706de70595a8d1d084e940c978 F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P cf618334a8a05a067e844236e4d461b2e5706da6 -R 30a0ced4e8757449657c5453f9890b65 +P 68ee426a6432ac63655909ff70cb22bde33cf28c +R b1e8d85157aaa205dae46563b3080619 U dan -Z 120618455a1082447e4825d9f82b93ec +Z e2816fa336eec46724399248fb4f473f diff --git a/manifest.uuid b/manifest.uuid index 0d152ea1ff..833def65e8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -68ee426a6432ac63655909ff70cb22bde33cf28c \ No newline at end of file +69be427c864dc3de804ca3c5f1c6addcd33cd188 \ No newline at end of file From 8789fbb2bdbc784976064ec687f16891104ca9c9 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 19 Oct 2015 20:49:10 +0000 Subject: [PATCH 06/20] Another optimization for fts5 prefix (and other) queries. FossilOrigin-Name: 60a8bde055a960c5b8cb4e231802c75617c942d8 --- ext/fts5/fts5Int.h | 7 ++++++- ext/fts5/fts5_buffer.c | 42 ++++++++++++++++++------------------------ ext/fts5/fts5_index.c | 12 +++++++----- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index bef185b07b..b6c498fc3f 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -224,6 +224,7 @@ struct Fts5Buffer { int nSpace; }; +int sqlite3Fts5BufferSize(int*, Fts5Buffer*, int); int sqlite3Fts5BufferGrow(int*, Fts5Buffer*, int); void sqlite3Fts5BufferAppendVarint(int*, Fts5Buffer*, i64); void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, int, const u8*); @@ -237,13 +238,17 @@ void sqlite3Fts5BufferAppend32(int*, Fts5Buffer*, int); char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...); #define fts5BufferZero(x) sqlite3Fts5BufferZero(x) -#define fts5BufferGrow(a,b,c) sqlite3Fts5BufferGrow(a,b,c) #define fts5BufferAppendVarint(a,b,c) sqlite3Fts5BufferAppendVarint(a,b,c) #define fts5BufferFree(a) sqlite3Fts5BufferFree(a) #define fts5BufferAppendBlob(a,b,c,d) sqlite3Fts5BufferAppendBlob(a,b,c,d) #define fts5BufferSet(a,b,c,d) sqlite3Fts5BufferSet(a,b,c,d) #define fts5BufferAppend32(a,b,c) sqlite3Fts5BufferAppend32(a,b,c) +#define fts5BufferGrow(pRc,pBuf,nn) ( \ + (pBuf)->n + (nn) <= (pBuf)->nSpace ? 0 : \ + sqlite3Fts5BufferSize((pRc),(pBuf),(nn)+(pBuf)->n) \ +) + /* Write and decode big-endian 32-bit integer values */ void sqlite3Fts5Put32(u8*, int); int sqlite3Fts5Get32(const u8*); diff --git a/ext/fts5/fts5_buffer.c b/ext/fts5/fts5_buffer.c index 07d8516ce4..bb64ce70d1 100644 --- a/ext/fts5/fts5_buffer.c +++ b/ext/fts5/fts5_buffer.c @@ -15,36 +15,30 @@ #include "fts5Int.h" -int sqlite3Fts5BufferGrow(int *pRc, Fts5Buffer *pBuf, int nByte){ - - if( (pBuf->n + nByte) > pBuf->nSpace ){ - u8 *pNew; - int nNew = pBuf->nSpace ? pBuf->nSpace*2 : 64; - - /* A no-op if an error has already occurred */ - if( *pRc ) return 1; - - while( nNew<(pBuf->n + nByte) ){ - nNew = nNew * 2; - } - pNew = sqlite3_realloc(pBuf->p, nNew); - if( pNew==0 ){ - *pRc = SQLITE_NOMEM; - return 1; - }else{ - pBuf->nSpace = nNew; - pBuf->p = pNew; - } +int sqlite3Fts5BufferSize(int *pRc, Fts5Buffer *pBuf, int nByte){ + int nNew = pBuf->nSpace ? pBuf->nSpace*2 : 64; + u8 *pNew; + while( nNewp, nNew); + if( pNew==0 ){ + *pRc = SQLITE_NOMEM; + return 1; + }else{ + pBuf->nSpace = nNew; + pBuf->p = pNew; } return 0; } + /* ** Encode value iVal as an SQLite varint and append it to the buffer object ** pBuf. If an OOM error occurs, set the error code in p. */ void sqlite3Fts5BufferAppendVarint(int *pRc, Fts5Buffer *pBuf, i64 iVal){ - if( sqlite3Fts5BufferGrow(pRc, pBuf, 9) ) return; + if( fts5BufferGrow(pRc, pBuf, 9) ) return; pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iVal); } @@ -60,7 +54,7 @@ int sqlite3Fts5Get32(const u8 *aBuf){ } void sqlite3Fts5BufferAppend32(int *pRc, Fts5Buffer *pBuf, int iVal){ - if( sqlite3Fts5BufferGrow(pRc, pBuf, 4) ) return; + if( fts5BufferGrow(pRc, pBuf, 4) ) return; sqlite3Fts5Put32(&pBuf->p[pBuf->n], iVal); pBuf->n += 4; } @@ -77,7 +71,7 @@ void sqlite3Fts5BufferAppendBlob( const u8 *pData ){ assert( *pRc || nData>=0 ); - if( sqlite3Fts5BufferGrow(pRc, pBuf, nData) ) return; + if( fts5BufferGrow(pRc, pBuf, nData) ) return; memcpy(&pBuf->p[pBuf->n], pData, nData); pBuf->n += nData; } @@ -227,7 +221,7 @@ int sqlite3Fts5PoslistWriterAppend( ){ static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32; int rc = SQLITE_OK; - if( 0==sqlite3Fts5BufferGrow(&rc, pBuf, 5+5+5) ){ + if( 0==fts5BufferGrow(&rc, pBuf, 5+5+5) ){ if( (iPos & colmask) != (pWriter->iPrev & colmask) ){ pBuf->p[pBuf->n++] = 1; pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32)); diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index cf4f3d8bb3..19ea73ab96 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4107,9 +4107,6 @@ static int fts5AppendPoslist( assert( fts5MultiIterEof(p, pMulti)==0 ); assert( pSeg->nPos>0 ); if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+9+9) ){ - int iSv1; - int iSv2; - int iData; if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf && (pColset==0 || pColset->nCol==1) @@ -4127,6 +4124,10 @@ static int fts5AppendPoslist( fts5BufferSafeAppendVarint(pBuf, nPos*2); fts5BufferSafeAppendBlob(pBuf, pPos, nPos); }else{ + int iSv1; + int iSv2; + int iData; + /* Append iDelta */ iSv1 = pBuf->n; fts5BufferSafeAppendVarint(pBuf, iDelta); @@ -4152,6 +4153,7 @@ static int fts5AppendPoslist( } } } + } } @@ -4240,7 +4242,7 @@ static void fts5MergePrefixLists( memset(&out, 0, sizeof(out)); memset(&tmp, 0, sizeof(tmp)); - sqlite3Fts5BufferGrow(&p->rc, &out, p1->n + p2->n); + fts5BufferGrow(&p->rc, &out, p1->n + p2->n); fts5DoclistIterInit(p1, &i1); fts5DoclistIterInit(p2, &i2); while( p->rc==SQLITE_OK && (i1.aPoslist!=0 || i2.aPoslist!=0) ){ @@ -4603,7 +4605,7 @@ int sqlite3Fts5IndexQuery( /* If the QUERY_SCAN flag is set, all other flags must be clear. */ assert( (flags & FTS5INDEX_QUERY_SCAN)==0 || flags==FTS5INDEX_QUERY_SCAN ); - if( sqlite3Fts5BufferGrow(&p->rc, &buf, nToken+1)==0 ){ + if( fts5BufferGrow(&p->rc, &buf, nToken+1)==0 ){ memcpy(&buf.p[1], pToken, nToken); #ifdef SQLITE_DEBUG diff --git a/manifest b/manifest index 84b919c298..3418ca7815 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Another\stweak\sto\simprove\sperformance\sof\sfts5\sprefix\squeries. -D 2015-10-19T17:43:24.360 +C Another\soptimization\sfor\sfts5\sprefix\s(and\sother)\squeries. +D 2015-10-19T20:49:10.124 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -103,13 +103,13 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 8b9a13b309b180e9fb88ea5666c0d8d73c6102d9 -F ext/fts5/fts5Int.h 0332d12fdca0f4fe2231df71bd7544b3cef81122 +F ext/fts5/fts5Int.h db1d5a18bae953c749198fe6d87862055ef55a1d F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 -F ext/fts5/fts5_buffer.c 9a3aa73a4e7b26b1c805b9c92c1344ba3d19d2a8 +F ext/fts5/fts5_buffer.c 6d4082daa71eef87812b8caa9d60ae57a6a9ebc0 F ext/fts5/fts5_config.c 88a77f5d5e4dfbb2355b8f6cc9969b7f02d94685 F ext/fts5/fts5_expr.c 28b15c9ae296204bc0a2e5cf7a667d840a9d2900 F ext/fts5/fts5_hash.c a9d4c1efebc2a91d26ad7ebdfcbf2678ceac405f -F ext/fts5/fts5_index.c 8468e41855bba133107760badda415bc7f86c12c +F ext/fts5/fts5_index.c 38d7ddd4d5650007ee83000f0f96967ff83c710c F ext/fts5/fts5_main.c 520a29136ba07448331f73bdc36d0ffa1e9dcfef F ext/fts5/fts5_storage.c 9b30115742b758706de70595a8d1d084e940c978 F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 68ee426a6432ac63655909ff70cb22bde33cf28c -R b1e8d85157aaa205dae46563b3080619 +P 69be427c864dc3de804ca3c5f1c6addcd33cd188 +R cf51e15890c7ae1ec9dc153fd0832e0a U dan -Z e2816fa336eec46724399248fb4f473f +Z 01b7158ec138174afd0e008584d0b467 diff --git a/manifest.uuid b/manifest.uuid index 833def65e8..4e22ea3ddd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -69be427c864dc3de804ca3c5f1c6addcd33cd188 \ No newline at end of file +60a8bde055a960c5b8cb4e231802c75617c942d8 \ No newline at end of file From 3f9bfa740f6bd337a9e1620cfadd4be99c79ede8 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 20 Oct 2015 15:49:02 +0000 Subject: [PATCH 07/20] Initialize variables in the fts5 integrity-check code to avoid compiler warnings. FossilOrigin-Name: e979e2cccac257ad554803e6a1103558b0f159d8 --- ext/fts5/fts5_storage.c | 4 ++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index ce38762cad..ff4aea50e1 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -914,12 +914,12 @@ int sqlite3Fts5StorageIntegrity(Fts5Storage *p){ /* Check that the %_docsize and %_content tables contain the expected ** number of rows. */ if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){ - i64 nRow; + i64 nRow = 0; rc = fts5StorageCount(p, "content", &nRow); if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT; } if( rc==SQLITE_OK && pConfig->bColumnsize ){ - i64 nRow; + i64 nRow = 0; rc = fts5StorageCount(p, "docsize", &nRow); if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT; } diff --git a/manifest b/manifest index 3418ca7815..7f3a3228ee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Another\soptimization\sfor\sfts5\sprefix\s(and\sother)\squeries. -D 2015-10-19T20:49:10.124 +C Initialize\svariables\sin\sthe\sfts5\sintegrity-check\scode\sto\savoid\scompiler\swarnings. +D 2015-10-20T15:49:02.194 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -111,7 +111,7 @@ F ext/fts5/fts5_expr.c 28b15c9ae296204bc0a2e5cf7a667d840a9d2900 F ext/fts5/fts5_hash.c a9d4c1efebc2a91d26ad7ebdfcbf2678ceac405f F ext/fts5/fts5_index.c 38d7ddd4d5650007ee83000f0f96967ff83c710c F ext/fts5/fts5_main.c 520a29136ba07448331f73bdc36d0ffa1e9dcfef -F ext/fts5/fts5_storage.c 9b30115742b758706de70595a8d1d084e940c978 +F ext/fts5/fts5_storage.c 8038a54a88d3beb94dc7f9db6428a3bc08b718bb F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd F ext/fts5/fts5_test_mi.c e96be827aa8f571031e65e481251dc1981d608bf F ext/fts5/fts5_tokenize.c 12c5d925286491a71bb3dad7c8924ce9cfd18320 @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 69be427c864dc3de804ca3c5f1c6addcd33cd188 -R cf51e15890c7ae1ec9dc153fd0832e0a +P 60a8bde055a960c5b8cb4e231802c75617c942d8 +R 507ca9e6ed1f2a8dcb12d2eaeb7b0450 U dan -Z 01b7158ec138174afd0e008584d0b467 +Z c40a91b7d33ce0f422b5ec994684bd4f diff --git a/manifest.uuid b/manifest.uuid index 4e22ea3ddd..74827af32d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -60a8bde055a960c5b8cb4e231802c75617c942d8 \ No newline at end of file +e979e2cccac257ad554803e6a1103558b0f159d8 \ No newline at end of file From 9cc4ae6f2aec8b46201856dc5b33a381fbc9ee4d Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 20 Oct 2015 19:55:35 +0000 Subject: [PATCH 08/20] Fix #line directives added to generated file fts5.c. FossilOrigin-Name: 1f5f5804cd394a81b1c0712ce6d1052f228d0a40 --- ext/fts5/fts5_index.c | 38 ++++++++++++++++++-------------------- ext/fts5/tool/mkfts5c.tcl | 8 +++++--- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 19ea73ab96..927d0a94dc 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -374,26 +374,6 @@ struct Fts5SegWriter { int iBtPage; /* Page number corresponding to btterm */ }; -/* -** Object for iterating through the merged results of one or more segments, -** visiting each term/rowid pair in the merged data. -** -** nSeg is always a power of two greater than or equal to the number of -** segments that this object is merging data from. Both the aSeg[] and -** aFirst[] arrays are sized at nSeg entries. The aSeg[] array is padded -** with zeroed objects - these are handled as if they were iterators opened -** on empty segments. -** -** The results of comparing segments aSeg[N] and aSeg[N+1], where N is an -** even number, is stored in aFirst[(nSeg+N)/2]. The "result" of the -** comparison in this context is the index of the iterator that currently -** points to the smaller term/rowid combination. Iterators at EOF are -** considered to be greater than all other iterators. -** -** aFirst[1] contains the index in aSeg[] of the iterator that points to -** the smallest key overall. aFirst[0] is unused. -*/ - typedef struct Fts5CResult Fts5CResult; struct Fts5CResult { u16 iFirst; /* aSeg[] index of firstest iterator */ @@ -500,6 +480,24 @@ struct Fts5SegIter { #define fts5LeafFirstRowidOff(x) (fts5GetU16((x)->p)) /* +** Object for iterating through the merged results of one or more segments, +** visiting each term/rowid pair in the merged data. +** +** nSeg is always a power of two greater than or equal to the number of +** segments that this object is merging data from. Both the aSeg[] and +** aFirst[] arrays are sized at nSeg entries. The aSeg[] array is padded +** with zeroed objects - these are handled as if they were iterators opened +** on empty segments. +** +** The results of comparing segments aSeg[N] and aSeg[N+1], where N is an +** even number, is stored in aFirst[(nSeg+N)/2]. The "result" of the +** comparison in this context is the index of the iterator that currently +** points to the smaller term/rowid combination. Iterators at EOF are +** considered to be greater than all other iterators. +** +** aFirst[1] contains the index in aSeg[] of the iterator that points to +** the smallest key overall. aFirst[0] is unused. +** ** poslist: ** Used by sqlite3Fts5IterPoslist() when the poslist needs to be buffered. ** There is no way to tell if this is populated or not. diff --git a/ext/fts5/tool/mkfts5c.tcl b/ext/fts5/tool/mkfts5c.tcl index 535506de1b..797811d46e 100644 --- a/ext/fts5/tool/mkfts5c.tcl +++ b/ext/fts5/tool/mkfts5c.tcl @@ -78,7 +78,7 @@ proc fts5c_printfile {zIn} { global G set data [readfile $zIn] set zTail [file tail $zIn] - puts $G(fd) "#line 2 \"$zTail\"" + puts $G(fd) "#line 1 \"$zTail\"" set sub_map [list --FTS5-SOURCE-ID-- [fts5_source_id $::srcdir]] if {$zTail=="fts5parse.c"} { @@ -86,8 +86,10 @@ proc fts5c_printfile {zIn} { } foreach line [split $data "\n"] { - if {[regexp {^#include.*fts5} $line]} continue - if { ![regexp { sqlite3Fts5Init\(} $line] + if {[regexp {^#include.*fts5} $line]} { + set line "/* $line */" + } elseif { + ![regexp { sqlite3Fts5Init\(} $line] && [regexp {^(const )?[a-zA-Z][a-zA-Z0-9]* [*]?sqlite3Fts5} $line] } { set line "static $line" diff --git a/manifest b/manifest index 7f3a3228ee..d0b4c559b0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Initialize\svariables\sin\sthe\sfts5\sintegrity-check\scode\sto\savoid\scompiler\swarnings. -D 2015-10-20T15:49:02.194 +C Fix\s#line\sdirectives\sadded\sto\sgenerated\sfile\sfts5.c. +D 2015-10-20T19:55:35.406 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -109,7 +109,7 @@ F ext/fts5/fts5_buffer.c 6d4082daa71eef87812b8caa9d60ae57a6a9ebc0 F ext/fts5/fts5_config.c 88a77f5d5e4dfbb2355b8f6cc9969b7f02d94685 F ext/fts5/fts5_expr.c 28b15c9ae296204bc0a2e5cf7a667d840a9d2900 F ext/fts5/fts5_hash.c a9d4c1efebc2a91d26ad7ebdfcbf2678ceac405f -F ext/fts5/fts5_index.c 38d7ddd4d5650007ee83000f0f96967ff83c710c +F ext/fts5/fts5_index.c 903ca7a882d6f7ae4a08575b233fc95894daaf0b F ext/fts5/fts5_main.c 520a29136ba07448331f73bdc36d0ffa1e9dcfef F ext/fts5/fts5_storage.c 8038a54a88d3beb94dc7f9db6428a3bc08b718bb F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd @@ -183,7 +183,7 @@ F ext/fts5/test/fts5version.test 978f59541d8cef7e8591f8be2115ec5ccb863e2e F ext/fts5/test/fts5vocab.test c88a5554d0409494da95ba647bbdb4879b2624b0 F ext/fts5/tool/fts5txt2db.tcl c374c4c4797e8cdfadabdfaeeb5412dcd6686e84 F ext/fts5/tool/loadfts5.tcl 58e90407cc5c2b1770460119488fd7c0090d4dd3 -F ext/fts5/tool/mkfts5c.tcl 09ce6a7997440508360f5ba1651ab7e923a8bf31 +F ext/fts5/tool/mkfts5c.tcl d1c2a9ab8e0ec690a52316f33dd9b1d379942f45 F ext/fts5/tool/showfts5.tcl 9eaf6c3df352f98a2ab5ce1921dd94128ab1381d F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c b2732aef0b076e4276d9b39b5a33cec7a05e1413 @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 60a8bde055a960c5b8cb4e231802c75617c942d8 -R 507ca9e6ed1f2a8dcb12d2eaeb7b0450 +P e979e2cccac257ad554803e6a1103558b0f159d8 +R 44b3b756f766dbcb6a6fd920376ac78a U dan -Z c40a91b7d33ce0f422b5ec994684bd4f +Z 5fc3ef172eb8863d82203d5aa10e31b9 diff --git a/manifest.uuid b/manifest.uuid index 74827af32d..4e786e8270 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e979e2cccac257ad554803e6a1103558b0f159d8 \ No newline at end of file +1f5f5804cd394a81b1c0712ce6d1052f228d0a40 \ No newline at end of file From 219f4d48a2820cfdd3f7422892017a8b5755f07f Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 20 Oct 2015 21:05:53 +0000 Subject: [PATCH 09/20] More optimizations for fts5 prefix queries. FossilOrigin-Name: b8fb263ed1b36d085437131795505e53af103d26 --- ext/fts5/fts5_index.c | 38 +++++++++++++++++++++++++++++++++++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 927d0a94dc..6747b9387b 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -2591,6 +2591,34 @@ static void fts5MultiIterNext( } } +static void fts5MultiIterNext2( + Fts5Index *p, + Fts5IndexIter *pIter, + int *pbNewTerm /* OUT: True if *might* be new term */ +){ + if( p->rc==SQLITE_OK ){ + do { + int iFirst = pIter->aFirst[1].iFirst; + Fts5SegIter *pSeg = &pIter->aSeg[iFirst]; + int bNewTerm = 0; + + fts5SegIterNext(p, pSeg, &bNewTerm); + if( pSeg->pLeaf==0 || bNewTerm + || fts5MultiIterAdvanceRowid(p, pIter, iFirst) + ){ + fts5MultiIterAdvanced(p, pIter, iFirst, 1); + fts5MultiIterSetEof(pIter); + *pbNewTerm = 1; + }else{ + *pbNewTerm = 0; + } + fts5AssertMultiIterSetup(p, pIter); + + }while( pIter->bSkipEmpty && fts5MultiIterIsEmpty(p, pIter) ); + } +} + + static Fts5IndexIter *fts5MultiIterAlloc( Fts5Index *p, /* FTS5 backend to iterate within */ int nSeg @@ -4058,7 +4086,7 @@ static int fts5IndexExtractCol( const u8 *pEnd = &p[n]; /* One byte past end of position list */ u8 prev = 0; - while( iCol!=iCurrent ){ + while( iCol>iCurrent ){ /* Advance pointer p until it points to pEnd or an 0x01 byte that is ** not part of a varint */ while( (prev & 0x80) || *p!=0x01 ){ @@ -4068,6 +4096,7 @@ static int fts5IndexExtractCol( *pa = p++; p += fts5GetVarint32(p, iCurrent); } + if( iCol!=iCurrent ) return 0; /* Advance pointer p until it points to pEnd or an 0x01 byte that is ** not part of a varint */ @@ -4331,17 +4360,20 @@ static void fts5SetupPrefixIter( Fts5IndexIter *p1 = 0; /* Iterator used to gather data from index */ Fts5Data *pData; Fts5Buffer doclist; + int bNewTerm; memset(&doclist, 0, sizeof(doclist)); for(fts5MultiIterNew(p, pStruct, 1, flags, pToken, nToken, -1, 0, &p1); fts5MultiIterEof(p, p1)==0; - fts5MultiIterNext(p, p1, 0, 0) + fts5MultiIterNext2(p, p1, &bNewTerm) ){ i64 iRowid = fts5MultiIterRowid(p1); int nTerm; const u8 *pTerm = fts5MultiIterTerm(p1, &nTerm); assert_nc( memcmp(pToken, pTerm, MIN(nToken, nTerm))<=0 ); - if( nTerm0 && iRowid<=iLastRowid ){ for(i=0; p->rc==SQLITE_OK && doclist.n; i++){ diff --git a/manifest b/manifest index d0b4c559b0..d75668e6c4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\s#line\sdirectives\sadded\sto\sgenerated\sfile\sfts5.c. -D 2015-10-20T19:55:35.406 +C More\soptimizations\sfor\sfts5\sprefix\squeries. +D 2015-10-20T21:05:53.203 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -109,7 +109,7 @@ F ext/fts5/fts5_buffer.c 6d4082daa71eef87812b8caa9d60ae57a6a9ebc0 F ext/fts5/fts5_config.c 88a77f5d5e4dfbb2355b8f6cc9969b7f02d94685 F ext/fts5/fts5_expr.c 28b15c9ae296204bc0a2e5cf7a667d840a9d2900 F ext/fts5/fts5_hash.c a9d4c1efebc2a91d26ad7ebdfcbf2678ceac405f -F ext/fts5/fts5_index.c 903ca7a882d6f7ae4a08575b233fc95894daaf0b +F ext/fts5/fts5_index.c 45856922243dc5f9d5bdc3b677d68e27997df600 F ext/fts5/fts5_main.c 520a29136ba07448331f73bdc36d0ffa1e9dcfef F ext/fts5/fts5_storage.c 8038a54a88d3beb94dc7f9db6428a3bc08b718bb F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e979e2cccac257ad554803e6a1103558b0f159d8 -R 44b3b756f766dbcb6a6fd920376ac78a +P 1f5f5804cd394a81b1c0712ce6d1052f228d0a40 +R 843f1263cb5ed99ae94cdac9953fa2b8 U dan -Z 5fc3ef172eb8863d82203d5aa10e31b9 +Z 0e003a47783a27c94ee2f0e7d256c7c6 diff --git a/manifest.uuid b/manifest.uuid index 4e786e8270..c7f268a7a4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1f5f5804cd394a81b1c0712ce6d1052f228d0a40 \ No newline at end of file +b8fb263ed1b36d085437131795505e53af103d26 \ No newline at end of file From 6d7734c27d3556568c828e999f65b0c9d2cbdb3f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 20 Oct 2015 23:27:14 +0000 Subject: [PATCH 10/20] Fix harmless compiler warnings in FTS5. FossilOrigin-Name: 0a903ec26bfbbe9bfd18bc34934e689ffdb01ce5 --- ext/fts5/fts5_index.c | 2 +- ext/fts5/fts5_vocab.c | 8 ++++---- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 6747b9387b..1628018b48 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4360,7 +4360,7 @@ static void fts5SetupPrefixIter( Fts5IndexIter *p1 = 0; /* Iterator used to gather data from index */ Fts5Data *pData; Fts5Buffer doclist; - int bNewTerm; + int bNewTerm = 0; memset(&doclist, 0, sizeof(doclist)); for(fts5MultiIterNew(p, pStruct, 1, flags, pToken, nToken, -1, 0, &p1); diff --git a/ext/fts5/fts5_vocab.c b/ext/fts5/fts5_vocab.c index 80e3455900..1d13b9cd63 100644 --- a/ext/fts5/fts5_vocab.c +++ b/ext/fts5/fts5_vocab.c @@ -462,7 +462,7 @@ static int fts5VocabFilterMethod( sqlite3_value **apVal /* Arguments for the indexing scheme */ ){ Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor; - int rc; + int rc = SQLITE_OK; int iVal = 0; int f = FTS5INDEX_QUERY_SCAN; @@ -479,16 +479,16 @@ static int fts5VocabFilterMethod( if( idxNum & FTS5_VOCAB_TERM_LE ) pLe = apVal[iVal++]; if( pEq ){ - zTerm = sqlite3_value_text(pEq); + zTerm = (const char *)sqlite3_value_text(pEq); nTerm = sqlite3_value_bytes(pEq); f = 0; }else{ if( pGe ){ - zTerm = sqlite3_value_text(pGe); + zTerm = (const char *)sqlite3_value_text(pGe); nTerm = sqlite3_value_bytes(pGe); } if( pLe ){ - const char *zCopy = sqlite3_value_text(pLe); + const char *zCopy = (const char *)sqlite3_value_text(pLe); pCsr->nLeTerm = sqlite3_value_bytes(pLe); pCsr->zLeTerm = sqlite3_malloc(pCsr->nLeTerm+1); if( pCsr->zLeTerm==0 ){ diff --git a/manifest b/manifest index d75668e6c4..e406cb4dc0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\soptimizations\sfor\sfts5\sprefix\squeries. -D 2015-10-20T21:05:53.203 +C Fix\sharmless\scompiler\swarnings\sin\sFTS5. +D 2015-10-20T23:27:14.365 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -109,7 +109,7 @@ F ext/fts5/fts5_buffer.c 6d4082daa71eef87812b8caa9d60ae57a6a9ebc0 F ext/fts5/fts5_config.c 88a77f5d5e4dfbb2355b8f6cc9969b7f02d94685 F ext/fts5/fts5_expr.c 28b15c9ae296204bc0a2e5cf7a667d840a9d2900 F ext/fts5/fts5_hash.c a9d4c1efebc2a91d26ad7ebdfcbf2678ceac405f -F ext/fts5/fts5_index.c 45856922243dc5f9d5bdc3b677d68e27997df600 +F ext/fts5/fts5_index.c d3503c75d329f027140b855149566c97c078c18d F ext/fts5/fts5_main.c 520a29136ba07448331f73bdc36d0ffa1e9dcfef F ext/fts5/fts5_storage.c 8038a54a88d3beb94dc7f9db6428a3bc08b718bb F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd @@ -117,7 +117,7 @@ F ext/fts5/fts5_test_mi.c e96be827aa8f571031e65e481251dc1981d608bf F ext/fts5/fts5_tokenize.c 12c5d925286491a71bb3dad7c8924ce9cfd18320 F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 -F ext/fts5/fts5_vocab.c 4bf7e418bd3f857c7aea8221fc2c159283d30c6b +F ext/fts5/fts5_vocab.c fc319264ebbf1b4518afd9cacd3801ac526536d8 F ext/fts5/fts5parse.y e83dca6028e3309178d05b5bd920e372dc295d35 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl 51f7ef3af444b89c6f6ce3896a0ac349ff4e996d @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1f5f5804cd394a81b1c0712ce6d1052f228d0a40 -R 843f1263cb5ed99ae94cdac9953fa2b8 -U dan -Z 0e003a47783a27c94ee2f0e7d256c7c6 +P b8fb263ed1b36d085437131795505e53af103d26 +R 95702bd1633e56deaa7f0c8cd9294ab7 +U mistachkin +Z 2868708b35b26115fe25354e42651fac diff --git a/manifest.uuid b/manifest.uuid index c7f268a7a4..ea64a17af2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8fb263ed1b36d085437131795505e53af103d26 \ No newline at end of file +0a903ec26bfbbe9bfd18bc34934e689ffdb01ce5 \ No newline at end of file From 5c22e82a175b6015df5b6fe70eabec413fca8a23 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 21 Oct 2015 08:26:01 +0000 Subject: [PATCH 11/20] Add extra debugging function to test_rbu.c. Enhance the documentation for sqlite3rbu_db() to define the validity of the returned database handles. FossilOrigin-Name: b9c4aa521156d8ca09151a82a7e80aa8d1d7a313 --- ext/rbu/sqlite3rbu.h | 3 +++ ext/rbu/test_rbu.c | 36 ++++++++++++++++++++++++++++++------ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/ext/rbu/sqlite3rbu.h b/ext/rbu/sqlite3rbu.h index 65d1c5f6e5..f1a0f3cd84 100644 --- a/ext/rbu/sqlite3rbu.h +++ b/ext/rbu/sqlite3rbu.h @@ -341,6 +341,9 @@ sqlite3rbu *sqlite3rbu_open( ** If an error has occurred, either while opening or stepping the RBU object, ** this function may return NULL. The error code and message may be collected ** when sqlite3rbu_close() is called. +** +** Database handles returned by this function remain valid until the next +** call to any sqlite3rbu_xxx() function other than sqlite3rbu_db(). */ sqlite3 *sqlite3rbu_db(sqlite3rbu*, int bRbu); diff --git a/ext/rbu/test_rbu.c b/ext/rbu/test_rbu.c index 6648f28e8b..3fa85b7569 100644 --- a/ext/rbu/test_rbu.c +++ b/ext/rbu/test_rbu.c @@ -56,20 +56,34 @@ static int test_sqlite3rbu_cmd( ){ int ret = TCL_OK; sqlite3rbu *pRbu = (sqlite3rbu*)clientData; - const char *azMethod[] = { - "step", "close", "create_rbu_delta", "savestate", 0 + struct RbuCmd { + const char *zName; + int nArg; + const char *zUsage; + } aCmd[] = { + {"step", 2, ""}, /* 0 */ + {"close", 2, ""}, /* 1 */ + {"create_rbu_delta", 2, ""}, /* 2 */ + {"savestate", 2, ""}, /* 3 */ + {"dbMain_eval", 3, "SQL"}, /* 4 */ + {0,0,0} }; - int iMethod; + int iCmd; - if( objc!=2 ){ + if( objc<2 ){ Tcl_WrongNumArgs(interp, 1, objv, "METHOD"); return TCL_ERROR; } - if( Tcl_GetIndexFromObj(interp, objv[1], azMethod, "method", 0, &iMethod) ){ + ret = Tcl_GetIndexFromObjStruct( + interp, objv[1], aCmd, sizeof(aCmd[0]), "method", 0, &iCmd + ); + if( ret ) return TCL_ERROR; + if( objc!=aCmd[iCmd].nArg ){ + Tcl_WrongNumArgs(interp, 1, objv, aCmd[iCmd].zUsage); return TCL_ERROR; } - switch( iMethod ){ + switch( iCmd ){ case 0: /* step */ { int rc = sqlite3rbu_step(pRbu); Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); @@ -112,6 +126,16 @@ static int test_sqlite3rbu_cmd( break; } + case 4: /* dbMain_eval */ { + sqlite3 *db = sqlite3rbu_db(pRbu, 0); + int rc = sqlite3_exec(db, Tcl_GetString(objv[2]), 0, 0, 0); + if( rc!=SQLITE_OK ){ + Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3_errmsg(db), -1)); + ret = TCL_ERROR; + } + break; + } + default: /* seems unlikely */ assert( !"cannot happen" ); break; diff --git a/manifest b/manifest index e406cb4dc0..05c2a89ea4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sFTS5. -D 2015-10-20T23:27:14.365 +C Add\sextra\sdebugging\sfunction\sto\stest_rbu.c.\sEnhance\sthe\sdocumentation\sfor\ssqlite3rbu_db()\sto\sdefine\sthe\svalidity\sof\sthe\sreturned\sdatabase\shandles. +D 2015-10-21T08:26:01.477 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -230,8 +230,8 @@ F ext/rbu/rbufault2.test 9a7f19edd6ea35c4c9f807d8a3db0a03a5670c06 F ext/rbu/rbufts.test 828cd689da825f0a7b7c53ffc1f6f7fdb6fa5bda F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48 F ext/rbu/sqlite3rbu.c ea47de615e911b3a69a8e7fb3be3866298403a25 -F ext/rbu/sqlite3rbu.h 1d568cb33738d7900975cc5c72e6f68049f15914 -F ext/rbu/test_rbu.c 2a3652241fa45d5eaa141775e4ae68c1d3582c03 +F ext/rbu/sqlite3rbu.h 0bdeb3be211aaba7d85445fa36f4701a25a3dbde +F ext/rbu/test_rbu.c 4a4cdcef4ef9379fc2a21f008805c80b27bcf573 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/rtree.c 0f9b595bd0debcbedf1d7a63d0e0678d619e6c9c F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b8fb263ed1b36d085437131795505e53af103d26 -R 95702bd1633e56deaa7f0c8cd9294ab7 -U mistachkin -Z 2868708b35b26115fe25354e42651fac +P 0a903ec26bfbbe9bfd18bc34934e689ffdb01ce5 +R c0f5065bff60d0df79ae9d2bf6514716 +U dan +Z 2c0acb856eea548f945a4e7fa327a156 diff --git a/manifest.uuid b/manifest.uuid index ea64a17af2..c6965600bc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a903ec26bfbbe9bfd18bc34934e689ffdb01ce5 \ No newline at end of file +b9c4aa521156d8ca09151a82a7e80aa8d1d7a313 \ No newline at end of file From f2c9995dbe5ea7bd4968e57ef8a3ce784c5667d2 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 21 Oct 2015 20:07:08 +0000 Subject: [PATCH 12/20] Minor optimization for fts5 queries. FossilOrigin-Name: 363b36d50b6f3e3d3e79c538be1167b071a5a710 --- ext/fts5/fts5_index.c | 9 ++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 1628018b48..9e3a9e0ff7 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -1828,7 +1828,14 @@ static void fts5SegIterNext( if( pbNewTerm ) *pbNewTerm = 1; } }else{ - fts5SegIterLoadNPos(p, pIter); + /* The following could be done by calling fts5SegIterLoadNPos(). But + ** this block is particularly performance critical, so equivalent + ** code is inlined. */ + int nSz; + assert( p->rc==SQLITE_OK ); + fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz); + pIter->bDel = (nSz & 0x0001); + pIter->nPos = nSz>>1; } } } diff --git a/manifest b/manifest index 05c2a89ea4..a9a1d123ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextra\sdebugging\sfunction\sto\stest_rbu.c.\sEnhance\sthe\sdocumentation\sfor\ssqlite3rbu_db()\sto\sdefine\sthe\svalidity\sof\sthe\sreturned\sdatabase\shandles. -D 2015-10-21T08:26:01.477 +C Minor\soptimization\sfor\sfts5\squeries. +D 2015-10-21T20:07:08.658 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -109,7 +109,7 @@ F ext/fts5/fts5_buffer.c 6d4082daa71eef87812b8caa9d60ae57a6a9ebc0 F ext/fts5/fts5_config.c 88a77f5d5e4dfbb2355b8f6cc9969b7f02d94685 F ext/fts5/fts5_expr.c 28b15c9ae296204bc0a2e5cf7a667d840a9d2900 F ext/fts5/fts5_hash.c a9d4c1efebc2a91d26ad7ebdfcbf2678ceac405f -F ext/fts5/fts5_index.c d3503c75d329f027140b855149566c97c078c18d +F ext/fts5/fts5_index.c 47ef0002b49b1dba5d5a49c8f2b02160a146a4ff F ext/fts5/fts5_main.c 520a29136ba07448331f73bdc36d0ffa1e9dcfef F ext/fts5/fts5_storage.c 8038a54a88d3beb94dc7f9db6428a3bc08b718bb F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0a903ec26bfbbe9bfd18bc34934e689ffdb01ce5 -R c0f5065bff60d0df79ae9d2bf6514716 +P b9c4aa521156d8ca09151a82a7e80aa8d1d7a313 +R 4d88206e8c01136d0ea377b3eae363fe U dan -Z 2c0acb856eea548f945a4e7fa327a156 +Z 08a5e9e12273e463d7b7c3c870bc7777 diff --git a/manifest.uuid b/manifest.uuid index c6965600bc..cac1a13281 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b9c4aa521156d8ca09151a82a7e80aa8d1d7a313 \ No newline at end of file +363b36d50b6f3e3d3e79c538be1167b071a5a710 \ No newline at end of file From 99b25309d064198001d6d619e3581109c671e503 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 21 Oct 2015 20:56:27 +0000 Subject: [PATCH 13/20] Remove some branches made unreachable by recent changes from fts5. FossilOrigin-Name: ae350bfbfd59f912c469a51bf7d1409f3c8d958a --- ext/fts5/fts5Int.h | 2 -- ext/fts5/fts5_buffer.c | 6 ------ ext/fts5/fts5_index.c | 48 ++++++++++++++++++++++++------------------ manifest | 16 +++++++------- manifest.uuid | 2 +- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index b6c498fc3f..76b3ac3928 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -233,7 +233,6 @@ void sqlite3Fts5BufferFree(Fts5Buffer*); void sqlite3Fts5BufferZero(Fts5Buffer*); void sqlite3Fts5BufferSet(int*, Fts5Buffer*, int, const u8*); void sqlite3Fts5BufferAppendPrintf(int *, Fts5Buffer*, char *zFmt, ...); -void sqlite3Fts5BufferAppend32(int*, Fts5Buffer*, int); char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...); @@ -242,7 +241,6 @@ char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...); #define fts5BufferFree(a) sqlite3Fts5BufferFree(a) #define fts5BufferAppendBlob(a,b,c,d) sqlite3Fts5BufferAppendBlob(a,b,c,d) #define fts5BufferSet(a,b,c,d) sqlite3Fts5BufferSet(a,b,c,d) -#define fts5BufferAppend32(a,b,c) sqlite3Fts5BufferAppend32(a,b,c) #define fts5BufferGrow(pRc,pBuf,nn) ( \ (pBuf)->n + (nn) <= (pBuf)->nSpace ? 0 : \ diff --git a/ext/fts5/fts5_buffer.c b/ext/fts5/fts5_buffer.c index bb64ce70d1..e9aab4622a 100644 --- a/ext/fts5/fts5_buffer.c +++ b/ext/fts5/fts5_buffer.c @@ -53,12 +53,6 @@ int sqlite3Fts5Get32(const u8 *aBuf){ return (aBuf[0] << 24) + (aBuf[1] << 16) + (aBuf[2] << 8) + aBuf[3]; } -void sqlite3Fts5BufferAppend32(int *pRc, Fts5Buffer *pBuf, int iVal){ - if( fts5BufferGrow(pRc, pBuf, 4) ) return; - sqlite3Fts5Put32(&pBuf->p[pBuf->n], iVal); - pBuf->n += 4; -} - /* ** Append buffer nData/pData to buffer pBuf. If an OOM error occurs, set ** the error code in p. If an error has already occurred when this function diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 9e3a9e0ff7..6285fa9af3 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -1006,6 +1006,18 @@ static int fts5StructureCountSegments(Fts5Structure *pStruct){ } #endif +#define fts5BufferSafeAppendBlob(pBuf, pBlob, nBlob) { \ + assert( (pBuf)->nSpace>=((pBuf)->n+nBlob) ); \ + memcpy(&(pBuf)->p[(pBuf)->n], pBlob, nBlob); \ + (pBuf)->n += nBlob; \ +} + +#define fts5BufferSafeAppendVarint(pBuf, iVal) { \ + (pBuf)->n += sqlite3Fts5PutVarint(&(pBuf)->p[(pBuf)->n], (iVal)); \ + assert( (pBuf)->nSpace>=(pBuf)->n ); \ +} + + /* ** Serialize and store the "structure" record. ** @@ -1024,11 +1036,14 @@ static void fts5StructureWrite(Fts5Index *p, Fts5Structure *pStruct){ /* Append the current configuration cookie */ iCookie = p->pConfig->iCookie; if( iCookie<0 ) iCookie = 0; - fts5BufferAppend32(&p->rc, &buf, iCookie); - fts5BufferAppendVarint(&p->rc, &buf, pStruct->nLevel); - fts5BufferAppendVarint(&p->rc, &buf, pStruct->nSegment); - fts5BufferAppendVarint(&p->rc, &buf, (i64)pStruct->nWriteCounter); + if( 0==sqlite3Fts5BufferSize(&p->rc, &buf, 4+9+9+9) ){ + sqlite3Fts5Put32(buf.p, iCookie); + buf.n = 4; + fts5BufferSafeAppendVarint(&buf, pStruct->nLevel); + fts5BufferSafeAppendVarint(&buf, pStruct->nSegment); + fts5BufferSafeAppendVarint(&buf, (i64)pStruct->nWriteCounter); + } for(iLvl=0; iLvlnLevel; iLvl++){ int iSeg; /* Used to iterate through segments */ @@ -2603,6 +2618,7 @@ static void fts5MultiIterNext2( Fts5IndexIter *pIter, int *pbNewTerm /* OUT: True if *might* be new term */ ){ + assert( pIter->bSkipEmpty ); if( p->rc==SQLITE_OK ){ do { int iFirst = pIter->aFirst[1].iFirst; @@ -2621,7 +2637,7 @@ static void fts5MultiIterNext2( } fts5AssertMultiIterSetup(p, pIter); - }while( pIter->bSkipEmpty && fts5MultiIterIsEmpty(p, pIter) ); + }while( fts5MultiIterIsEmpty(p, pIter) ); } } @@ -3379,9 +3395,12 @@ static void fts5WriteInit( pWriter->bFirstTermInPage = 1; pWriter->iBtPage = 1; + assert( pWriter->writer.buf.n==0 ); + assert( pWriter->writer.pgidx.n==0 ); + /* Grow the two buffers to pgsz + padding bytes in size. */ - fts5BufferGrow(&p->rc, &pWriter->writer.pgidx, nBuffer); - fts5BufferGrow(&p->rc, &pWriter->writer.buf, nBuffer); + sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.pgidx, nBuffer); + sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.buf, nBuffer); if( p->pIdxWriter==0 ){ Fts5Config *pConfig = p->pConfig; @@ -3734,17 +3753,6 @@ static int fts5PoslistPrefix(const u8 *aBuf, int nMax){ return ret; } -#define fts5BufferSafeAppendBlob(pBuf, pBlob, nBlob) { \ - assert( (pBuf)->nSpace>=((pBuf)->n+nBlob) ); \ - memcpy(&(pBuf)->p[(pBuf)->n], pBlob, nBlob); \ - (pBuf)->n += nBlob; \ -} - -#define fts5BufferSafeAppendVarint(pBuf, iVal) { \ - (pBuf)->n += sqlite3Fts5PutVarint(&(pBuf)->p[(pBuf)->n], (iVal)); \ - assert( (pBuf)->nSpace>=(pBuf)->n ); \ -} - /* ** Flush the contents of in-memory hash table iHash to a new level-0 ** segment on disk. Also update the corresponding structure record. @@ -4276,7 +4284,7 @@ static void fts5MergePrefixLists( memset(&out, 0, sizeof(out)); memset(&tmp, 0, sizeof(tmp)); - fts5BufferGrow(&p->rc, &out, p1->n + p2->n); + sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n); fts5DoclistIterInit(p1, &i1); fts5DoclistIterInit(p2, &i2); while( p->rc==SQLITE_OK && (i1.aPoslist!=0 || i2.aPoslist!=0) ){ @@ -4642,7 +4650,7 @@ int sqlite3Fts5IndexQuery( /* If the QUERY_SCAN flag is set, all other flags must be clear. */ assert( (flags & FTS5INDEX_QUERY_SCAN)==0 || flags==FTS5INDEX_QUERY_SCAN ); - if( fts5BufferGrow(&p->rc, &buf, nToken+1)==0 ){ + if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){ memcpy(&buf.p[1], pToken, nToken); #ifdef SQLITE_DEBUG diff --git a/manifest b/manifest index a9a1d123ff..53c1c13210 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\soptimization\sfor\sfts5\squeries. -D 2015-10-21T20:07:08.658 +C Remove\ssome\sbranches\smade\sunreachable\sby\srecent\schanges\sfrom\sfts5. +D 2015-10-21T20:56:27.613 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e @@ -103,13 +103,13 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 8b9a13b309b180e9fb88ea5666c0d8d73c6102d9 -F ext/fts5/fts5Int.h db1d5a18bae953c749198fe6d87862055ef55a1d +F ext/fts5/fts5Int.h dfe8390b65e84846e1bd7a2fccc076d350e83f8a F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 -F ext/fts5/fts5_buffer.c 6d4082daa71eef87812b8caa9d60ae57a6a9ebc0 +F ext/fts5/fts5_buffer.c 1e49512a535045e621246dc7f4f65f3593fa0fc2 F ext/fts5/fts5_config.c 88a77f5d5e4dfbb2355b8f6cc9969b7f02d94685 F ext/fts5/fts5_expr.c 28b15c9ae296204bc0a2e5cf7a667d840a9d2900 F ext/fts5/fts5_hash.c a9d4c1efebc2a91d26ad7ebdfcbf2678ceac405f -F ext/fts5/fts5_index.c 47ef0002b49b1dba5d5a49c8f2b02160a146a4ff +F ext/fts5/fts5_index.c ffb95101cab310700ccedd641f4ac8a92b1bace8 F ext/fts5/fts5_main.c 520a29136ba07448331f73bdc36d0ffa1e9dcfef F ext/fts5/fts5_storage.c 8038a54a88d3beb94dc7f9db6428a3bc08b718bb F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b9c4aa521156d8ca09151a82a7e80aa8d1d7a313 -R 4d88206e8c01136d0ea377b3eae363fe +P 363b36d50b6f3e3d3e79c538be1167b071a5a710 +R 78a6349126aa9306d06a1fd8711337ce U dan -Z 08a5e9e12273e463d7b7c3c870bc7777 +Z 67153b352bb25ea8149714857c236ba9 diff --git a/manifest.uuid b/manifest.uuid index cac1a13281..621961a6e3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -363b36d50b6f3e3d3e79c538be1167b071a5a710 \ No newline at end of file +ae350bfbfd59f912c469a51bf7d1409f3c8d958a \ No newline at end of file From 1dfaa5c4b2688da792baeb07cba5bc744b9894fe Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 21 Oct 2015 22:07:25 +0000 Subject: [PATCH 14/20] Fix compilation of 'testfixture' with MSVC when the FTS5 and JSON1 extensions are enabled. FossilOrigin-Name: e31aa97a9298e49507256036cfb8fa7517a48461 --- Makefile.msc | 2 -- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 63fbfad6ca..408073c651 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1084,11 +1084,9 @@ TESTEXT = \ $(TOP)\ext\misc\eval.c \ $(TOP)\ext\misc\fileio.c \ $(TOP)\ext\misc\fuzzer.c \ - fts5.c \ $(TOP)\ext\fts5\fts5_tcl.c \ $(TOP)\ext\fts5\fts5_test_mi.c \ $(TOP)\ext\misc\ieee754.c \ - $(TOP)\ext\misc\json1.c \ $(TOP)\ext\misc\nextchar.c \ $(TOP)\ext\misc\percentile.c \ $(TOP)\ext\misc\regexp.c \ diff --git a/manifest b/manifest index 53c1c13210..7f4be2d02f 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Remove\ssome\sbranches\smade\sunreachable\sby\srecent\schanges\sfrom\sfts5. -D 2015-10-21T20:56:27.613 +C Fix\scompilation\sof\s'testfixture'\swith\sMSVC\swhen\sthe\sFTS5\sand\sJSON1\sextensions\sare\senabled. +D 2015-10-21T22:07:25.256 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 4eb750e0fdf52050a06d881e1b060f4bb116ed7e +F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION a47917b59f38b632b3a8662d14fd20f94956bdd0 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 363b36d50b6f3e3d3e79c538be1167b071a5a710 -R 78a6349126aa9306d06a1fd8711337ce -U dan -Z 67153b352bb25ea8149714857c236ba9 +P ae350bfbfd59f912c469a51bf7d1409f3c8d958a +R 94370da87418177dbfd07035771f078a +U mistachkin +Z b64a69f65dcbfbb052541ed7b4c602d1 diff --git a/manifest.uuid b/manifest.uuid index 621961a6e3..fdefa58cb3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ae350bfbfd59f912c469a51bf7d1409f3c8d958a \ No newline at end of file +e31aa97a9298e49507256036cfb8fa7517a48461 \ No newline at end of file From 16158eeb49f6de3a373cae5b41a4bbf3976432d7 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 21 Oct 2015 22:08:36 +0000 Subject: [PATCH 15/20] Fix harmless compiler warnings in FTS5. FossilOrigin-Name: aa4e01ea1af327d1f8398ebea1c5bacc46698c3d --- ext/fts5/fts5Int.h | 1 - ext/fts5/fts5_index.c | 4 ++++ ext/fts5/fts5_vocab.c | 2 +- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 76b3ac3928..8626962067 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -225,7 +225,6 @@ struct Fts5Buffer { }; int sqlite3Fts5BufferSize(int*, Fts5Buffer*, int); -int sqlite3Fts5BufferGrow(int*, Fts5Buffer*, int); void sqlite3Fts5BufferAppendVarint(int*, Fts5Buffer*, i64); void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, int, const u8*); void sqlite3Fts5BufferAppendString(int *, Fts5Buffer*, const char*); diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 6285fa9af3..e70bc85351 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -5335,9 +5335,11 @@ int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){ Fts5IndexIter *pIter; /* Used to iterate through entire index */ Fts5Structure *pStruct; /* Index structure */ +#ifdef SQLITE_DEBUG /* Used by extra internal tests only run if NDEBUG is not defined */ u64 cksum3 = 0; /* Checksum based on contents of indexes */ Fts5Buffer term = {0,0,0}; /* Buffer used to hold most recent term */ +#endif /* Load the FTS index structure */ pStruct = fts5StructureRead(p); @@ -5393,7 +5395,9 @@ int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){ if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT; fts5StructureRelease(pStruct); +#ifdef SQLITE_DEBUG fts5BufferFree(&term); +#endif fts5BufferFree(&poslist); return fts5IndexReturn(p); } diff --git a/ext/fts5/fts5_vocab.c b/ext/fts5/fts5_vocab.c index 1d13b9cd63..860cfedb9b 100644 --- a/ext/fts5/fts5_vocab.c +++ b/ext/fts5/fts5_vocab.c @@ -180,7 +180,7 @@ static int fts5VocabInitVtab( const char *zType = bDb ? argv[5] : argv[4]; int nDb = (int)strlen(zDb)+1; int nTab = (int)strlen(zTab)+1; - int eType; + int eType = 0; rc = fts5VocabTableType(zType, pzErr, &eType); if( rc==SQLITE_OK ){ diff --git a/manifest b/manifest index 7f4be2d02f..253f2f9505 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompilation\sof\s'testfixture'\swith\sMSVC\swhen\sthe\sFTS5\sand\sJSON1\sextensions\sare\senabled. -D 2015-10-21T22:07:25.256 +C Fix\sharmless\scompiler\swarnings\sin\sFTS5. +D 2015-10-21T22:08:36.772 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4 @@ -103,13 +103,13 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 8b9a13b309b180e9fb88ea5666c0d8d73c6102d9 -F ext/fts5/fts5Int.h dfe8390b65e84846e1bd7a2fccc076d350e83f8a +F ext/fts5/fts5Int.h 06594fd3e5a3c74da6df9141e165975dc0ea6ef4 F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 1e49512a535045e621246dc7f4f65f3593fa0fc2 F ext/fts5/fts5_config.c 88a77f5d5e4dfbb2355b8f6cc9969b7f02d94685 F ext/fts5/fts5_expr.c 28b15c9ae296204bc0a2e5cf7a667d840a9d2900 F ext/fts5/fts5_hash.c a9d4c1efebc2a91d26ad7ebdfcbf2678ceac405f -F ext/fts5/fts5_index.c ffb95101cab310700ccedd641f4ac8a92b1bace8 +F ext/fts5/fts5_index.c 2bd3cb65b36160f7b411e70c4360d0619c965e4e F ext/fts5/fts5_main.c 520a29136ba07448331f73bdc36d0ffa1e9dcfef F ext/fts5/fts5_storage.c 8038a54a88d3beb94dc7f9db6428a3bc08b718bb F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd @@ -117,7 +117,7 @@ F ext/fts5/fts5_test_mi.c e96be827aa8f571031e65e481251dc1981d608bf F ext/fts5/fts5_tokenize.c 12c5d925286491a71bb3dad7c8924ce9cfd18320 F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 -F ext/fts5/fts5_vocab.c fc319264ebbf1b4518afd9cacd3801ac526536d8 +F ext/fts5/fts5_vocab.c 3742d0abfe8aa8c3cb4a7df56aa38f2e3c3fb1c2 F ext/fts5/fts5parse.y e83dca6028e3309178d05b5bd920e372dc295d35 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl 51f7ef3af444b89c6f6ce3896a0ac349ff4e996d @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ae350bfbfd59f912c469a51bf7d1409f3c8d958a -R 94370da87418177dbfd07035771f078a +P e31aa97a9298e49507256036cfb8fa7517a48461 +R 606f7dfef62137a51a41fcb520dc155f U mistachkin -Z b64a69f65dcbfbb052541ed7b4c602d1 +Z be7e8557e6be3b3a5f61a53f0769e842 diff --git a/manifest.uuid b/manifest.uuid index fdefa58cb3..0399ec5e0b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e31aa97a9298e49507256036cfb8fa7517a48461 \ No newline at end of file +aa4e01ea1af327d1f8398ebea1c5bacc46698c3d \ No newline at end of file From 7ef855f156175964bb2d193208776044144b8f32 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 22 Oct 2015 18:06:40 +0000 Subject: [PATCH 16/20] Alternate compiler warning fix for sqlite3StatusHighwater. FossilOrigin-Name: 4315d20200d578c9252dcb26e60739063a8eff1d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/status.c | 21 ++++++++++++--------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 253f2f9505..9f8c896ecd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sFTS5. -D 2015-10-21T22:08:36.772 +C Alternate\scompiler\swarning\sfix\sfor\ssqlite3StatusHighwater. +D 2015-10-22T18:06:40.381 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4 @@ -345,7 +345,7 @@ F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 4b66e3e3435da4b4c8c83696d0349f0c503b3924 F src/sqliteInt.h 1ad779ee62efee60494af0a75d8d45592f9f53c3 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 -F src/status.c 286f6398a4d2cd1e8ff0771e3d30f8dddb4768ea +F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e F src/tclsqlite.c d9439b6a910985b7fff43ba6756bcef00de22649 F src/test1.c 8fff9c5aa63d6490f516d018b70c12a9cb9a4d8a @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e31aa97a9298e49507256036cfb8fa7517a48461 -R 606f7dfef62137a51a41fcb520dc155f +P aa4e01ea1af327d1f8398ebea1c5bacc46698c3d +R a22db3919509c137f252ea9c4c395816 U mistachkin -Z be7e8557e6be3b3a5f61a53f0769e842 +Z cd96591ebe18ee957344d1fc4f75aaa9 diff --git a/manifest.uuid b/manifest.uuid index 0399ec5e0b..48569933f6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aa4e01ea1af327d1f8398ebea1c5bacc46698c3d \ No newline at end of file +4315d20200d578c9252dcb26e60739063a8eff1d \ No newline at end of file diff --git a/src/status.c b/src/status.c index a7fddf060f..69f92ff7c6 100644 --- a/src/status.c +++ b/src/status.c @@ -19,15 +19,15 @@ /* ** Variables in which to record status information. */ +#if SQLITE_PTRSIZE>4 +typedef sqlite3_int64 sqlite3StatValueType; +#else +typedef u32 sqlite3StatValueType; +#endif typedef struct sqlite3StatType sqlite3StatType; static SQLITE_WSD struct sqlite3StatType { -#if SQLITE_PTRSIZE>4 - sqlite3_int64 nowValue[10]; /* Current value */ - sqlite3_int64 mxValue[10]; /* Maximum value */ -#else - u32 nowValue[10]; /* Current value */ - u32 mxValue[10]; /* Maximum value */ -#endif + sqlite3StatValueType nowValue[10]; /* Current value */ + sqlite3StatValueType mxValue[10]; /* Maximum value */ } sqlite3Stat = { {0,}, {0,} }; /* @@ -112,7 +112,10 @@ void sqlite3StatusDown(int op, int N){ ** The caller must hold the appropriate mutex. */ void sqlite3StatusHighwater(int op, int X){ + sqlite3StatValueType newValue; wsdStatInit; + assert( X>=0 ); + newValue = (sqlite3StatValueType)X; assert( op>=0 && op=0 && opwsdStat.mxValue[op] ){ - wsdStat.mxValue[op] = X; + if( newValue>wsdStat.mxValue[op] ){ + wsdStat.mxValue[op] = newValue; } } From fb785b2c2b91c49362c8d70e162aac96f85e8534 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 24 Oct 2015 20:31:22 +0000 Subject: [PATCH 17/20] When creating an automatic-index on a sub-query, add a unique integer to the end of each index key to ensure the entire key is unique. Fix for [8a2adec1]. FossilOrigin-Name: bfea226d0d226a046a8bfb7a7a6288850d69bd26 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/where.c | 37 ++++++++++++++++++++++++++++--------- test/autoindex5.test | 21 +++++++++++++++++++++ 4 files changed, 58 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 9f8c896ecd..23d91d98fd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Alternate\scompiler\swarning\sfix\sfor\ssqlite3StatusHighwater. -D 2015-10-22T18:06:40.381 +C When\screating\san\sautomatic-index\son\sa\ssub-query,\sadd\sa\sunique\sinteger\sto\sthe\send\sof\seach\sindex\skey\sto\sensure\sthe\sentire\skey\sis\sunique.\sFix\sfor\s[8a2adec1]. +D 2015-10-24T20:31:22.639 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4 @@ -415,7 +415,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 18b0ed49830cf04fe2d68224b41838a73ac6cd24 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba -F src/where.c 4c4646675e794ac71e701289edefd7cd81bac844 +F src/where.c e3724b7b31d1e13869308ed4125305364f7d823a F src/whereInt.h 7892bb54cf9ca0ae5c7e6094491b94c9286dc647 F src/wherecode.c b924b78acd9e623fb69bfa2cb65cd7d542166dd3 F src/whereexpr.c e63244ca06c503e5f3c5b7f3c9aea0db826089ed @@ -465,7 +465,7 @@ F test/autoindex1.test 14b63a9f1e405fe6d5bfc8c8d00249c2ebaf13ea F test/autoindex2.test af7e595c6864cc6ef5fc38d5db579a3e34940cb8 F test/autoindex3.test a3be0d1a53a7d2edff208a5e442312957047e972 F test/autoindex4.test 49d3cd791a9baa16fb461d7ea3de80d019a819cf -F test/autoindex5.test 6f487290ce2a667c24517191651bfb8c7d86b6dc +F test/autoindex5.test 96f084a5e6024ea07cace5888df3223f3ea86990 F test/autovacuum.test 941892505d2c0f410a0cb5970dfa1c7c4e5f6e74 F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4 F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85 @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P aa4e01ea1af327d1f8398ebea1c5bacc46698c3d -R a22db3919509c137f252ea9c4c395816 -U mistachkin -Z cd96591ebe18ee957344d1fc4f75aaa9 +P 4315d20200d578c9252dcb26e60739063a8eff1d +R dc911a631bba00e9a0808ae6a2dfaef0 +U dan +Z 6491941420be3020676420319ae4eec9 diff --git a/manifest.uuid b/manifest.uuid index 48569933f6..59b584ce70 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4315d20200d578c9252dcb26e60739063a8eff1d \ No newline at end of file +bfea226d0d226a046a8bfb7a7a6288850d69bd26 \ No newline at end of file diff --git a/src/where.c b/src/where.c index af8e2f35fd..0adc698401 100644 --- a/src/where.c +++ b/src/where.c @@ -485,14 +485,20 @@ static LogEst estLog(LogEst N){ ** Convert OP_Column opcodes to OP_Copy in previously generated code. ** ** This routine runs over generated VDBE code and translates OP_Column -** opcodes into OP_Copy, and OP_Rowid into OP_Null, when the table is being -** accessed via co-routine instead of via table lookup. +** opcodes into OP_Copy when the table is being accessed via co-routine +** instead of via table lookup. +** +** If the bIncrRowid parameter is 0, then any OP_Rowid instructions on +** cursor iTabCur are transformed into OP_Null. Or, if bIncrRowid is non-zero, +** then each OP_Rowid is transformed into an instruction to increment the +** value stored in its output register. */ static void translateColumnToCopy( Vdbe *v, /* The VDBE containing code to translate */ int iStart, /* Translate from this opcode to the end */ int iTabCur, /* OP_Column/OP_Rowid references to this table */ - int iRegister /* The first column is in this register */ + int iRegister, /* The first column is in this register */ + int bIncrRowid /* If non-zero, transform OP_rowid to OP_AddImm(1) */ ){ VdbeOp *pOp = sqlite3VdbeGetOp(v, iStart); int iEnd = sqlite3VdbeCurrentAddr(v); @@ -504,9 +510,16 @@ static void translateColumnToCopy( pOp->p2 = pOp->p3; pOp->p3 = 0; }else if( pOp->opcode==OP_Rowid ){ - pOp->opcode = OP_Null; - pOp->p1 = 0; - pOp->p3 = 0; + if( bIncrRowid ){ + /* Increment the value stored in the P2 operand of the OP_Rowid. */ + pOp->opcode = OP_AddImm; + pOp->p1 = pOp->p2; + pOp->p2 = 1; + }else{ + pOp->opcode = OP_Null; + pOp->p1 = 0; + pOp->p3 = 0; + } } } } @@ -614,6 +627,8 @@ static void constructAutomaticIndex( Expr *pPartial = 0; /* Partial Index Expression */ int iContinue = 0; /* Jump here to skip excluded rows */ struct SrcList_item *pTabItem; /* FROM clause term being indexed */ + int addrCounter; /* Address where integer counter is initialized */ + int regBase; /* Array of registers where record is assembled */ /* Generate code to skip over the creation and initialization of the ** transient index on 2nd and subsequent iterations of the loop. */ @@ -742,6 +757,7 @@ static void constructAutomaticIndex( pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom]; if( pTabItem->fg.viaCoroutine ){ int regYield = pTabItem->regReturn; + addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0); sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub); addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield); VdbeCoverage(v); @@ -755,12 +771,15 @@ static void constructAutomaticIndex( pLoop->wsFlags |= WHERE_PARTIALIDX; } regRecord = sqlite3GetTempReg(pParse); - sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0); + regBase = sqlite3GenerateIndexKey( + pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0 + ); sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord); sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue); if( pTabItem->fg.viaCoroutine ){ - translateColumnToCopy(v, addrTop, pLevel->iTabCur, pTabItem->regResult); + sqlite3VdbeChangeP2(v, addrCounter, regBase+n); + translateColumnToCopy(v, addrTop, pLevel->iTabCur, pTabItem->regResult, 1); sqlite3VdbeGoto(v, addrTop); pTabItem->fg.viaCoroutine = 0; }else{ @@ -4509,7 +4528,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ */ if( pTabItem->fg.viaCoroutine && !db->mallocFailed ){ translateColumnToCopy(v, pLevel->addrBody, pLevel->iTabCur, - pTabItem->regResult); + pTabItem->regResult, 0); continue; } diff --git a/test/autoindex5.test b/test/autoindex5.test index 2d5fad2eda..649ae123a4 100644 --- a/test/autoindex5.test +++ b/test/autoindex5.test @@ -17,6 +17,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix autoindex5 # Schema is from the Debian security database # @@ -103,6 +104,26 @@ do_execsql_test autoindex5-1.1 { OR sp.release = 'wheezy' OR sp.release = 'squeeze' ) ORDER BY sp.name, st.bug_name, sp.release, sp.subrelease; } {/SEARCH SUBQUERY 2 USING AUTOMATIC COVERING INDEX .bug_name=/} + +#------------------------------------------------------------------------- +# Test that ticket [8a2adec1] has been fixed. +# +do_execsql_test 2.1 { + CREATE TABLE one(o); + INSERT INTO one DEFAULT VALUES; + + CREATE TABLE t1(x, z); + INSERT INTO t1 VALUES('aaa', 4.0); + INSERT INTO t1 VALUES('aaa', 4.0); + CREATE VIEW vvv AS + SELECT * FROM t1 + UNION ALL + SELECT 0, 0 WHERE 0; + + SELECT ( + SELECT sum(z) FROM vvv WHERE x='aaa' + ) FROM one; +} {8.0} finish_test From 56d90be18309072182e9b8bb22a0d26286ab0ffb Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 26 Oct 2015 12:55:56 +0000 Subject: [PATCH 18/20] Remove an unreachable branch in malloc.c. FossilOrigin-Name: a36b7fe92372a13ff0b6e08f1704496045c6f62a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/malloc.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 23d91d98fd..d5c461ba4f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\screating\san\sautomatic-index\son\sa\ssub-query,\sadd\sa\sunique\sinteger\sto\sthe\send\sof\seach\sindex\skey\sto\sensure\sthe\sentire\skey\sis\sunique.\sFix\sfor\s[8a2adec1]. -D 2015-10-24T20:31:22.639 +C Remove\san\sunreachable\sbranch\sin\smalloc.c. +D 2015-10-26T12:55:56.255 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4 @@ -304,7 +304,7 @@ F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c d344a95d60c24e2f490ee59db9784b1b17439012 F src/loadext.c 18586e45a215325f15096821e9c082035d4fb810 F src/main.c fec97668771438033a7559883401067b139729e1 -F src/malloc.c 0a2e42b835c980ba91c17866e9b6a9810ff54d75 +F src/malloc.c 337bbe9c7d436ef9b7d06b5dd10bbfc8f3025972 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 52485a88f22649c3b3b4f3eb15760505d49ccf71 F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4315d20200d578c9252dcb26e60739063a8eff1d -R dc911a631bba00e9a0808ae6a2dfaef0 -U dan -Z 6491941420be3020676420319ae4eec9 +P bfea226d0d226a046a8bfb7a7a6288850d69bd26 +R 71bd1944f2afa43b9641de175600fe9d +U drh +Z a960b5da2c918e1209a303de326b24d2 diff --git a/manifest.uuid b/manifest.uuid index 59b584ce70..ca08f0beac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bfea226d0d226a046a8bfb7a7a6288850d69bd26 \ No newline at end of file +a36b7fe92372a13ff0b6e08f1704496045c6f62a \ No newline at end of file diff --git a/src/malloc.c b/src/malloc.c index 32047a2a5f..a4968aaa2f 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -455,7 +455,7 @@ void sqlite3_free(void *p){ ** *db->pnBytesFreed. */ static SQLITE_NOINLINE void measureAllocationSize(sqlite3 *db, void *p){ - if( p ) *db->pnBytesFreed += sqlite3DbMallocSize(db,p); + *db->pnBytesFreed += sqlite3DbMallocSize(db,p); } /* From 46e6ea028283946b5bb0b2c8417944a5a0d649ee Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 26 Oct 2015 14:41:35 +0000 Subject: [PATCH 19/20] When compiling with SQLITE_HAS_CODEC, honor the hexkey= query parameter on URI pathnames in sqlite3_open_v2(). FossilOrigin-Name: e0ce3fc089c2523b8b718b4a4f9ab8c4d0432fc7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index d5c461ba4f..2fa695a375 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunreachable\sbranch\sin\smalloc.c. -D 2015-10-26T12:55:56.255 +C When\scompiling\swith\sSQLITE_HAS_CODEC,\shonor\sthe\shexkey=\squery\sparameter\son\nURI\spathnames\sin\ssqlite3_open_v2(). +D 2015-10-26T14:41:35.868 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4 @@ -303,7 +303,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c d344a95d60c24e2f490ee59db9784b1b17439012 F src/loadext.c 18586e45a215325f15096821e9c082035d4fb810 -F src/main.c fec97668771438033a7559883401067b139729e1 +F src/main.c 1cae029707c323292b5691e4d0a4c5c44561c877 F src/malloc.c 337bbe9c7d436ef9b7d06b5dd10bbfc8f3025972 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 52485a88f22649c3b3b4f3eb15760505d49ccf71 @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P bfea226d0d226a046a8bfb7a7a6288850d69bd26 -R 71bd1944f2afa43b9641de175600fe9d +P a36b7fe92372a13ff0b6e08f1704496045c6f62a +R b06039a97a9cf0855388e699ea924396 U drh -Z a960b5da2c918e1209a303de326b24d2 +Z 746928cfbf856735825bc415cbbeefac diff --git a/manifest.uuid b/manifest.uuid index ca08f0beac..cca9fc08e5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a36b7fe92372a13ff0b6e08f1704496045c6f62a \ No newline at end of file +e0ce3fc089c2523b8b718b4a4f9ab8c4d0432fc7 \ No newline at end of file diff --git a/src/main.c b/src/main.c index ef2fa66ec3..9dd05cdf1d 100644 --- a/src/main.c +++ b/src/main.c @@ -2954,6 +2954,21 @@ opendb_out: void *pArg = sqlite3GlobalConfig.pSqllogArg; sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0); } +#endif +#if defined(SQLITE_HAS_CODEC) + if( rc==SQLITE_OK ){ + const char *zHexKey = sqlite3_uri_parameter(zOpen, "hexkey"); + if( zHexKey && zHexKey[0] ){ + u8 iByte; + int i; + char zKey[40]; + for(i=0, iByte=0; i Date: Mon, 26 Oct 2015 14:54:32 +0000 Subject: [PATCH 20/20] Fix a C99-ism and a harmless compiler warning. FossilOrigin-Name: 138783b553602a055b3efdeac5947cf5ccd76b5d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/mem1.c | 3 ++- src/where.c | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 2fa695a375..fa40bac9a9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\scompiling\swith\sSQLITE_HAS_CODEC,\shonor\sthe\shexkey=\squery\sparameter\son\nURI\spathnames\sin\ssqlite3_open_v2(). -D 2015-10-26T14:41:35.868 +C Fix\sa\sC99-ism\sand\sa\sharmless\scompiler\swarning. +D 2015-10-26T14:54:32.296 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4 @@ -306,7 +306,7 @@ F src/loadext.c 18586e45a215325f15096821e9c082035d4fb810 F src/main.c 1cae029707c323292b5691e4d0a4c5c44561c877 F src/malloc.c 337bbe9c7d436ef9b7d06b5dd10bbfc8f3025972 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 -F src/mem1.c 52485a88f22649c3b3b4f3eb15760505d49ccf71 +F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a F src/mem5.c c1ab1153bd6443bdf6f71e4213c6fb31221b9eb7 @@ -415,7 +415,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 18b0ed49830cf04fe2d68224b41838a73ac6cd24 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba -F src/where.c e3724b7b31d1e13869308ed4125305364f7d823a +F src/where.c 7b9e8d72e3eb52cec98617a5d6a029191bf1bcc8 F src/whereInt.h 7892bb54cf9ca0ae5c7e6094491b94c9286dc647 F src/wherecode.c b924b78acd9e623fb69bfa2cb65cd7d542166dd3 F src/whereexpr.c e63244ca06c503e5f3c5b7f3c9aea0db826089ed @@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a36b7fe92372a13ff0b6e08f1704496045c6f62a -R b06039a97a9cf0855388e699ea924396 +P e0ce3fc089c2523b8b718b4a4f9ab8c4d0432fc7 +R 2133c21a41df33b66ecf042f1953a26d U drh -Z 746928cfbf856735825bc415cbbeefac +Z 7527955b7ce1cc200d4d1a233d6e1b75 diff --git a/manifest.uuid b/manifest.uuid index cca9fc08e5..3da3b3d71f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e0ce3fc089c2523b8b718b4a4f9ab8c4d0432fc7 \ No newline at end of file +138783b553602a055b3efdeac5947cf5ccd76b5d \ No newline at end of file diff --git a/src/mem1.c b/src/mem1.c index da6ae33e4c..b960ccfd47 100644 --- a/src/mem1.c +++ b/src/mem1.c @@ -171,11 +171,12 @@ static void sqlite3MemFree(void *pPrior){ ** or xRealloc(). */ static int sqlite3MemSize(void *pPrior){ - assert( pPrior!=0 ); #ifdef SQLITE_MALLOCSIZE + assert( pPrior!=0 ); return (int)SQLITE_MALLOCSIZE(pPrior); #else sqlite3_int64 *p; + assert( pPrior!=0 ); p = (sqlite3_int64*)pPrior; p--; return (int)p[0]; diff --git a/src/where.c b/src/where.c index 0adc698401..f079fb02ce 100644 --- a/src/where.c +++ b/src/where.c @@ -627,7 +627,7 @@ static void constructAutomaticIndex( Expr *pPartial = 0; /* Partial Index Expression */ int iContinue = 0; /* Jump here to skip excluded rows */ struct SrcList_item *pTabItem; /* FROM clause term being indexed */ - int addrCounter; /* Address where integer counter is initialized */ + int addrCounter = 0; /* Address where integer counter is initialized */ int regBase; /* Array of registers where record is assembled */ /* Generate code to skip over the creation and initialization of the