1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Update sessions branch with trunk changes.

FossilOrigin-Name: 3f4848a871a4229ff6951eefaf7673de46d2c43f
This commit is contained in:
dan
2012-05-12 11:50:41 +00:00
15 changed files with 417 additions and 213 deletions

View File

@@ -3945,7 +3945,7 @@ void sqlite3Fts3DoclistPrev(
int nDoclist, /* Length of aDoclist in bytes */ int nDoclist, /* Length of aDoclist in bytes */
char **ppIter, /* IN/OUT: Iterator pointer */ char **ppIter, /* IN/OUT: Iterator pointer */
sqlite3_int64 *piDocid, /* IN/OUT: Docid pointer */ sqlite3_int64 *piDocid, /* IN/OUT: Docid pointer */
int *pnList, /* IN/OUT: List length pointer */ int *pnList, /* OUT: List length pointer */
u8 *pbEof /* OUT: End-of-file flag */ u8 *pbEof /* OUT: End-of-file flag */
){ ){
char *p = *ppIter; char *p = *ppIter;
@@ -3992,6 +3992,41 @@ void sqlite3Fts3DoclistPrev(
} }
} }
/*
** Iterate forwards through a doclist.
*/
void sqlite3Fts3DoclistNext(
int bDescIdx, /* True if the doclist is desc */
char *aDoclist, /* Pointer to entire doclist */
int nDoclist, /* Length of aDoclist in bytes */
char **ppIter, /* IN/OUT: Iterator pointer */
sqlite3_int64 *piDocid, /* IN/OUT: Docid pointer */
u8 *pbEof /* OUT: End-of-file flag */
){
char *p = *ppIter;
assert( nDoclist>0 );
assert( *pbEof==0 );
assert( p || *piDocid==0 );
assert( !p || (p>=aDoclist && p<=&aDoclist[nDoclist]) );
if( p==0 ){
p = aDoclist;
p += sqlite3Fts3GetVarint(p, piDocid);
}else{
fts3PoslistCopy(0, &p);
if( p>=&aDoclist[nDoclist] ){
*pbEof = 1;
}else{
sqlite3_int64 iVar;
p += sqlite3Fts3GetVarint(p, &iVar);
*piDocid += ((bDescIdx ? -1 : 1) * iVar);
}
}
*ppIter = p;
}
/* /*
** Attempt to move the phrase iterator to point to the next matching docid. ** Attempt to move the phrase iterator to point to the next matching docid.
** If an error occurs, return an SQLite error code. Otherwise, return ** If an error occurs, return an SQLite error code. Otherwise, return
@@ -5147,26 +5182,87 @@ int sqlite3Fts3EvalPhraseStats(
** This function works regardless of whether or not the phrase is deferred, ** This function works regardless of whether or not the phrase is deferred,
** incremental, or neither. ** incremental, or neither.
*/ */
char *sqlite3Fts3EvalPhrasePoslist( int sqlite3Fts3EvalPhrasePoslist(
Fts3Cursor *pCsr, /* FTS3 cursor object */ Fts3Cursor *pCsr, /* FTS3 cursor object */
Fts3Expr *pExpr, /* Phrase to return doclist for */ Fts3Expr *pExpr, /* Phrase to return doclist for */
int iCol /* Column to return position list for */ int iCol, /* Column to return position list for */
char **ppOut /* OUT: Pointer to position list */
){ ){
Fts3Phrase *pPhrase = pExpr->pPhrase; Fts3Phrase *pPhrase = pExpr->pPhrase;
Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab; Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
char *pIter = pPhrase->doclist.pList; char *pIter;
int iThis; int iThis;
sqlite3_int64 iDocid;
/* If this phrase is applies specifically to some column other than
** column iCol, return a NULL pointer. */
*ppOut = 0;
assert( iCol>=0 && iCol<pTab->nColumn ); assert( iCol>=0 && iCol<pTab->nColumn );
if( !pIter if( (pPhrase->iColumn<pTab->nColumn && pPhrase->iColumn!=iCol) ){
|| pExpr->bEof return SQLITE_OK;
|| pExpr->iDocid!=pCsr->iPrevId
|| (pPhrase->iColumn<pTab->nColumn && pPhrase->iColumn!=iCol)
){
return 0;
} }
assert( pPhrase->doclist.nList>0 ); iDocid = pExpr->iDocid;
pIter = pPhrase->doclist.pList;
if( iDocid!=pCsr->iPrevId || pExpr->bEof ){
int bDescDoclist = pTab->bDescIdx; /* For DOCID_CMP macro */
int bOr = 0;
u8 bEof = 0;
Fts3Expr *p;
/* Check if this phrase descends from an OR expression node. If not,
** return NULL. Otherwise, the entry that corresponds to docid
** pCsr->iPrevId may lie earlier in the doclist buffer. */
for(p=pExpr->pParent; p; p=p->pParent){
if( p->eType==FTSQUERY_OR ) bOr = 1;
}
if( bOr==0 ) return SQLITE_OK;
/* This is the descendent of an OR node. In this case we cannot use
** an incremental phrase. Load the entire doclist for the phrase
** into memory in this case. */
if( pPhrase->bIncr ){
int rc = SQLITE_OK;
int bEofSave = pExpr->bEof;
fts3EvalRestart(pCsr, pExpr, &rc);
while( rc==SQLITE_OK && !pExpr->bEof ){
fts3EvalNextRow(pCsr, pExpr, &rc);
if( bEofSave==0 && pExpr->iDocid==iDocid ) break;
}
pIter = pPhrase->doclist.pList;
assert( rc!=SQLITE_OK || pPhrase->bIncr==0 );
if( rc!=SQLITE_OK ) return rc;
}
if( pExpr->bEof ){
pIter = 0;
iDocid = 0;
}
bEof = (pPhrase->doclist.nAll==0);
assert( bDescDoclist==0 || bDescDoclist==1 );
assert( pCsr->bDesc==0 || pCsr->bDesc==1 );
if( pCsr->bDesc==bDescDoclist ){
int dummy;
while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){
sqlite3Fts3DoclistPrev(
bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
&pIter, &iDocid, &dummy, &bEof
);
}
}else{
while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
sqlite3Fts3DoclistNext(
bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
&pIter, &iDocid, &bEof
);
}
}
if( bEof || iDocid!=pCsr->iPrevId ) pIter = 0;
}
if( pIter==0 ) return SQLITE_OK;
if( *pIter==0x01 ){ if( *pIter==0x01 ){
pIter++; pIter++;
pIter += sqlite3Fts3GetVarint32(pIter, &iThis); pIter += sqlite3Fts3GetVarint32(pIter, &iThis);
@@ -5180,7 +5276,8 @@ char *sqlite3Fts3EvalPhrasePoslist(
pIter += sqlite3Fts3GetVarint32(pIter, &iThis); pIter += sqlite3Fts3GetVarint32(pIter, &iThis);
} }
return ((iCol==iThis)?pIter:0); *ppOut = ((iCol==iThis)?pIter:0);
return SQLITE_OK;
} }
/* /*

View File

@@ -535,7 +535,7 @@ int sqlite3Fts3MsrIncrStart(
Fts3Table*, Fts3MultiSegReader*, int, const char*, int); Fts3Table*, Fts3MultiSegReader*, int, const char*, int);
int sqlite3Fts3MsrIncrNext( int sqlite3Fts3MsrIncrNext(
Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *); Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *);
char *sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol); int sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol, char **);
int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *); int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);
int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr); int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);

View File

@@ -360,10 +360,11 @@ static int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){
SnippetIter *p = (SnippetIter *)ctx; SnippetIter *p = (SnippetIter *)ctx;
SnippetPhrase *pPhrase = &p->aPhrase[iPhrase]; SnippetPhrase *pPhrase = &p->aPhrase[iPhrase];
char *pCsr; char *pCsr;
int rc;
pPhrase->nToken = pExpr->pPhrase->nToken; pPhrase->nToken = pExpr->pPhrase->nToken;
rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr);
pCsr = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol); assert( rc==SQLITE_OK || pCsr==0 );
if( pCsr ){ if( pCsr ){
int iFirst = 0; int iFirst = 0;
pPhrase->pList = pCsr; pPhrase->pList = pCsr;
@@ -374,10 +375,12 @@ static int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){
pPhrase->iHead = iFirst; pPhrase->iHead = iFirst;
pPhrase->iTail = iFirst; pPhrase->iTail = iFirst;
}else{ }else{
assert( pPhrase->pList==0 && pPhrase->pHead==0 && pPhrase->pTail==0 ); assert( rc!=SQLITE_OK || (
pPhrase->pList==0 && pPhrase->pHead==0 && pPhrase->pTail==0
));
} }
return SQLITE_OK; return rc;
} }
/* /*
@@ -770,13 +773,14 @@ static int fts3ExprLocalHitsCb(
int iPhrase, /* Phrase number */ int iPhrase, /* Phrase number */
void *pCtx /* Pointer to MatchInfo structure */ void *pCtx /* Pointer to MatchInfo structure */
){ ){
int rc = SQLITE_OK;
MatchInfo *p = (MatchInfo *)pCtx; MatchInfo *p = (MatchInfo *)pCtx;
int iStart = iPhrase * p->nCol * 3; int iStart = iPhrase * p->nCol * 3;
int i; int i;
for(i=0; i<p->nCol; i++){ for(i=0; i<p->nCol && rc==SQLITE_OK; i++){
char *pCsr; char *pCsr;
pCsr = sqlite3Fts3EvalPhrasePoslist(p->pCursor, pExpr, i); rc = sqlite3Fts3EvalPhrasePoslist(p->pCursor, pExpr, i, &pCsr);
if( pCsr ){ if( pCsr ){
p->aMatchinfo[iStart+i*3] = fts3ColumnlistCount(&pCsr); p->aMatchinfo[iStart+i*3] = fts3ColumnlistCount(&pCsr);
}else{ }else{
@@ -784,7 +788,7 @@ static int fts3ExprLocalHitsCb(
} }
} }
return SQLITE_OK; return rc;
} }
static int fts3MatchinfoCheck( static int fts3MatchinfoCheck(
@@ -945,8 +949,10 @@ static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){
int nLive = 0; /* Number of iterators in aIter not at EOF */ int nLive = 0; /* Number of iterators in aIter not at EOF */
for(i=0; i<pInfo->nPhrase; i++){ for(i=0; i<pInfo->nPhrase; i++){
int rc;
LcsIterator *pIt = &aIter[i]; LcsIterator *pIt = &aIter[i];
pIt->pRead = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol); rc = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol, &pIt->pRead);
if( rc!=SQLITE_OK ) return rc;
if( pIt->pRead ){ if( pIt->pRead ){
pIt->iPos = pIt->iPosOffset; pIt->iPos = pIt->iPosOffset;
fts3LcsIteratorAdvance(&aIter[i]); fts3LcsIteratorAdvance(&aIter[i]);
@@ -1298,9 +1304,10 @@ static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){
int iTerm; /* For looping through nTerm phrase terms */ int iTerm; /* For looping through nTerm phrase terms */
char *pList; /* Pointer to position list for phrase */ char *pList; /* Pointer to position list for phrase */
int iPos = 0; /* First position in position-list */ int iPos = 0; /* First position in position-list */
int rc;
UNUSED_PARAMETER(iPhrase); UNUSED_PARAMETER(iPhrase);
pList = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol); rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pList);
nTerm = pExpr->pPhrase->nToken; nTerm = pExpr->pPhrase->nToken;
if( pList ){ if( pList ){
fts3GetDeltaPosition(&pList, &iPos); fts3GetDeltaPosition(&pList, &iPos);
@@ -1314,7 +1321,7 @@ static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){
pT->iPos = iPos; pT->iPos = iPos;
} }
return SQLITE_OK; return rc;
} }
/* /*

View File

@@ -1,5 +1,5 @@
C Merge\sin\sthe\swindows\sAV-defense\senhancements\sfor\sopen()\sand\sthe\stable\nconstraint\sparser\sfixes\sfor\slegacy\sschemas,\sall\sfrom\strunk. C Update\ssessions\sbranch\swith\strunk\schanges.
D 2012-05-10T12:17:18.151 D 2012-05-12T11:50:41.131
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -55,16 +55,16 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
F ext/fts3/fts3.c 111626ce72b0df93f509ebd14ce31804fed24be0 F ext/fts3/fts3.c a7adf6747d1fdd627ecd421c1709996741ca6693
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
F ext/fts3/fts3Int.h 5fd2ec4e47faf17bf4a508d6b8ec5fc0f2c80bff F ext/fts3/fts3Int.h aca752b99c15ee738f5bcf0910eafb9e4aeb1b97
F ext/fts3/fts3_aux.c 5205182bd8f372782597888156404766edf5781e F ext/fts3/fts3_aux.c 5205182bd8f372782597888156404766edf5781e
F ext/fts3/fts3_expr.c dbc7ba4c3a6061adde0f38ed8e9b349568299551 F ext/fts3/fts3_expr.c dbc7ba4c3a6061adde0f38ed8e9b349568299551
F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914
F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec
F ext/fts3/fts3_icu.c 62ec177c55f6a5c6e994dd3e5fd3194b4045c347 F ext/fts3/fts3_icu.c 62ec177c55f6a5c6e994dd3e5fd3194b4045c347
F ext/fts3/fts3_porter.c a465b49fcb8249a755792f87516eff182efa42b3 F ext/fts3/fts3_porter.c a465b49fcb8249a755792f87516eff182efa42b3
F ext/fts3/fts3_snippet.c 51a3a34c217e24678a133782c1dfb6f2f70fe559 F ext/fts3/fts3_snippet.c bf67520ae9d2352a65368ed101729ff701c08808
F ext/fts3/fts3_term.c a521f75132f9a495bdca1bdd45949b3191c52763 F ext/fts3/fts3_term.c a521f75132f9a495bdca1bdd45949b3191c52763
F ext/fts3/fts3_test.c 348f7d08cae05285794e23dc4fe8b8fdf66e264a F ext/fts3/fts3_test.c 348f7d08cae05285794e23dc4fe8b8fdf66e264a
F ext/fts3/fts3_tokenizer.c 3da7254a9881f7e270ab28e2004e0d22b3212bce F ext/fts3/fts3_tokenizer.c 3da7254a9881f7e270ab28e2004e0d22b3212bce
@@ -231,7 +231,7 @@ F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9
F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0
F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f
F src/test_spellfix.c 495535f3eb57acdc384572da570e869bb1834bf4 F src/test_spellfix.c 495535f3eb57acdc384572da570e869bb1834bf4
F src/test_stat.c d7035cfcc0ff1f93c000b621f36524318e004e11 F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935
F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd
F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae
F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
@@ -259,7 +259,7 @@ F src/vtab.c ae657b1c22cff43863458e768a44f915c07bc0e4
F src/wal.c 7bb3ad807afc7973406c805d5157ec7a2f65e146 F src/wal.c 7bb3ad807afc7973406c805d5157ec7a2f65e146
F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
F src/where.c 8e9f01cd1604aa21cfa8e0258b7101e05082fa98 F src/where.c 24c7494d8875ead994b4dfe5461340c27fd424ca
F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
@@ -294,7 +294,7 @@ F test/autoindex1.test 058d0b331ae6840a61bbee910d8cbae27bfd5991
F test/autovacuum.test fcaf4616ae5bb18098db1cb36262565e5c841c3c F test/autovacuum.test fcaf4616ae5bb18098db1cb36262565e5c841c3c
F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4 F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4
F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85 F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85
F test/backcompat.test 94778872ed9f6158ba1b8534264d3413ae7e27f8 F test/backcompat.test bccbc64769d9c755ad65ee7c2f7336b86e3cc0c8
F test/backup.test 717346db953e9e435c2a94916e4af177330d60d3 F test/backup.test 717346db953e9e435c2a94916e4af177330d60d3
F test/backup2.test 34986ef926ea522911a51dfdb2f8e99b7b75ebcf F test/backup2.test 34986ef926ea522911a51dfdb2f8e99b7b75ebcf
F test/backup_ioerr.test 40d208bc9224b666ee3ed423f49bc9062a36a9d0 F test/backup_ioerr.test 40d208bc9224b666ee3ed423f49bc9062a36a9d0
@@ -472,7 +472,7 @@ F test/fts3am.test 218aa6ba0dfc50c7c16b2022aac5c6be593d08d8
F test/fts3an.test a49ccadc07a2f7d646ec1b81bc09da2d85a85b18 F test/fts3an.test a49ccadc07a2f7d646ec1b81bc09da2d85a85b18
F test/fts3ao.test e7b80272efcced57d1d087a9da5c690dd7c21fd9 F test/fts3ao.test e7b80272efcced57d1d087a9da5c690dd7c21fd9
F test/fts3atoken.test 402ef2f7c2fb4b3d4fa0587df6441c1447e799b3 F test/fts3atoken.test 402ef2f7c2fb4b3d4fa0587df6441c1447e799b3
F test/fts3auto.test 868a2afea308d7d8b45ef29fcf022644a9e6d662 F test/fts3auto.test b39f3f51227aea145eae6638690355dbdf9abf18
F test/fts3aux1.test 0b02743955d56fc0d4d66236a26177bd1b726de0 F test/fts3aux1.test 0b02743955d56fc0d4d66236a26177bd1b726de0
F test/fts3b.test e93bbb653e52afde110ad53bbd793f14fe7a8984 F test/fts3b.test e93bbb653e52afde110ad53bbd793f14fe7a8984
F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958 F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958
@@ -637,7 +637,7 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/null.test a8b09b8ed87852742343b33441a9240022108993
F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394 F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394
F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3 F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3
F test/pager1.test eb6d64d2e148dc4bfc6420605bee3717e2d5f10c F test/pager1.test 31fef8ff6d5cbb4643f430e31756312d361ecfdf
F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1
F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f
F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442 F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442
@@ -703,7 +703,7 @@ F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9
F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e
F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de
F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf
F test/shell1.test 7dcd612b0018ddad783647d984fffa76791ffd3d F test/shell1.test cd9f846702d1d471225a988fee590a153be8192c
F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a
F test/shell3.test 9196c42772d575685e722c92b4b39053c6ebba59 F test/shell3.test 9196c42772d575685e722c92b4b39053c6ebba59
F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9 F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9
@@ -739,7 +739,7 @@ F test/tclsqlite.test 2f2aa887763af30641f5561bdc26c5d3fbc73a88
F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2 F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2
F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d
F test/tester.tcl e9e495e68f7c5e0e17561acdfcb59ca6679ff019 F test/tester.tcl f341da6a8982a5d1c521a45c9dd09260d728a147
F test/thread001.test 7cc2ce08f9cde95964736d11e91f9ab610f82f91 F test/thread001.test 7cc2ce08f9cde95964736d11e91f9ab610f82f91
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
@@ -781,6 +781,7 @@ F test/tkt-b1d3a2e531.test 610ef582413171b379652663111b1f996d9f8f78
F test/tkt-b351d95f9.test d14a503c414c5c58fdde3e80f9a3cfef986498c0 F test/tkt-b351d95f9.test d14a503c414c5c58fdde3e80f9a3cfef986498c0
F test/tkt-b72787b1.test a95e8cdad0b98af1853ac7f0afd4ab27b77bf5f3 F test/tkt-b72787b1.test a95e8cdad0b98af1853ac7f0afd4ab27b77bf5f3
F test/tkt-bd484a090c.test 60460bf946f79a79712b71f202eda501ca99b898 F test/tkt-bd484a090c.test 60460bf946f79a79712b71f202eda501ca99b898
F test/tkt-bdc6bbbb38.test fc38bb09bdd440e3513a1f5f98fc60a075182d7d
F test/tkt-c48d99d690.test bed446e3513ae10eec1b86fdd186ef750226c408 F test/tkt-c48d99d690.test bed446e3513ae10eec1b86fdd186ef750226c408
F test/tkt-cbd054fa6b.test bd9fb546f63bc0c79d1776978d059fa51c5b1c63 F test/tkt-cbd054fa6b.test bd9fb546f63bc0c79d1776978d059fa51c5b1c63
F test/tkt-d11f09d36e.test fb44f7961aa6d4b632fb7b9768239832210b5fc7 F test/tkt-d11f09d36e.test fb44f7961aa6d4b632fb7b9768239832210b5fc7
@@ -929,8 +930,8 @@ F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e
F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
F test/vtab_shared.test 82f463886e18d7f8395a4b6167c91815efe54839 F test/vtab_shared.test 82f463886e18d7f8395a4b6167c91815efe54839
F test/wal.test 2fbf4bbd0cb03aff6ada8150f29808c79370d50b F test/wal.test b3d28d655371bf3f6500c679f526e9860544fe70
F test/wal2.test 8871e7fd2c86711ff415a5817d68ea3101a15312 F test/wal2.test d5021064bebfc717fe2bf4db2536ea030b76a773
F test/wal3.test 6504bbf348b2d6dfade64a064f1050fd617e8706 F test/wal3.test 6504bbf348b2d6dfade64a064f1050fd617e8706
F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
F test/wal5.test f58ed4b8b542f71c7441da12fbd769d99b362437 F test/wal5.test f58ed4b8b542f71c7441da12fbd769d99b362437
@@ -1009,7 +1010,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P 0f347fbfc7d8821f56f1ae0d1a9472a375631e65 38bf90af1ede6ee64ef7be66392e895e60c9126e P 323570b8bd52c7e1b0c8c7a0e4f57f6fdebead11 f84d87bcc0e4f6f56d01556b2b1dc27ebef9ce26
R 21dedc1a34649558aea7c289d84ec993 R 638df784a54d2791b773a7681a2d1690
U drh U dan
Z bf3857ddf912fd88e60d600cf99c392f Z 30a906fd51de4488c11598c55a1906ac

View File

@@ -1 +1 @@
323570b8bd52c7e1b0c8c7a0e4f57f6fdebead11 3f4848a871a4229ff6951eefaf7673de46d2c43f

View File

@@ -328,7 +328,7 @@ static int statDecodePage(Btree *pBt, StatPage *p){
getLocalPayload(nUsable, p->flags, nPayload, &nLocal); getLocalPayload(nUsable, p->flags, nPayload, &nLocal);
pCell->nLocal = nLocal; pCell->nLocal = nLocal;
assert( nLocal>=0 ); assert( nLocal>=0 );
assert( nPayload>=nLocal ); assert( nPayload>=(u32)nLocal );
assert( nLocal<=(nUsable-35) ); assert( nLocal<=(nUsable-35) );
if( nPayload>(u32)nLocal ){ if( nPayload>(u32)nLocal ){
int j; int j;

View File

@@ -1725,7 +1725,6 @@ static int isSortingIndex(
&& !referencesOtherTables(pOrderBy, pMaskSet, j, base) && !referencesOtherTables(pOrderBy, pMaskSet, j, base)
){ ){
Column *aCol = pIdx->pTable->aCol; Column *aCol = pIdx->pTable->aCol;
int i;
/* All terms of this index match some prefix of the ORDER BY clause, /* All terms of this index match some prefix of the ORDER BY clause,
** the index is UNIQUE, and no terms on the tail of the ORDER BY ** the index is UNIQUE, and no terms on the tail of the ORDER BY

View File

@@ -251,96 +251,98 @@ do_allbackcompat_test {
# Test that FTS3 tables may be read/written by different versions of # Test that FTS3 tables may be read/written by different versions of
# SQLite. # SQLite.
# #
set contents { ifcapable fts3 {
CREATE VIRTUAL TABLE t1 USING fts3(a, b); set contents {
} CREATE VIRTUAL TABLE t1 USING fts3(a, b);
foreach {num doc} { }
one "jk zm jk eczkjblu urvysbnykk sk gnl jk ttvgf hmjf" foreach {num doc} {
two "jk bnhc jjrxpjkb mjpavjuhw fibokdry igju jk zm zm xh" one "jk zm jk eczkjblu urvysbnykk sk gnl jk ttvgf hmjf"
three "wxe ogttbykvt uhzq xr iaf zf urvysbnykk aayxpmve oacaxgjoo mjpavjuhw" two "jk bnhc jjrxpjkb mjpavjuhw fibokdry igju jk zm zm xh"
four "gazrt jk ephknonq myjp uenvbm wuvajhwqz jk zm xnxhf nvfasfh" three "wxe ogttbykvt uhzq xr iaf zf urvysbnykk aayxpmve oacaxgjoo mjpavjuhw"
five "zm aayxpmve csjqxhgj xnxhf xr jk aayxpmve xnxhf zm zm" four "gazrt jk ephknonq myjp uenvbm wuvajhwqz jk zm xnxhf nvfasfh"
six "sokcyf zm ogyavjvv jk zm fibokdry zm jk igju igju" five "zm aayxpmve csjqxhgj xnxhf xr jk aayxpmve xnxhf zm zm"
seven "vgsld bvgimjik xuprtlyle jk akmikrqyt jk aayxpmve hkfoudzftq ddjj" six "sokcyf zm ogyavjvv jk zm fibokdry zm jk igju igju"
eight "zm uhzq ovkyevlgv zk uenvbm csjqxhgj jk vgsld pgybs jk" seven "vgsld bvgimjik xuprtlyle jk akmikrqyt jk aayxpmve hkfoudzftq ddjj"
nine "zm agmckuiu zexh fibokdry jk uhzq bu tugflixoex xnxhf sk" eight "zm uhzq ovkyevlgv zk uenvbm csjqxhgj jk vgsld pgybs jk"
} { nine "zm agmckuiu zexh fibokdry jk uhzq bu tugflixoex xnxhf sk"
append contents "INSERT INTO t1 VALUES('$num', '$doc');"
}
do_allbackcompat_test {
if {[code1 {set ::sqlite_options(fts3)}]
&& [code2 {set ::sqlite_options(fts3)}]
} { } {
append contents "INSERT INTO t1 VALUES('$num', '$doc');"
do_test backcompat-3.1 { sql1 $contents } {} }
do_allbackcompat_test {
foreach {n q} { if {[code1 {set ::sqlite_options(fts3)}]
1 "SELECT * FROM t1 ORDER BY a, b" && [code2 {set ::sqlite_options(fts3)}]
2 "SELECT rowid FROM t1 WHERE a MATCH 'five'"
3 "SELECT * FROM t1 WHERE a MATCH 'five'"
4 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'"
5 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'"
} { } {
do_test backcompat-3.2 [list sql1 $q] [sql2 $q]
} do_test backcompat-3.1 { sql1 $contents } {}
do_test backcompat-3.3 { sql1 { foreach {n q} {
INSERT INTO t1 SELECT * FROM t1; 1 "SELECT * FROM t1 ORDER BY a, b"
INSERT INTO t1 SELECT * FROM t1; 2 "SELECT rowid FROM t1 WHERE a MATCH 'five'"
INSERT INTO t1 SELECT * FROM t1; 3 "SELECT * FROM t1 WHERE a MATCH 'five'"
INSERT INTO t1 SELECT * FROM t1; 4 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'"
INSERT INTO t1 SELECT * FROM t1; 5 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'"
INSERT INTO t1 SELECT * FROM t1; } {
INSERT INTO t1 SELECT * FROM t1; do_test backcompat-3.2 [list sql1 $q] [sql2 $q]
INSERT INTO t1 SELECT * FROM t1; }
} } {}
do_test backcompat-3.3 { sql1 {
foreach {n q} { INSERT INTO t1 SELECT * FROM t1;
1 "SELECT * FROM t1 ORDER BY a, b" INSERT INTO t1 SELECT * FROM t1;
2 "SELECT rowid FROM t1 WHERE a MATCH 'five'" INSERT INTO t1 SELECT * FROM t1;
3 "SELECT * FROM t1 WHERE a MATCH 'five'" INSERT INTO t1 SELECT * FROM t1;
4 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'" INSERT INTO t1 SELECT * FROM t1;
5 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'" INSERT INTO t1 SELECT * FROM t1;
} { INSERT INTO t1 SELECT * FROM t1;
do_test backcompat-3.4 [list sql1 $q] [sql2 $q] INSERT INTO t1 SELECT * FROM t1;
} } } {}
set alphabet "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 1 2 3 4" foreach {n q} {
for {set i 0} {$i < 900} {incr i} { 1 "SELECT * FROM t1 ORDER BY a, b"
set term "[lindex $alphabet [expr $i/30]][lindex $alphabet [expr $i%30]] " 2 "SELECT rowid FROM t1 WHERE a MATCH 'five'"
sql1 "INSERT INTO t1 VALUES($i, '[string repeat $term 14]')" 3 "SELECT * FROM t1 WHERE a MATCH 'five'"
} 4 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'"
5 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'"
foreach {n q} { } {
1 "SELECT * FROM t1 ORDER BY a, b" do_test backcompat-3.4 [list sql1 $q] [sql2 $q]
2 "SELECT rowid FROM t1 WHERE a MATCH 'five'" }
3 "SELECT * FROM t1 WHERE a MATCH 'five'"
4 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'" set alphabet "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 1 2 3 4"
5 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'" for {set i 0} {$i < 900} {incr i} {
set term "[lindex $alphabet [expr $i/30]][lindex $alphabet [expr $i%30]] "
6 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'aa'" sql1 "INSERT INTO t1 VALUES($i, '[string repeat $term 14]')"
7 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH '44'" }
8 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'a*'"
} { foreach {n q} {
do_test backcompat-3.5 [list sql1 $q] [sql2 $q] 1 "SELECT * FROM t1 ORDER BY a, b"
} 2 "SELECT rowid FROM t1 WHERE a MATCH 'five'"
3 "SELECT * FROM t1 WHERE a MATCH 'five'"
do_test backcompat-3.6 { 4 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'"
sql1 "SELECT optimize(t1) FROM t1 LIMIT 1" 5 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'"
} {{Index optimized}}
6 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'aa'"
foreach {n q} { 7 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH '44'"
1 "SELECT * FROM t1 ORDER BY a, b" 8 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'a*'"
2 "SELECT rowid FROM t1 WHERE a MATCH 'five'" } {
3 "SELECT * FROM t1 WHERE a MATCH 'five'" do_test backcompat-3.5 [list sql1 $q] [sql2 $q]
4 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'" }
5 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'"
do_test backcompat-3.6 {
6 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'aa'" sql1 "SELECT optimize(t1) FROM t1 LIMIT 1"
7 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH '44'" } {{Index optimized}}
8 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'a*'"
} { foreach {n q} {
do_test backcompat-3.7 [list sql1 $q] [sql2 $q] 1 "SELECT * FROM t1 ORDER BY a, b"
2 "SELECT rowid FROM t1 WHERE a MATCH 'five'"
3 "SELECT * FROM t1 WHERE a MATCH 'five'"
4 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'"
5 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'"
6 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'aa'"
7 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH '44'"
8 "SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'a*'"
} {
do_test backcompat-3.7 [list sql1 $q] [sql2 $q]
}
} }
} }
} }
@@ -349,72 +351,74 @@ do_allbackcompat_test {
# Test that Rtree tables may be read/written by different versions of # Test that Rtree tables may be read/written by different versions of
# SQLite. # SQLite.
# #
set contents { ifcapable rtree {
CREATE VIRTUAL TABLE t1 USING rtree(id, x1, x2, y1, y2); set contents {
} CREATE VIRTUAL TABLE t1 USING rtree(id, x1, x2, y1, y2);
foreach {id x1 x2 y1 y2} { }
1 -47.64 43.87 33.86 34.42 2 -21.51 17.32 2.05 31.04 foreach {id x1 x2 y1 y2} {
3 -43.67 -38.33 -19.79 3.43 4 32.41 35.16 9.12 19.82 1 -47.64 43.87 33.86 34.42 2 -21.51 17.32 2.05 31.04
5 33.28 34.87 14.78 28.26 6 49.31 116.59 -9.87 75.09 3 -43.67 -38.33 -19.79 3.43 4 32.41 35.16 9.12 19.82
7 -14.93 34.51 -17.64 64.09 8 -43.05 23.43 -1.19 69.44 5 33.28 34.87 14.78 28.26 6 49.31 116.59 -9.87 75.09
9 44.79 133.56 28.09 80.30 10 -2.66 81.47 -41.38 -10.46 7 -14.93 34.51 -17.64 64.09 8 -43.05 23.43 -1.19 69.44
11 -42.89 -3.54 15.76 71.63 12 -3.50 84.96 -11.64 64.95 9 44.79 133.56 28.09 80.30 10 -2.66 81.47 -41.38 -10.46
13 -45.69 26.25 11.14 55.06 14 -44.09 11.23 17.52 44.45 11 -42.89 -3.54 15.76 71.63 12 -3.50 84.96 -11.64 64.95
15 36.23 133.49 -19.38 53.67 16 -17.89 81.54 14.64 50.61 13 -45.69 26.25 11.14 55.06 14 -44.09 11.23 17.52 44.45
17 -41.97 -24.04 -39.43 28.95 18 -5.85 7.76 -6.38 47.02 15 36.23 133.49 -19.38 53.67 16 -17.89 81.54 14.64 50.61
19 18.82 27.10 42.82 100.09 20 39.17 113.45 26.14 73.47 17 -41.97 -24.04 -39.43 28.95 18 -5.85 7.76 -6.38 47.02
21 22.31 103.17 49.92 106.05 22 -43.06 40.38 -1.75 76.08 19 18.82 27.10 42.82 100.09 20 39.17 113.45 26.14 73.47
23 2.43 57.27 -14.19 -3.83 24 -47.57 -4.35 8.93 100.06 21 22.31 103.17 49.92 106.05 22 -43.06 40.38 -1.75 76.08
25 -37.47 49.14 -29.11 8.81 26 -7.86 75.72 49.34 107.42 23 2.43 57.27 -14.19 -3.83 24 -47.57 -4.35 8.93 100.06
27 1.53 45.49 20.36 49.74 28 -48.48 32.54 28.81 54.45 25 -37.47 49.14 -29.11 8.81 26 -7.86 75.72 49.34 107.42
29 2.67 39.77 -4.05 13.67 30 4.11 62.88 -47.44 -5.72 27 1.53 45.49 20.36 49.74 28 -48.48 32.54 28.81 54.45
31 -21.47 51.75 37.25 116.09 32 45.59 111.37 -6.43 43.64 29 2.67 39.77 -4.05 13.67 30 4.11 62.88 -47.44 -5.72
33 35.23 48.29 23.54 113.33 34 16.61 68.35 -14.69 65.97 31 -21.47 51.75 37.25 116.09 32 45.59 111.37 -6.43 43.64
35 13.98 16.60 48.66 102.87 36 19.74 23.84 31.15 77.27 33 35.23 48.29 23.54 113.33 34 16.61 68.35 -14.69 65.97
37 -27.61 24.43 7.96 94.91 38 -34.77 12.05 -22.60 -6.29 35 13.98 16.60 48.66 102.87 36 19.74 23.84 31.15 77.27
39 -25.83 8.71 -13.48 -12.53 40 -17.11 -1.01 18.06 67.89 37 -27.61 24.43 7.96 94.91 38 -34.77 12.05 -22.60 -6.29
41 14.13 71.72 -3.78 39.25 42 23.75 76.00 -16.30 8.23 39 -25.83 8.71 -13.48 -12.53 40 -17.11 -1.01 18.06 67.89
43 -39.15 28.63 38.12 125.88 44 48.62 86.09 36.49 102.95 41 14.13 71.72 -3.78 39.25 42 23.75 76.00 -16.30 8.23
45 -31.39 -21.98 2.52 89.78 46 5.65 56.04 15.94 89.10 43 -39.15 28.63 38.12 125.88 44 48.62 86.09 36.49 102.95
47 18.28 95.81 46.46 143.08 48 30.93 102.82 -20.08 37.36 45 -31.39 -21.98 2.52 89.78 46 5.65 56.04 15.94 89.10
49 -20.78 -3.48 -5.58 35.46 50 49.85 90.58 -24.48 46.29 47 18.28 95.81 46.46 143.08 48 30.93 102.82 -20.08 37.36
} { 49 -20.78 -3.48 -5.58 35.46 50 49.85 90.58 -24.48 46.29
if {$x1 >= $x2 || $y1 >= $y2} { error "$x1 $x2 $y1 $y2" }
append contents "INSERT INTO t1 VALUES($id, $x1, $x2, $y1, $y2);"
}
set queries {
1 "SELECT id FROM t1 WHERE x1>10 AND x2<44"
2 "SELECT id FROM t1 WHERE y1<100"
3 "SELECT id FROM t1 WHERE y1<100 AND x1>0"
4 "SELECT id FROM t1 WHERE y1>10 AND x1>0 AND x2<50 AND y2<550"
}
do_allbackcompat_test {
if {[code1 {set ::sqlite_options(fts3)}]
&& [code2 {set ::sqlite_options(fts3)}]
} { } {
if {$x1 >= $x2 || $y1 >= $y2} { error "$x1 $x2 $y1 $y2" }
do_test backcompat-4.1 { sql1 $contents } {} append contents "INSERT INTO t1 VALUES($id, $x1, $x2, $y1, $y2);"
}
foreach {n q} $::queries { set queries {
do_test backcompat-4.2.$n [list sql1 $q] [sql2 $q] 1 "SELECT id FROM t1 WHERE x1>10 AND x2<44"
2 "SELECT id FROM t1 WHERE y1<100"
3 "SELECT id FROM t1 WHERE y1<100 AND x1>0"
4 "SELECT id FROM t1 WHERE y1>10 AND x1>0 AND x2<50 AND y2<550"
}
do_allbackcompat_test {
if {[code1 {set ::sqlite_options(fts3)}]
&& [code2 {set ::sqlite_options(fts3)}]
} {
do_test backcompat-4.1 { sql1 $contents } {}
foreach {n q} $::queries {
do_test backcompat-4.2.$n [list sql1 $q] [sql2 $q]
}
do_test backcompat-4.3 { sql1 {
INSERT INTO t1 SELECT id+100, x1+10.0, x2+10.0, y1-10.0, y2-10.0 FROM t1;
} } {}
foreach {n q} $::queries {
do_test backcompat-4.4.$n [list sql1 $q] [sql2 $q]
}
do_test backcompat-4.5 { sql2 {
INSERT INTO t1 SELECT id+200, x1+20.0, x2+20.0, y1-20.0, y2-20.0 FROM t1;
} } {}
foreach {n q} $::queries {
do_test backcompat-4.6.$n [list sql1 $q] [sql2 $q]
}
} }
do_test backcompat-4.3 { sql1 {
INSERT INTO t1 SELECT id+100, x1+10.0, x2+10.0, y1-10.0, y2-10.0 FROM t1;
} } {}
foreach {n q} $::queries {
do_test backcompat-4.4.$n [list sql1 $q] [sql2 $q]
}
do_test backcompat-4.5 { sql2 {
INSERT INTO t1 SELECT id+200, x1+20.0, x2+20.0, y1-20.0, y2-20.0 FROM t1;
} } {}
foreach {n q} $::queries {
do_test backcompat-4.6.$n [list sql1 $q] [sql2 $q]
}
} }
} }

View File

@@ -75,26 +75,27 @@ proc do_fts3query_test {tn args} {
} }
} }
get_near_results $tbl $match $deferred aMatchinfo get_near_results $tbl $match $deferred aHit
get_near_results $tbl [string map {AND OR} $match] $deferred aMatchinfo
set matchinfo_asc [list] set matchinfo_asc [list]
foreach docid [lsort -integer -incr [array names aMatchinfo]] { foreach docid [lsort -integer -incr [array names aHit]] {
lappend matchinfo_asc $docid $aMatchinfo($docid) lappend matchinfo_asc $docid $aMatchinfo($docid)
} }
set matchinfo_desc [list] set matchinfo_desc [list]
foreach docid [lsort -integer -decr [array names aMatchinfo]] { foreach docid [lsort -integer -decr [array names aHit]] {
lappend matchinfo_desc $docid $aMatchinfo($docid) lappend matchinfo_desc $docid $aMatchinfo($docid)
} }
set title "(\"$match\" -> [llength [array names aMatchinfo]] rows)" set title "(\"$match\" -> [llength [array names aHit]] rows)"
do_execsql_test $tn$title.1 " do_execsql_test $tn$title.1 "
SELECT docid FROM $tbl WHERE $tbl MATCH '$match' ORDER BY docid ASC SELECT docid FROM $tbl WHERE $tbl MATCH '$match' ORDER BY docid ASC
" [lsort -integer -incr [array names aMatchinfo]] " [lsort -integer -incr [array names aHit]]
do_execsql_test $tn$title.2 " do_execsql_test $tn$title.2 "
SELECT docid FROM $tbl WHERE $tbl MATCH '$match' ORDER BY docid DESC SELECT docid FROM $tbl WHERE $tbl MATCH '$match' ORDER BY docid DESC
" [lsort -integer -decr [array names aMatchinfo]] " [lsort -integer -decr [array names aHit]]
do_execsql_test $tn$title.3 " do_execsql_test $tn$title.3 "
SELECT docid, mit(matchinfo($tbl, 'x')) FROM $tbl SELECT docid, mit(matchinfo($tbl, 'x')) FROM $tbl
@@ -650,6 +651,7 @@ foreach {tn pending create} {
do_fts3query_test 6.$tn.2 t1 {b:G AND c:I} do_fts3query_test 6.$tn.2 t1 {b:G AND c:I}
do_fts3query_test 6.$tn.3 t1 {b:G NEAR c:I} do_fts3query_test 6.$tn.3 t1 {b:G NEAR c:I}
do_fts3query_test 6.$tn.4 t1 {a:C OR b:G OR c:K OR d:C} do_fts3query_test 6.$tn.4 t1 {a:C OR b:G OR c:K OR d:C}
do_fts3query_test 6.$tn.5 t1 {a:G OR b:G} do_fts3query_test 6.$tn.5 t1 {a:G OR b:G}
catchsql { COMMIT } catchsql { COMMIT }

View File

@@ -462,7 +462,7 @@ do_test pager1.4.2.3 {
} {64 ok} } {64 ok}
do_test pager1.4.2.4 { do_test pager1.4.2.4 {
faultsim_restore_and_reopen faultsim_restore_and_reopen
hexio_write test.db-journal [expr [file size test.db-journal]-20] 123456 hexio_write test.db-journal [expr [file size test.db-journal]-30] 123456
execsql { execsql {
SELECT count(*) FROM t1; SELECT count(*) FROM t1;
PRAGMA integrity_check; PRAGMA integrity_check;
@@ -470,7 +470,7 @@ do_test pager1.4.2.4 {
} {4 ok} } {4 ok}
do_test pager1.4.2.5 { do_test pager1.4.2.5 {
faultsim_restore_and_reopen faultsim_restore_and_reopen
hexio_write test.db-journal [expr [file size test.db-journal]-20] 123456 hexio_write test.db-journal [expr [file size test.db-journal]-30] 123456
foreach f [glob test.db-mj*] { forcedelete $f } foreach f [glob test.db-mj*] { forcedelete $f }
execsql { execsql {
SELECT count(*) FROM t1; SELECT count(*) FROM t1;

View File

@@ -283,9 +283,8 @@ do_test shell1-3.2.4 {
# .databases List names and files of attached databases # .databases List names and files of attached databases
do_test shell1-3.3.1 { do_test shell1-3.3.1 {
set res [catchcmd "test.db" ".databases"] catchcmd "-csv test.db" ".databases"
regexp {0.*main.*test\.db} $res } {/0 +.*main +.*test.db.*/}
} {1}
do_test shell1-3.3.2 { do_test shell1-3.3.2 {
# too many arguments # too many arguments
catchcmd "test.db" ".databases BAD" catchcmd "test.db" ".databases BAD"

View File

@@ -1620,5 +1620,8 @@ proc db_delete_and_reopen {{file test.db}} {
# to non-zero, then set the global variable $AUTOVACUUM to 1. # to non-zero, then set the global variable $AUTOVACUUM to 1.
set AUTOVACUUM $sqlite_options(default_autovacuum) set AUTOVACUUM $sqlite_options(default_autovacuum)
# Make sure the FTS enhanced query syntax is disabled.
set sqlite_fts3_enable_parentheses 0
source $testdir/thread_common.tcl source $testdir/thread_common.tcl
source $testdir/malloc_common.tcl source $testdir/malloc_common.tcl

90
test/tkt-bdc6bbbb38.test Normal file
View File

@@ -0,0 +1,90 @@
# 2012 May 11
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests to verify that ticket [bdc6bbbb38] has been
# fixed.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix tkt-bdc6bbbb38
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 { finish_test ; return }
set sqlite_fts3_enable_parentheses 1
foreach {tn idxdir} {1 ASC 2 DESC} {
execsql { DROP TABLE IF EXISTS t2 }
do_execsql_test $tn.1.1 "CREATE VIRTUAL TABLE t2 USING fts4(x, order=$idxdir)"
do_execsql_test $tn.1.2 { INSERT INTO t2 VALUES('a b c') }
do_execsql_test $tn.1.3 {
SELECT offsets(t2) FROM t2 WHERE t2 MATCH 'a AND d OR b' ORDER BY docid ASC
} {
{0 0 0 1 0 2 2 1}
}
do_execsql_test $tn.1.4 {
SELECT snippet(t2,'[',']') FROM t2 WHERE t2 MATCH 'a AND d OR b'
ORDER BY docid ASC
} {
{[a] [b] c}
}
do_execsql_test $tn.1.5 { INSERT INTO t2 VALUES('a c d') }
do_execsql_test $tn.1.6 {
SELECT offsets(t2) FROM t2 WHERE t2 MATCH 'a AND d OR b' ORDER BY docid ASC
} {
{0 0 0 1 0 2 2 1}
{0 0 0 1 0 1 4 1}
}
do_execsql_test $tn.1.7 {
SELECT snippet(t2,'[',']') FROM t2 WHERE t2 MATCH 'a AND d OR b'
ORDER BY docid ASC
} {
{[a] [b] c}
{[a] c [d]}
}
execsql { DROP TABLE IF EXISTS t3 }
do_execsql_test $tn.2.1 "CREATE VIRTUAL TABLE t3 USING fts4(x, order=$idxdir)"
do_execsql_test $tn.2.2 { INSERT INTO t3 VALUES('a c d') }
do_execsql_test $tn.2.3 {
SELECT offsets(t3) FROM t3 WHERE t3 MATCH 'a AND d OR b' ORDER BY docid DESC
} {
{0 0 0 1 0 1 4 1}
}
do_execsql_test $tn.2.4 {
SELECT snippet(t3,'[',']') FROM t3 WHERE t3 MATCH 'a AND d OR b'
ORDER BY docid DESC
} {
{[a] c [d]}
}
do_execsql_test $tn.2.5 {
INSERT INTO t3 VALUES('a b c');
}
do_execsql_test $tn.2.6 {
SELECT offsets(t3) FROM t3 WHERE t3 MATCH 'a AND d OR b' ORDER BY docid DESC
} {
{0 0 0 1 0 2 2 1}
{0 0 0 1 0 1 4 1}
}
do_execsql_test $tn.2.7 {
SELECT snippet(t3,'[',']') FROM t3 WHERE t3 MATCH 'a AND d OR b'
ORDER BY docid DESC
} {
{[a] [b] c}
{[a] c [d]}
}
}
set sqlite_fts3_enable_parentheses 0
finish_test

View File

@@ -1223,10 +1223,11 @@ proc logcksum {ckv1 ckv2 blob} {
upvar $ckv1 c1 upvar $ckv1 c1
upvar $ckv2 c2 upvar $ckv2 c2
set scanpattern I* # Since the magic number at the start of the -wal file header is
if {$::tcl_platform(byteOrder) eq "littleEndian"} { # 931071618 that indicates that the content should always be read as
set scanpattern i* # little-endian.
} #
set scanpattern i*
binary scan $blob $scanpattern values binary scan $blob $scanpattern values
foreach {v1 v2} $values { foreach {v1 v2} $values {

View File

@@ -46,6 +46,7 @@ proc set_tvfs_hdr {file args} {
} }
set blob [tvfs shm $file] set blob [tvfs shm $file]
if {$::tcl_platform(byteOrder)=="bigEndian"} {set fmt I} {set fmt i}
if {[llength $args]} { if {[llength $args]} {
set ia [lindex $args 0] set ia [lindex $args 0]
@@ -54,11 +55,11 @@ proc set_tvfs_hdr {file args} {
set ib [lindex $args 1] set ib [lindex $args 1]
} }
binary scan $blob a[expr $nHdr*2]a* dummy tail binary scan $blob a[expr $nHdr*2]a* dummy tail
set blob [binary format i${nInt}i${nInt}a* $ia $ib $tail] set blob [binary format ${fmt}${nInt}${fmt}${nInt}a* $ia $ib $tail]
tvfs shm $file $blob tvfs shm $file $blob
} }
binary scan $blob i${nInt} ints binary scan $blob ${fmt}${nInt} ints
return $ints return $ints
} }