From b2bd727e52d2cf6de187b766e3b813bfbf1a7c08 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 5 May 2015 19:37:07 +0000 Subject: [PATCH 01/33] Optimizations for the matchinfo() function, particularly the 'y' flag. FossilOrigin-Name: dddd7e182943a1d3a9d32830e819a63f1a228d6d --- ext/fts3/fts3.c | 4 +- ext/fts3/fts3Int.h | 7 +- ext/fts3/fts3_snippet.c | 207 ++++++++++++++++++++++++++++++---------- manifest | 21 ++-- manifest.uuid | 2 +- 5 files changed, 178 insertions(+), 63 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index e7958d9c4d..8673ab7c3e 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -1675,7 +1675,7 @@ static int fts3CloseMethod(sqlite3_vtab_cursor *pCursor){ sqlite3Fts3ExprFree(pCsr->pExpr); sqlite3Fts3FreeDeferredTokens(pCsr); sqlite3_free(pCsr->aDoclist); - sqlite3_free(pCsr->aMatchinfo); + sqlite3Fts3MIBufferFree(pCsr->pMIBuffer); assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 ); sqlite3_free(pCsr); return SQLITE_OK; @@ -3176,7 +3176,7 @@ static int fts3FilterMethod( /* In case the cursor has been used before, clear it now. */ sqlite3_finalize(pCsr->pStmt); sqlite3_free(pCsr->aDoclist); - sqlite3_free(pCsr->aMatchinfo); + sqlite3Fts3MIBufferFree(pCsr->pMIBuffer); sqlite3Fts3ExprFree(pCsr->pExpr); memset(&pCursor[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor)); diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index 0748d916d0..9e98c0410f 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -197,6 +197,8 @@ typedef struct Fts3DeferredToken Fts3DeferredToken; typedef struct Fts3SegReader Fts3SegReader; typedef struct Fts3MultiSegReader Fts3MultiSegReader; +typedef struct MatchinfoBuffer MatchinfoBuffer; + /* ** A connection to a fulltext index is an instance of the following ** structure. The xCreate and xConnect methods create an instance @@ -306,9 +308,7 @@ struct Fts3Cursor { i64 iMinDocid; /* Minimum docid to return */ i64 iMaxDocid; /* Maximum docid to return */ int isMatchinfoNeeded; /* True when aMatchinfo[] needs filling in */ - u32 *aMatchinfo; /* Information about most recent match */ - int nMatchinfo; /* Number of elements in aMatchinfo[] */ - char *zMatchinfo; /* Matchinfo specification */ + MatchinfoBuffer *pMIBuffer; /* Buffer for matchinfo data */ }; #define FTS3_EVAL_FILTER 0 @@ -564,6 +564,7 @@ void sqlite3Fts3Snippet(sqlite3_context *, Fts3Cursor *, const char *, const char *, const char *, int, int ); void sqlite3Fts3Matchinfo(sqlite3_context *, Fts3Cursor *, const char *); +void sqlite3Fts3MIBufferFree(MatchinfoBuffer *p); /* fts3_expr.c */ int sqlite3Fts3ExprParse(sqlite3_tokenizer *, int, diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 6abb169ebf..1eceafa050 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -92,6 +92,18 @@ struct MatchInfo { u32 *aMatchinfo; /* Pre-allocated buffer */ }; +/* +** An instance of this structure is used to manage a pair of buffers, each +** (nElem * sizeof(u32)) bytes in size. See the MatchinfoBuffer code below +** for details. +*/ +struct MatchinfoBuffer { + u8 aRef[3]; + int nElem; + int bGlobal; /* Set if global data is loaded */ + char *zMatchinfo; + u32 aMatchinfo[0]; +}; /* @@ -107,6 +119,97 @@ struct StrBuffer { }; +/************************************************************************* +** Start of MatchinfoBuffer code. +*/ + +/* +** Allocate a two-slot MatchinfoBuffer object. +*/ +static MatchinfoBuffer *fts3MIBufferNew(int nElem, const char *zMatchinfo){ + MatchinfoBuffer *pRet; + int nByte = sizeof(u32) * (2*nElem + 2) + sizeof(MatchinfoBuffer); + int nStr = strlen(zMatchinfo); + + pRet = sqlite3_malloc(nByte + nStr+1); + if( pRet ){ + memset(pRet, 0, nByte); + pRet->aMatchinfo[0] = (u8*)(&pRet->aMatchinfo[1]) - (u8*)pRet; + pRet->aMatchinfo[1+nElem] = pRet->aMatchinfo[0] + sizeof(u32)*(nElem+1); + pRet->nElem = nElem; + pRet->zMatchinfo = ((char*)pRet) + nByte; + memcpy(pRet->zMatchinfo, zMatchinfo, nStr+1); + pRet->aRef[0] = 1; + } + + return pRet; +} + +static void fts3MIBufferFree(void *p){ + MatchinfoBuffer *pBuf = (MatchinfoBuffer*)((u8*)p - ((u32*)p)[-1]); + + assert( (u32*)p==&pBuf->aMatchinfo[1] + || (u32*)p==&pBuf->aMatchinfo[pBuf->nElem+2] + ); + if( (u32*)p==&pBuf->aMatchinfo[1] ){ + pBuf->aRef[1] = 0; + }else{ + pBuf->aRef[2] = 0; + } + + if( pBuf->aRef[0]==0 && pBuf->aRef[1]==0 && pBuf->aRef[2]==0 ){ + sqlite3_free(pBuf); + } +} + +static void (*fts3MIBufferAlloc(MatchinfoBuffer *p, u32 **paOut))(void*){ + void (*xRet)(void*) = 0; + u32 *aOut = 0; + + if( p->aRef[1]==0 ){ + p->aRef[1] = 1; + aOut = &p->aMatchinfo[1]; + xRet = fts3MIBufferFree; + } + else if( p->aRef[2]==0 ){ + p->aRef[2] = 1; + aOut = &p->aMatchinfo[p->nElem+2]; + xRet = fts3MIBufferFree; + }else{ + aOut = (u32*)sqlite3_malloc(p->nElem * sizeof(u32)); + if( aOut ){ + xRet = sqlite3_free; + if( p->bGlobal ) memcpy(aOut, &p->aMatchinfo[1], p->nElem*sizeof(u32)); + } + } + + *paOut = aOut; + return xRet; +} + +static void fts3MIBufferSetGlobal(MatchinfoBuffer *p){ + p->bGlobal = 1; + memcpy(&p->aMatchinfo[2+p->nElem], &p->aMatchinfo[1], p->nElem*sizeof(u32)); +} + +/* +** Free a MatchinfoBuffer object allocated using fts3MIBufferNew() +*/ +void sqlite3Fts3MIBufferFree(MatchinfoBuffer *p){ + if( p ){ + assert( p->aRef[0]==1 ); + p->aRef[0] = 0; + if( p->aRef[0]==0 && p->aRef[1]==0 && p->aRef[2]==0 ){ + sqlite3_free(p); + } + } +} + +/* +** End of MatchinfoBuffer code. +*************************************************************************/ + + /* ** This function is used to help iterate through a position-list. A position ** list is a list of unique integers, sorted from smallest to largest. Each @@ -133,6 +236,8 @@ static void fts3GetDeltaPosition(char **pp, int *piPos){ *piPos += (iVal-2); } +static int fts3ExprLHitsCb(Fts3Expr*,int,void*); + /* ** Helper function for fts3ExprIterate() (see below). */ @@ -143,17 +248,21 @@ static int fts3ExprIterate2( void *pCtx /* Second argument to pass to callback */ ){ int rc; /* Return code */ - int eType = pExpr->eType; /* Type of expression node pExpr */ - if( eType!=FTSQUERY_PHRASE ){ - assert( pExpr->pLeft && pExpr->pRight ); - rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx); - if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){ - rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx); - } + if( x==fts3ExprLHitsCb && pExpr->bEof ){ + rc = SQLITE_OK; }else{ - rc = x(pExpr, *piPhrase, pCtx); - (*piPhrase)++; + int eType = pExpr->eType; /* Type of expression node pExpr */ + if( eType!=FTSQUERY_PHRASE ){ + assert( pExpr->pLeft && pExpr->pRight ); + rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx); + if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){ + rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx); + } + }else{ + rc = x(pExpr, *piPhrase, pCtx); + (*piPhrase)++; + } } return rc; } @@ -819,23 +928,15 @@ static int fts3ExprLHitsCb( int iPhrase, /* Phrase number */ void *pCtx /* Pointer to MatchInfo structure */ ){ - MatchInfo *p = (MatchInfo *)pCtx; - Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab; int rc = SQLITE_OK; - int iStart = iPhrase * p->nCol; - Fts3Expr *pEof; /* Ancestor node already at EOF */ + MatchInfo *p = (MatchInfo *)pCtx; /* This must be a phrase */ assert( pExpr->pPhrase ); - /* Initialize all output integers to zero. */ - memset(&p->aMatchinfo[iStart], 0, sizeof(u32) * p->nCol); - - /* Check if this or any parent node is at EOF. If so, then all output - ** values are zero. */ - for(pEof=pExpr; pEof && pEof->bEof==0; pEof=pEof->pParent); - - if( pEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){ + if( pExpr->iDocid==p->pCursor->iPrevId ){ + Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab; + int iStart = iPhrase * p->nCol; Fts3Phrase *pPhrase = pExpr->pPhrase; char *pIter = pPhrase->doclist.pList; int iCol = 0; @@ -1149,9 +1250,12 @@ static int fts3MatchinfoValues( } break; - case FTS3_MATCHINFO_LHITS: + case FTS3_MATCHINFO_LHITS: { + int nZero = fts3MatchinfoSize(pInfo, FTS3_MATCHINFO_LHITS)*sizeof(u32); + memset(pInfo->aMatchinfo, 0, nZero); (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLHitsCb, (void*)pInfo); break; + } default: { Fts3Expr *pExpr; @@ -1185,6 +1289,7 @@ static int fts3MatchinfoValues( ** 'matchinfo' data is an array of 32-bit unsigned integers (C type u32). */ static int fts3GetMatchinfo( + sqlite3_context *pCtx, /* Return results here */ Fts3Cursor *pCsr, /* FTS3 Cursor object */ const char *zArg /* Second argument to matchinfo() function */ ){ @@ -1193,6 +1298,9 @@ static int fts3GetMatchinfo( int rc = SQLITE_OK; int bGlobal = 0; /* Collect 'global' stats as well as local */ + u32 *aOut = 0; + void (*xDestroyOut)(void*) = 0; + memset(&sInfo, 0, sizeof(MatchInfo)); sInfo.pCursor = pCsr; sInfo.nCol = pTab->nColumn; @@ -1200,19 +1308,17 @@ static int fts3GetMatchinfo( /* If there is cached matchinfo() data, but the format string for the ** cache does not match the format string for this request, discard ** the cached data. */ - if( pCsr->zMatchinfo && strcmp(pCsr->zMatchinfo, zArg) ){ - assert( pCsr->aMatchinfo ); - sqlite3_free(pCsr->aMatchinfo); - pCsr->zMatchinfo = 0; - pCsr->aMatchinfo = 0; + if( pCsr->pMIBuffer && strcmp(pCsr->pMIBuffer->zMatchinfo, zArg) ){ + sqlite3Fts3MIBufferFree(pCsr->pMIBuffer); + pCsr->pMIBuffer = 0; } - /* If Fts3Cursor.aMatchinfo[] is NULL, then this is the first time the + /* If Fts3Cursor.pMIBuffer is NULL, then this is the first time the ** matchinfo function has been called for this query. In this case ** allocate the array used to accumulate the matchinfo data and ** initialize those elements that are constant for every row. */ - if( pCsr->aMatchinfo==0 ){ + if( pCsr->pMIBuffer==0 ){ int nMatchinfo = 0; /* Number of u32 elements in match-info */ int nArg; /* Bytes in zArg */ int i; /* Used to iterate through zArg */ @@ -1227,23 +1333,35 @@ static int fts3GetMatchinfo( } /* Allocate space for Fts3Cursor.aMatchinfo[] and Fts3Cursor.zMatchinfo. */ - nArg = (int)strlen(zArg); - pCsr->aMatchinfo = (u32 *)sqlite3_malloc(sizeof(u32)*nMatchinfo + nArg + 1); - if( !pCsr->aMatchinfo ) return SQLITE_NOMEM; + pCsr->pMIBuffer = fts3MIBufferNew(nMatchinfo, zArg); + if( !pCsr->pMIBuffer ) rc = SQLITE_NOMEM; - pCsr->zMatchinfo = (char *)&pCsr->aMatchinfo[nMatchinfo]; - pCsr->nMatchinfo = nMatchinfo; - memcpy(pCsr->zMatchinfo, zArg, nArg+1); - memset(pCsr->aMatchinfo, 0, sizeof(u32)*nMatchinfo); pCsr->isMatchinfoNeeded = 1; bGlobal = 1; } - sInfo.aMatchinfo = pCsr->aMatchinfo; - sInfo.nPhrase = pCsr->nPhrase; - if( pCsr->isMatchinfoNeeded ){ + if( rc==SQLITE_OK ){ + xDestroyOut = fts3MIBufferAlloc(pCsr->pMIBuffer, &aOut); + if( xDestroyOut==0 ){ + rc = SQLITE_NOMEM; + } + } + + if( rc==SQLITE_OK ){ + sInfo.aMatchinfo = aOut; + sInfo.nPhrase = pCsr->nPhrase; rc = fts3MatchinfoValues(pCsr, bGlobal, &sInfo, zArg); - pCsr->isMatchinfoNeeded = 0; + if( bGlobal ){ + fts3MIBufferSetGlobal(pCsr->pMIBuffer); + } + } + + if( rc!=SQLITE_OK ){ + sqlite3_result_error_code(pCtx, rc); + if( xDestroyOut ) xDestroyOut(aOut); + }else{ + int n = pCsr->pMIBuffer->nElem * sizeof(u32); + sqlite3_result_blob(pCtx, aOut, n, xDestroyOut); } return rc; @@ -1568,15 +1686,8 @@ void sqlite3Fts3Matchinfo( } /* Retrieve matchinfo() data. */ - rc = fts3GetMatchinfo(pCsr, zFormat); + rc = fts3GetMatchinfo(pContext, pCsr, zFormat); sqlite3Fts3SegmentsClose(pTab); - - if( rc!=SQLITE_OK ){ - sqlite3_result_error_code(pContext, rc); - }else{ - int n = pCsr->nMatchinfo * sizeof(u32); - sqlite3_result_blob(pContext, pCsr->aMatchinfo, n, SQLITE_TRANSIENT); - } } #endif diff --git a/manifest b/manifest index 7b6957d36a..738c7e07a1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\s#ifdef\sstatements\sto\stest_blob.c\sso\sthat\sit\swill\sbuild\nwith\sSQLITE_OMIT_INCRBLOB. -D 2015-05-05T11:08:02.278 +C Optimizations\sfor\sthe\smatchinfo()\sfunction,\sparticularly\sthe\s'y'\sflag. +D 2015-05-05T19:37:07.819 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -78,16 +78,16 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 2fb98467f4b670c8934cdd97d1ba3ffa7382764c +F ext/fts3/fts3.c 341e9d9a3c7615bac8e815a8937d576265b22f78 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h 59ecaa2d7af0da44c70b6aeaebdcfc070d14abab +F ext/fts3/fts3Int.h bf61766eeb57a6922a8458b894d85e50d1cfb04e F ext/fts3/fts3_aux.c 9edc3655fcb287f0467d0a4b886a01c6185fe9f1 F ext/fts3/fts3_expr.c 71c063da9c2a4167fb54aec089dd5ef33a58c9cb F ext/fts3/fts3_hash.c 29b986e43f4e9dd40110eafa377dc0d63c422c60 F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf F ext/fts3/fts3_icu.c e319e108661147bcca8dd511cd562f33a1ba81b5 F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009 -F ext/fts3/fts3_snippet.c 40a96ba78e90aba7d7d6d014a18049bb218060fd +F ext/fts3/fts3_snippet.c a1c62f1b7c55d14a13385689ce11aa0e1ada55b8 F ext/fts3/fts3_term.c 88c55a6fa1a51ab494e33dced0401a6c28791fd7 F ext/fts3/fts3_test.c 8a3a78c4458b2d7c631fcf4b152a5cd656fa7038 F ext/fts3/fts3_tokenize_vtab.c a27593ab19657166f6fa5ec073b678cc29a75860 @@ -1256,7 +1256,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d2cb1becc07fad5cbd48c206c676493ba90cada1 -R e1db2a6afd30f4051a55266b8de5e117 -U drh -Z df7e75264a470014004f32463950df05 +P b8f090e65d010c62df335d0520a36a24904e8bc6 +R db4b4f916c43503b3d5880cc35083941 +T *branch * fts3-matchinfo-y +T *sym-fts3-matchinfo-y * +T -sym-trunk * +U dan +Z 2cd9b208c5989e901293be093105f297 diff --git a/manifest.uuid b/manifest.uuid index c9040b853e..c76ab92b50 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8f090e65d010c62df335d0520a36a24904e8bc6 \ No newline at end of file +dddd7e182943a1d3a9d32830e819a63f1a228d6d \ No newline at end of file From 99eaf39784f2da96210af07828ab1abad1c31edd Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 5 May 2015 20:39:53 +0000 Subject: [PATCH 02/33] Add the fts3 matchinfo 'b' flag. FossilOrigin-Name: b9b77972d88171e4239b8194f308eb5d60b5d172 --- ext/fts3/fts3_snippet.c | 55 +++++++++++++++++++++++++++-------------- manifest | 19 ++++++-------- manifest.uuid | 2 +- test/fts3matchinfo.test | 41 +++++++++++++++++++++++++++++- test/fts3query.test | 4 +-- 5 files changed, 88 insertions(+), 33 deletions(-) diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 1eceafa050..a0286bbb43 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -28,6 +28,7 @@ #define FTS3_MATCHINFO_LCS 's' /* nCol values */ #define FTS3_MATCHINFO_HITS 'x' /* 3*nCol*nPhrase values */ #define FTS3_MATCHINFO_LHITS 'y' /* nCol*nPhrase values */ +#define FTS3_MATCHINFO_LHITS_BM 'b' /* nCol*nPhrase values */ /* ** The default value for the second argument to matchinfo(). @@ -89,6 +90,7 @@ struct MatchInfo { int nCol; /* Number of columns in table */ int nPhrase; /* Number of matchable phrases in query */ sqlite3_int64 nDoc; /* Number of docs in database */ + char flag; u32 *aMatchinfo; /* Pre-allocated buffer */ }; @@ -236,28 +238,27 @@ static void fts3GetDeltaPosition(char **pp, int *piPos){ *piPos += (iVal-2); } -static int fts3ExprLHitsCb(Fts3Expr*,int,void*); - /* ** Helper function for fts3ExprIterate() (see below). */ static int fts3ExprIterate2( Fts3Expr *pExpr, /* Expression to iterate phrases of */ + int bExcludeEof, int *piPhrase, /* Pointer to phrase counter */ int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */ void *pCtx /* Second argument to pass to callback */ ){ int rc; /* Return code */ - if( x==fts3ExprLHitsCb && pExpr->bEof ){ + if( bExcludeEof && pExpr->bEof ){ rc = SQLITE_OK; }else{ int eType = pExpr->eType; /* Type of expression node pExpr */ if( eType!=FTSQUERY_PHRASE ){ assert( pExpr->pLeft && pExpr->pRight ); - rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx); + rc = fts3ExprIterate2(pExpr->pLeft, bExcludeEof, piPhrase, x, pCtx); if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){ - rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx); + rc = fts3ExprIterate2(pExpr->pRight, bExcludeEof, piPhrase, x, pCtx); } }else{ rc = x(pExpr, *piPhrase, pCtx); @@ -279,11 +280,12 @@ static int fts3ExprIterate2( */ static int fts3ExprIterate( Fts3Expr *pExpr, /* Expression to iterate phrases of */ + int bExcludeEof, /* Include nodes already at EOF */ int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */ void *pCtx /* Second argument to pass to callback */ ){ int iPhrase = 0; /* Variable used as the phrase counter */ - return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx); + return fts3ExprIterate2(pExpr, bExcludeEof, &iPhrase, x, pCtx); } /* @@ -322,7 +324,7 @@ static int fts3ExprLoadDoclists( int rc; /* Return Code */ LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */ sCtx.pCsr = pCsr; - rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx); + rc = fts3ExprIterate(pCsr->pExpr, 0, fts3ExprLoadDoclistsCb, (void *)&sCtx); if( pnPhrase ) *pnPhrase = sCtx.nPhrase; if( pnToken ) *pnToken = sCtx.nToken; return rc; @@ -336,7 +338,7 @@ static int fts3ExprPhraseCountCb(Fts3Expr *pExpr, int iPhrase, void *ctx){ } static int fts3ExprPhraseCount(Fts3Expr *pExpr){ int nPhrase = 0; - (void)fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase); + (void)fts3ExprIterate(pExpr, 0, fts3ExprPhraseCountCb, (void *)&nPhrase); return nPhrase; } @@ -552,7 +554,7 @@ static int fts3BestSnippet( sIter.nSnippet = nSnippet; sIter.nPhrase = nList; sIter.iCurrent = -1; - rc = fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void *)&sIter); + rc = fts3ExprIterate(pCsr->pExpr, 0, fts3SnippetFindPositions, (void*)&sIter); if( rc==SQLITE_OK ){ /* Set the *pmSeen output variable. */ @@ -936,15 +938,26 @@ static int fts3ExprLHitsCb( if( pExpr->iDocid==p->pCursor->iPrevId ){ Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab; - int iStart = iPhrase * p->nCol; + int iStart; Fts3Phrase *pPhrase = pExpr->pPhrase; char *pIter = pPhrase->doclist.pList; int iCol = 0; + assert( p->flag==FTS3_MATCHINFO_LHITS_BM || p->flag==FTS3_MATCHINFO_LHITS ); + if( p->flag==FTS3_MATCHINFO_LHITS ){ + iStart = iPhrase * p->nCol; + }else{ + iStart = iPhrase * ((p->nCol + 31) / 32); + } + while( 1 ){ int nHit = fts3ColumnlistCount(&pIter); if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){ - p->aMatchinfo[iStart + iCol] = (u32)nHit; + if( p->flag==FTS3_MATCHINFO_LHITS ){ + p->aMatchinfo[iStart + iCol] = (u32)nHit; + }else if( nHit ){ + p->aMatchinfo[iStart + (iCol+1)/32] |= (1 << (iCol&0x1F)); + } } assert( *pIter==0x00 || *pIter==0x01 ); if( *pIter!=0x01 ) break; @@ -969,6 +982,7 @@ static int fts3MatchinfoCheck( || (cArg==FTS3_MATCHINFO_LCS) || (cArg==FTS3_MATCHINFO_HITS) || (cArg==FTS3_MATCHINFO_LHITS) + || (cArg==FTS3_MATCHINFO_LHITS_BM) ){ return SQLITE_OK; } @@ -996,6 +1010,10 @@ static int fts3MatchinfoSize(MatchInfo *pInfo, char cArg){ nVal = pInfo->nCol * pInfo->nPhrase; break; + case FTS3_MATCHINFO_LHITS_BM: + nVal = pInfo->nPhrase * ((pInfo->nCol + 31) / 32); + break; + default: assert( cArg==FTS3_MATCHINFO_HITS ); nVal = pInfo->nCol * pInfo->nPhrase * 3; @@ -1106,7 +1124,7 @@ static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){ aIter = sqlite3_malloc(sizeof(LcsIterator) * pCsr->nPhrase); if( !aIter ) return SQLITE_NOMEM; memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase); - (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter); + (void)fts3ExprIterate(pCsr->pExpr, 0, fts3MatchinfoLcsCb, (void*)aIter); for(i=0; inPhrase; i++){ LcsIterator *pIter = &aIter[i]; @@ -1190,7 +1208,7 @@ static int fts3MatchinfoValues( sqlite3_stmt *pSelect = 0; for(i=0; rc==SQLITE_OK && zArg[i]; i++){ - + pInfo->flag = zArg[i]; switch( zArg[i] ){ case FTS3_MATCHINFO_NPHRASE: if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nPhrase; @@ -1250,10 +1268,11 @@ static int fts3MatchinfoValues( } break; + case FTS3_MATCHINFO_LHITS_BM: case FTS3_MATCHINFO_LHITS: { - int nZero = fts3MatchinfoSize(pInfo, FTS3_MATCHINFO_LHITS)*sizeof(u32); + int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32); memset(pInfo->aMatchinfo, 0, nZero); - (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLHitsCb, (void*)pInfo); + (void)fts3ExprIterate(pCsr->pExpr, 1, fts3ExprLHitsCb, (void*)pInfo); break; } @@ -1268,10 +1287,10 @@ static int fts3MatchinfoValues( rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0); if( rc!=SQLITE_OK ) break; } - rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo); + rc = fts3ExprIterate(pExpr, 0, fts3ExprGlobalHitsCb,(void*)pInfo); if( rc!=SQLITE_OK ) break; } - (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo); + (void)fts3ExprIterate(pExpr, 0, fts3ExprLocalHitsCb,(void*)pInfo); break; } } @@ -1570,7 +1589,7 @@ void sqlite3Fts3Offsets( */ sCtx.iCol = iCol; sCtx.iTerm = 0; - (void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void *)&sCtx); + (void)fts3ExprIterate(pCsr->pExpr, 0, fts3ExprTermOffsetInit, (void*)&sCtx); /* Retreive the text stored in column iCol. If an SQL NULL is stored ** in column iCol, jump immediately to the next iteration of the loop. diff --git a/manifest b/manifest index 738c7e07a1..cfd87670bf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Optimizations\sfor\sthe\smatchinfo()\sfunction,\sparticularly\sthe\s'y'\sflag. -D 2015-05-05T19:37:07.819 +C Add\sthe\sfts3\smatchinfo\s'b'\sflag. +D 2015-05-05T20:39:53.730 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -87,7 +87,7 @@ F ext/fts3/fts3_hash.c 29b986e43f4e9dd40110eafa377dc0d63c422c60 F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf F ext/fts3/fts3_icu.c e319e108661147bcca8dd511cd562f33a1ba81b5 F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009 -F ext/fts3/fts3_snippet.c a1c62f1b7c55d14a13385689ce11aa0e1ada55b8 +F ext/fts3/fts3_snippet.c 2224cdfddd4825c449bab0420549b76963f5e444 F ext/fts3/fts3_term.c 88c55a6fa1a51ab494e33dced0401a6c28791fd7 F ext/fts3/fts3_test.c 8a3a78c4458b2d7c631fcf4b152a5cd656fa7038 F ext/fts3/fts3_tokenize_vtab.c a27593ab19657166f6fa5ec073b678cc29a75860 @@ -593,11 +593,11 @@ F test/fts3fault2.test f953bb3cf903988172270a9a0aafd5a890b0f98f F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641 F test/fts3join.test 53e66a0c21eb568580674a43b21c059acb26f499 F test/fts3malloc.test b0e4c133b8d61d4f6d112d8110f8320e9e453ef6 -F test/fts3matchinfo.test 3e5f5ac2e0a8ba42eafd4c685f803ca48b4c3a83 +F test/fts3matchinfo.test 07009313ad6c082f94d8c9c3228eb8940c93ac71 F test/fts3near.test 7e3354d46f155a822b59c0e957fd2a70c1d7e905 F test/fts3prefix.test fa794eaab0bdae466494947b0b153d7844478ab2 F test/fts3prefix2.test e1f0a822ca661dced7f12ce392e14eaf65609dce -F test/fts3query.test c838b18f2b859e15fd31c64be3d79ef1556803ca +F test/fts3query.test f33eb71a1fe1084ea585eeb7ee76b390729f5170 F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0 F test/fts3shared.test 57e26a801f21027b7530da77db54286a6fe4997e F test/fts3snippet.test 63dbd687d5bf5191f1b8e6a0977aa9c1e28a7004 @@ -1256,10 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b8f090e65d010c62df335d0520a36a24904e8bc6 -R db4b4f916c43503b3d5880cc35083941 -T *branch * fts3-matchinfo-y -T *sym-fts3-matchinfo-y * -T -sym-trunk * +P dddd7e182943a1d3a9d32830e819a63f1a228d6d +R 163d76f4b269e89cdb470ec09f3dac69 U dan -Z 2cd9b208c5989e901293be093105f297 +Z 5b29ad8a6cfef6f4d3b7a8b71870984c diff --git a/manifest.uuid b/manifest.uuid index c76ab92b50..9f54e8112d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dddd7e182943a1d3a9d32830e819a63f1a228d6d \ No newline at end of file +b9b77972d88171e4239b8194f308eb5d60b5d172 \ No newline at end of file diff --git a/test/fts3matchinfo.test b/test/fts3matchinfo.test index 2681d0068f..b17d7da0a5 100644 --- a/test/fts3matchinfo.test +++ b/test/fts3matchinfo.test @@ -507,10 +507,49 @@ foreach {tn expr res} { } } { - do_execsql_test 11.1.$tn { + do_execsql_test 11.1.$tn.1 { SELECT rowid, mit(matchinfo(tt, 'y')) FROM tt WHERE tt MATCH $expr } $res + + set r2 [list] + foreach {rowid L} $res { + lappend r2 $rowid + set M [list] + foreach {a b} $L { + lappend M [expr ($a ? 1 : 0) + ($b ? 2 : 0)] + } + lappend r2 $M + } + + do_execsql_test 11.1.$tn.2 { + SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr + } $r2 + breakpoint + + do_execsql_test 11.1.$tn.2 { + SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr + } $r2 } set sqlite_fts3_enable_parentheses 0 +#--------------------------------------------------------------------------- +# Test the 'b' matchinfo flag +# +set sqlite_fts3_enable_parentheses 1 +reset_db +db func mit mit + +do_test 12.0 { + set cols [list] + for {set i 0} {$i < 50} {incr i} { lappend cols "c$i" } + execsql "CREATE VIRTUAL TABLE tt USING fts3([join $cols ,])" +} {} + +do_execsql_test 12.1 { + INSERT INTO tt (rowid, c4, c45) VALUES(1, 'abc', 'abc'); + SELECT mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH 'abc'; +} [list [list [expr 1<<4] [expr 1<<(45-32)]]] + +set sqlite_fts3_enable_parentheses 0 finish_test + diff --git a/test/fts3query.test b/test/fts3query.test index 06019d14e6..7d5ae991f7 100644 --- a/test/fts3query.test +++ b/test/fts3query.test @@ -173,8 +173,8 @@ do_select_tests 5.4 -errorformat { 4 "SELECT optimize(content) FROM t2 WHERE t2 MATCH 'history'" optimize } do_catchsql_test 5.5.1 { - SELECT matchinfo(t2, 'abc') FROM t2 WHERE t2 MATCH 'history' -} {1 {unrecognized matchinfo request: b}} + SELECT matchinfo(t2, 'abcd') FROM t2 WHERE t2 MATCH 'history' +} {1 {unrecognized matchinfo request: d}} do_execsql_test 5.5 { DROP TABLE t2 } From 753c1f56db9804069597d7e76d62bee47d7a4742 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 6 May 2015 08:43:26 +0000 Subject: [PATCH 03/33] Further optimizations for the 'y' and 'b' matchinfo operators. FossilOrigin-Name: fbd038bb57322e1ed2e1ee52f3d134594b6bfcc0 --- ext/fts3/fts3_snippet.c | 55 +++++++++++++++++++---------------------- manifest | 12 ++++----- manifest.uuid | 2 +- 3 files changed, 33 insertions(+), 36 deletions(-) diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index a0286bbb43..a317b9a3e9 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -238,27 +238,28 @@ static void fts3GetDeltaPosition(char **pp, int *piPos){ *piPos += (iVal-2); } +static int fts3ExprLHitsCb(Fts3Expr*, int, void*); + /* ** Helper function for fts3ExprIterate() (see below). */ static int fts3ExprIterate2( Fts3Expr *pExpr, /* Expression to iterate phrases of */ - int bExcludeEof, int *piPhrase, /* Pointer to phrase counter */ int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */ void *pCtx /* Second argument to pass to callback */ ){ int rc; /* Return code */ - if( bExcludeEof && pExpr->bEof ){ + if( x==fts3ExprLHitsCb && pExpr->bEof ){ rc = SQLITE_OK; }else{ int eType = pExpr->eType; /* Type of expression node pExpr */ if( eType!=FTSQUERY_PHRASE ){ assert( pExpr->pLeft && pExpr->pRight ); - rc = fts3ExprIterate2(pExpr->pLeft, bExcludeEof, piPhrase, x, pCtx); + rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx); if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){ - rc = fts3ExprIterate2(pExpr->pRight, bExcludeEof, piPhrase, x, pCtx); + rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx); } }else{ rc = x(pExpr, *piPhrase, pCtx); @@ -280,12 +281,11 @@ static int fts3ExprIterate2( */ static int fts3ExprIterate( Fts3Expr *pExpr, /* Expression to iterate phrases of */ - int bExcludeEof, /* Include nodes already at EOF */ int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */ void *pCtx /* Second argument to pass to callback */ ){ int iPhrase = 0; /* Variable used as the phrase counter */ - return fts3ExprIterate2(pExpr, bExcludeEof, &iPhrase, x, pCtx); + return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx); } /* @@ -324,7 +324,7 @@ static int fts3ExprLoadDoclists( int rc; /* Return Code */ LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */ sCtx.pCsr = pCsr; - rc = fts3ExprIterate(pCsr->pExpr, 0, fts3ExprLoadDoclistsCb, (void *)&sCtx); + rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx); if( pnPhrase ) *pnPhrase = sCtx.nPhrase; if( pnToken ) *pnToken = sCtx.nToken; return rc; @@ -338,7 +338,7 @@ static int fts3ExprPhraseCountCb(Fts3Expr *pExpr, int iPhrase, void *ctx){ } static int fts3ExprPhraseCount(Fts3Expr *pExpr){ int nPhrase = 0; - (void)fts3ExprIterate(pExpr, 0, fts3ExprPhraseCountCb, (void *)&nPhrase); + (void)fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase); return nPhrase; } @@ -554,7 +554,7 @@ static int fts3BestSnippet( sIter.nSnippet = nSnippet; sIter.nPhrase = nList; sIter.iCurrent = -1; - rc = fts3ExprIterate(pCsr->pExpr, 0, fts3SnippetFindPositions, (void*)&sIter); + rc = fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void*)&sIter); if( rc==SQLITE_OK ){ /* Set the *pmSeen output variable. */ @@ -923,7 +923,7 @@ static int fts3ExprLocalHitsCb( /* ** fts3ExprIterate() callback used to gather information for the matchinfo -** directive 'y'. +** directives 'y' and 'b'. */ static int fts3ExprLHitsCb( Fts3Expr *pExpr, /* Phrase expression node */ @@ -1124,7 +1124,7 @@ static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){ aIter = sqlite3_malloc(sizeof(LcsIterator) * pCsr->nPhrase); if( !aIter ) return SQLITE_NOMEM; memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase); - (void)fts3ExprIterate(pCsr->pExpr, 0, fts3MatchinfoLcsCb, (void*)aIter); + (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter); for(i=0; inPhrase; i++){ LcsIterator *pIter = &aIter[i]; @@ -1272,7 +1272,7 @@ static int fts3MatchinfoValues( case FTS3_MATCHINFO_LHITS: { int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32); memset(pInfo->aMatchinfo, 0, nZero); - (void)fts3ExprIterate(pCsr->pExpr, 1, fts3ExprLHitsCb, (void*)pInfo); + (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLHitsCb, (void*)pInfo); break; } @@ -1287,10 +1287,10 @@ static int fts3MatchinfoValues( rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0); if( rc!=SQLITE_OK ) break; } - rc = fts3ExprIterate(pExpr, 0, fts3ExprGlobalHitsCb,(void*)pInfo); + rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo); if( rc!=SQLITE_OK ) break; } - (void)fts3ExprIterate(pExpr, 0, fts3ExprLocalHitsCb,(void*)pInfo); + (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo); break; } } @@ -1348,6 +1348,12 @@ static int fts3GetMatchinfo( /* Determine the number of integers in the buffer returned by this call. */ for(i=0; zArg[i]; i++){ + char *zErr = 0; + if( fts3MatchinfoCheck(pTab, zArg[i], &zErr) ){ + sqlite3_result_error(pCtx, zErr, -1); + sqlite3_free(zErr); + return; + } nMatchinfo += fts3MatchinfoSize(&sInfo, zArg[i]); } @@ -1589,7 +1595,7 @@ void sqlite3Fts3Offsets( */ sCtx.iCol = iCol; sCtx.iTerm = 0; - (void)fts3ExprIterate(pCsr->pExpr, 0, fts3ExprTermOffsetInit, (void*)&sCtx); + (void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx); /* Retreive the text stored in column iCol. If an SQL NULL is stored ** in column iCol, jump immediately to the next iteration of the loop. @@ -1681,19 +1687,10 @@ void sqlite3Fts3Matchinfo( const char *zArg /* Second arg to matchinfo() function */ ){ Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab; - int rc; - int i; const char *zFormat; + int rc; if( zArg ){ - for(i=0; zArg[i]; i++){ - char *zErr = 0; - if( fts3MatchinfoCheck(pTab, zArg[i], &zErr) ){ - sqlite3_result_error(pContext, zErr, -1); - sqlite3_free(zErr); - return; - } - } zFormat = zArg; }else{ zFormat = FTS3_MATCHINFO_DEFAULT; @@ -1702,11 +1699,11 @@ void sqlite3Fts3Matchinfo( if( !pCsr->pExpr ){ sqlite3_result_blob(pContext, "", 0, SQLITE_STATIC); return; + }else{ + /* Retrieve matchinfo() data. */ + rc = fts3GetMatchinfo(pContext, pCsr, zFormat); + sqlite3Fts3SegmentsClose(pTab); } - - /* Retrieve matchinfo() data. */ - rc = fts3GetMatchinfo(pContext, pCsr, zFormat); - sqlite3Fts3SegmentsClose(pTab); } #endif diff --git a/manifest b/manifest index cfd87670bf..94eecd5b55 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sfts3\smatchinfo\s'b'\sflag. -D 2015-05-05T20:39:53.730 +C Further\soptimizations\sfor\sthe\s'y'\sand\s'b'\smatchinfo\soperators. +D 2015-05-06T08:43:26.741 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -87,7 +87,7 @@ F ext/fts3/fts3_hash.c 29b986e43f4e9dd40110eafa377dc0d63c422c60 F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf F ext/fts3/fts3_icu.c e319e108661147bcca8dd511cd562f33a1ba81b5 F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009 -F ext/fts3/fts3_snippet.c 2224cdfddd4825c449bab0420549b76963f5e444 +F ext/fts3/fts3_snippet.c e03db2f3eb878849aa95e9638873d057be9aad39 F ext/fts3/fts3_term.c 88c55a6fa1a51ab494e33dced0401a6c28791fd7 F ext/fts3/fts3_test.c 8a3a78c4458b2d7c631fcf4b152a5cd656fa7038 F ext/fts3/fts3_tokenize_vtab.c a27593ab19657166f6fa5ec073b678cc29a75860 @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P dddd7e182943a1d3a9d32830e819a63f1a228d6d -R 163d76f4b269e89cdb470ec09f3dac69 +P b9b77972d88171e4239b8194f308eb5d60b5d172 +R 34e6b7f6ad3a1ef38f2174c145dcb2ec U dan -Z 5b29ad8a6cfef6f4d3b7a8b71870984c +Z b623aae8ea84248dd7625f093d4e05ab diff --git a/manifest.uuid b/manifest.uuid index 9f54e8112d..1c7e9d6f10 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b9b77972d88171e4239b8194f308eb5d60b5d172 \ No newline at end of file +fbd038bb57322e1ed2e1ee52f3d134594b6bfcc0 \ No newline at end of file From e60aedc564c6f7291143b33a90869529b1676b35 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 6 May 2015 17:41:19 +0000 Subject: [PATCH 04/33] More optimization for the 'y' and 'b' matchinfo directives. FossilOrigin-Name: 8c5b9fedfcee3ac22a222819dceb981ad94a9903 --- ext/fts3/fts3Int.h | 4 ++- ext/fts3/fts3_snippet.c | 68 +++++++++++++++++++++++++++++++++++------ manifest | 14 ++++----- manifest.uuid | 2 +- 4 files changed, 70 insertions(+), 18 deletions(-) diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index 9e98c0410f..6db20b9fae 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -428,7 +428,9 @@ struct Fts3Expr { u8 bStart; /* True if iDocid is valid */ u8 bDeferred; /* True if this expression is entirely deferred */ - u32 *aMI; + /* The following are used by the fts3_snippet.c module. */ + int iPhrase; /* Index of this phrase in matchinfo() results */ + u32 *aMI; /* See above */ }; /* diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index a317b9a3e9..90752d5037 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -288,6 +288,7 @@ static int fts3ExprIterate( return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx); } + /* ** This is an fts3ExprIterate() callback used while loading the doclists ** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also @@ -332,8 +333,7 @@ static int fts3ExprLoadDoclists( static int fts3ExprPhraseCountCb(Fts3Expr *pExpr, int iPhrase, void *ctx){ (*(int *)ctx)++; - UNUSED_PARAMETER(pExpr); - UNUSED_PARAMETER(iPhrase); + pExpr->iPhrase = iPhrase; return SQLITE_OK; } static int fts3ExprPhraseCount(Fts3Expr *pExpr){ @@ -855,6 +855,60 @@ static int fts3ColumnlistCount(char **ppCollist){ return nEntry; } +/* +** This function gathers 'y' or 'b' data for a single phrase. +*/ +static void fts3ExprLHits( + Fts3Expr *pExpr, /* Phrase expression node */ + MatchInfo *p /* Matchinfo context */ +){ + Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab; + int iStart; + Fts3Phrase *pPhrase = pExpr->pPhrase; + char *pIter = pPhrase->doclist.pList; + int iCol = 0; + + assert( p->flag==FTS3_MATCHINFO_LHITS_BM || p->flag==FTS3_MATCHINFO_LHITS ); + if( p->flag==FTS3_MATCHINFO_LHITS ){ + iStart = pExpr->iPhrase * p->nCol; + }else{ + iStart = pExpr->iPhrase * ((p->nCol + 31) / 32); + } + + while( 1 ){ + int nHit = fts3ColumnlistCount(&pIter); + if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){ + if( p->flag==FTS3_MATCHINFO_LHITS ){ + p->aMatchinfo[iStart + iCol] = (u32)nHit; + }else if( nHit ){ + p->aMatchinfo[iStart + (iCol+1)/32] |= (1 << (iCol&0x1F)); + } + } + assert( *pIter==0x00 || *pIter==0x01 ); + if( *pIter!=0x01 ) break; + pIter++; + pIter += fts3GetVarint32(pIter, &iCol); + } +} + +/* +** Gather the results for matchinfo directives 'y' and 'b'. +*/ +static void fts3ExprLHitGather( + Fts3Expr *pExpr, + MatchInfo *p +){ + assert( (pExpr->pLeft==0)==(pExpr->pRight==0) ); + if( pExpr->bEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){ + if( pExpr->pLeft ){ + fts3ExprLHitGather(pExpr->pLeft, p); + fts3ExprLHitGather(pExpr->pRight, p); + }else{ + fts3ExprLHits(pExpr, p); + } + } +} + /* ** fts3ExprIterate() callback used to collect the "global" matchinfo stats ** for a single query. @@ -1272,7 +1326,7 @@ static int fts3MatchinfoValues( case FTS3_MATCHINFO_LHITS: { int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32); memset(pInfo->aMatchinfo, 0, nZero); - (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLHitsCb, (void*)pInfo); + fts3ExprLHitGather(pCsr->pExpr, pInfo); break; } @@ -1307,7 +1361,7 @@ static int fts3MatchinfoValues( ** Populate pCsr->aMatchinfo[] with data for the current row. The ** 'matchinfo' data is an array of 32-bit unsigned integers (C type u32). */ -static int fts3GetMatchinfo( +static void fts3GetMatchinfo( sqlite3_context *pCtx, /* Return results here */ Fts3Cursor *pCsr, /* FTS3 Cursor object */ const char *zArg /* Second argument to matchinfo() function */ @@ -1339,7 +1393,6 @@ static int fts3GetMatchinfo( */ if( pCsr->pMIBuffer==0 ){ int nMatchinfo = 0; /* Number of u32 elements in match-info */ - int nArg; /* Bytes in zArg */ int i; /* Used to iterate through zArg */ /* Determine the number of phrases in the query */ @@ -1388,8 +1441,6 @@ static int fts3GetMatchinfo( int n = pCsr->pMIBuffer->nElem * sizeof(u32); sqlite3_result_blob(pCtx, aOut, n, xDestroyOut); } - - return rc; } /* @@ -1688,7 +1739,6 @@ void sqlite3Fts3Matchinfo( ){ Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab; const char *zFormat; - int rc; if( zArg ){ zFormat = zArg; @@ -1701,7 +1751,7 @@ void sqlite3Fts3Matchinfo( return; }else{ /* Retrieve matchinfo() data. */ - rc = fts3GetMatchinfo(pContext, pCsr, zFormat); + fts3GetMatchinfo(pContext, pCsr, zFormat); sqlite3Fts3SegmentsClose(pTab); } } diff --git a/manifest b/manifest index 94eecd5b55..8865d52ac5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\soptimizations\sfor\sthe\s'y'\sand\s'b'\smatchinfo\soperators. -D 2015-05-06T08:43:26.741 +C More\soptimization\sfor\sthe\s'y'\sand\s'b'\smatchinfo\sdirectives. +D 2015-05-06T17:41:19.953 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -80,14 +80,14 @@ F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d F ext/fts3/fts3.c 341e9d9a3c7615bac8e815a8937d576265b22f78 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h bf61766eeb57a6922a8458b894d85e50d1cfb04e +F ext/fts3/fts3Int.h 142837a7544dff49121b67091a71c4f7a4546b0f F ext/fts3/fts3_aux.c 9edc3655fcb287f0467d0a4b886a01c6185fe9f1 F ext/fts3/fts3_expr.c 71c063da9c2a4167fb54aec089dd5ef33a58c9cb F ext/fts3/fts3_hash.c 29b986e43f4e9dd40110eafa377dc0d63c422c60 F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf F ext/fts3/fts3_icu.c e319e108661147bcca8dd511cd562f33a1ba81b5 F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009 -F ext/fts3/fts3_snippet.c e03db2f3eb878849aa95e9638873d057be9aad39 +F ext/fts3/fts3_snippet.c aa922977437794f1db44153a3641dc13532d70bf F ext/fts3/fts3_term.c 88c55a6fa1a51ab494e33dced0401a6c28791fd7 F ext/fts3/fts3_test.c 8a3a78c4458b2d7c631fcf4b152a5cd656fa7038 F ext/fts3/fts3_tokenize_vtab.c a27593ab19657166f6fa5ec073b678cc29a75860 @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b9b77972d88171e4239b8194f308eb5d60b5d172 -R 34e6b7f6ad3a1ef38f2174c145dcb2ec +P fbd038bb57322e1ed2e1ee52f3d134594b6bfcc0 +R 780f3f117425896614672c37a51cec34 U dan -Z b623aae8ea84248dd7625f093d4e05ab +Z 685754dfb55ce5a995c9773000dc4c01 diff --git a/manifest.uuid b/manifest.uuid index 1c7e9d6f10..61a8b2cb1c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fbd038bb57322e1ed2e1ee52f3d134594b6bfcc0 \ No newline at end of file +8c5b9fedfcee3ac22a222819dceb981ad94a9903 \ No newline at end of file From 739b903e6d37e64690dbb8d1ac12f8515c52eb2d Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 6 May 2015 17:51:59 +0000 Subject: [PATCH 05/33] Remove some dead code from fts3_snippet.c. FossilOrigin-Name: 46b2d3cef5c22a9e6bd0a4f8411f17b7ec72bd18 --- ext/fts3/fts3_snippet.c | 72 ++++++----------------------------------- manifest | 12 +++---- manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 70 deletions(-) diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 90752d5037..646d7acd56 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -238,8 +238,6 @@ static void fts3GetDeltaPosition(char **pp, int *piPos){ *piPos += (iVal-2); } -static int fts3ExprLHitsCb(Fts3Expr*, int, void*); - /* ** Helper function for fts3ExprIterate() (see below). */ @@ -250,21 +248,17 @@ static int fts3ExprIterate2( void *pCtx /* Second argument to pass to callback */ ){ int rc; /* Return code */ + int eType = pExpr->eType; /* Type of expression node pExpr */ - if( x==fts3ExprLHitsCb && pExpr->bEof ){ - rc = SQLITE_OK; - }else{ - int eType = pExpr->eType; /* Type of expression node pExpr */ - if( eType!=FTSQUERY_PHRASE ){ - assert( pExpr->pLeft && pExpr->pRight ); - rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx); - if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){ - rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx); - } - }else{ - rc = x(pExpr, *piPhrase, pCtx); - (*piPhrase)++; + if( eType!=FTSQUERY_PHRASE ){ + assert( pExpr->pLeft && pExpr->pRight ); + rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx); + if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){ + rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx); } + }else{ + rc = x(pExpr, *piPhrase, pCtx); + (*piPhrase)++; } return rc; } @@ -975,54 +969,6 @@ static int fts3ExprLocalHitsCb( return rc; } -/* -** fts3ExprIterate() callback used to gather information for the matchinfo -** directives 'y' and 'b'. -*/ -static int fts3ExprLHitsCb( - Fts3Expr *pExpr, /* Phrase expression node */ - int iPhrase, /* Phrase number */ - void *pCtx /* Pointer to MatchInfo structure */ -){ - int rc = SQLITE_OK; - MatchInfo *p = (MatchInfo *)pCtx; - - /* This must be a phrase */ - assert( pExpr->pPhrase ); - - if( pExpr->iDocid==p->pCursor->iPrevId ){ - Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab; - int iStart; - Fts3Phrase *pPhrase = pExpr->pPhrase; - char *pIter = pPhrase->doclist.pList; - int iCol = 0; - - assert( p->flag==FTS3_MATCHINFO_LHITS_BM || p->flag==FTS3_MATCHINFO_LHITS ); - if( p->flag==FTS3_MATCHINFO_LHITS ){ - iStart = iPhrase * p->nCol; - }else{ - iStart = iPhrase * ((p->nCol + 31) / 32); - } - - while( 1 ){ - int nHit = fts3ColumnlistCount(&pIter); - if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){ - if( p->flag==FTS3_MATCHINFO_LHITS ){ - p->aMatchinfo[iStart + iCol] = (u32)nHit; - }else if( nHit ){ - p->aMatchinfo[iStart + (iCol+1)/32] |= (1 << (iCol&0x1F)); - } - } - assert( *pIter==0x00 || *pIter==0x01 ); - if( *pIter!=0x01 ) break; - pIter++; - pIter += fts3GetVarint32(pIter, &iCol); - } - } - - return rc; -} - static int fts3MatchinfoCheck( Fts3Table *pTab, char cArg, diff --git a/manifest b/manifest index 8865d52ac5..860da89670 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\soptimization\sfor\sthe\s'y'\sand\s'b'\smatchinfo\sdirectives. -D 2015-05-06T17:41:19.953 +C Remove\ssome\sdead\scode\sfrom\sfts3_snippet.c. +D 2015-05-06T17:51:59.283 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -87,7 +87,7 @@ F ext/fts3/fts3_hash.c 29b986e43f4e9dd40110eafa377dc0d63c422c60 F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf F ext/fts3/fts3_icu.c e319e108661147bcca8dd511cd562f33a1ba81b5 F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009 -F ext/fts3/fts3_snippet.c aa922977437794f1db44153a3641dc13532d70bf +F ext/fts3/fts3_snippet.c b7aaa8698096b26e1c6eb563e317409323398142 F ext/fts3/fts3_term.c 88c55a6fa1a51ab494e33dced0401a6c28791fd7 F ext/fts3/fts3_test.c 8a3a78c4458b2d7c631fcf4b152a5cd656fa7038 F ext/fts3/fts3_tokenize_vtab.c a27593ab19657166f6fa5ec073b678cc29a75860 @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P fbd038bb57322e1ed2e1ee52f3d134594b6bfcc0 -R 780f3f117425896614672c37a51cec34 +P 8c5b9fedfcee3ac22a222819dceb981ad94a9903 +R 9c0ae1ced8b4f8180762181541a87277 U dan -Z 685754dfb55ce5a995c9773000dc4c01 +Z 598498d40245cf3b5c2dae507eb1e6dd diff --git a/manifest.uuid b/manifest.uuid index 61a8b2cb1c..342085a825 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c5b9fedfcee3ac22a222819dceb981ad94a9903 \ No newline at end of file +46b2d3cef5c22a9e6bd0a4f8411f17b7ec72bd18 \ No newline at end of file From 857df26b856d7017607dc0e3f6bf5f409d606653 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 May 2015 14:41:56 +0000 Subject: [PATCH 06/33] Enhance the dbstat virtual table with the ability to analyze ATTACHed databases. FossilOrigin-Name: 25ec09400b753fcb10a2aae57eb43dbf0548b7ca --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/dbstat.c | 34 ++++++++++++++++++++++++++-------- test/stat.test | 10 ++++++++-- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index b7d0b1b60e..0cbe50bfcb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.8.10 -D 2015-05-07T11:53:08.287 +C Enhance\sthe\sdbstat\svirtual\stable\swith\sthe\sability\sto\sanalyze\sATTACHed\ndatabases. +D 2015-05-07T14:41:56.372 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -181,7 +181,7 @@ F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac -F src/dbstat.c 1eacd310212b5ae59b7be645a06de8f8bbe0b5d6 +F src/dbstat.c a9c0550fe90b765e1ac38760e1822bb7a1dfe857 F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e F src/expr.c 3fb2ab3ab69d15b4b75ae53fceb4e317f64cb306 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -902,7 +902,7 @@ F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b F test/speedtest1.c 2b416dca3a155fcaa849540b2e7fc1df12896c23 F test/spellfix.test 24f676831acddd2f4056a598fd731a72c6311f49 F test/sqllimits1.test e05786eaed7950ff6a2d00031d001d8a26131e68 -F test/stat.test 76fd746b85459e812a0193410fb599f0531f22de +F test/stat.test 8de91498c99f5298b303f70f1d1f3b9557af91bf F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1 F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9 F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f @@ -1256,10 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5f2539da8cb9df99029ab4ab7023804722697673 -R 014968d54fc9fdc23120a39f420a5f8f -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.8.10 * +P cf975957b9ae671f34bb65f049acf351e650d437 +R e2036c834faa435fbd4ece874ab9ac24 U drh -Z 6270ca72fe7be4337004b813fe656c7c +Z cef1b7912e822bf40819db2b70a8eba6 diff --git a/manifest.uuid b/manifest.uuid index 8e4d2fce57..dde28b002b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cf975957b9ae671f34bb65f049acf351e650d437 \ No newline at end of file +25ec09400b753fcb10a2aae57eb43dbf0548b7ca \ No newline at end of file diff --git a/src/dbstat.c b/src/dbstat.c index fb5a52b791..8351926dcc 100644 --- a/src/dbstat.c +++ b/src/dbstat.c @@ -122,6 +122,7 @@ struct StatCursor { struct StatTable { sqlite3_vtab base; sqlite3 *db; + int iDb; /* Index of database to analyze */ }; #ifndef get2byte @@ -140,7 +141,17 @@ static int statConnect( ){ StatTable *pTab = 0; int rc = SQLITE_OK; + int iDb; + if( argc>=4 ){ + iDb = sqlite3FindDbName(db, argv[3]); + if( iDb<0 ){ + *pzErr = sqlite3_mprintf("no such database: %s", argv[3]); + return SQLITE_ERROR; + } + }else{ + iDb = 0; + } rc = sqlite3_declare_vtab(db, VTAB_SCHEMA); if( rc==SQLITE_OK ){ pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable)); @@ -151,6 +162,7 @@ static int statConnect( if( rc==SQLITE_OK ){ memset(pTab, 0, sizeof(StatTable)); pTab->db = db; + pTab->iDb = iDb; } *ppVtab = (sqlite3_vtab*)pTab; @@ -205,16 +217,22 @@ static int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ if( pCsr==0 ){ rc = SQLITE_NOMEM; }else{ + char *zSql; memset(pCsr, 0, sizeof(StatCursor)); pCsr->base.pVtab = pVTab; - rc = sqlite3_prepare_v2(pTab->db, + zSql = sqlite3_mprintf( "SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type" " UNION ALL " - "SELECT name, rootpage, type FROM sqlite_master WHERE rootpage!=0" - " ORDER BY name", -1, - &pCsr->pStmt, 0 - ); + "SELECT name, rootpage, type" + " FROM \"%w\".sqlite_master WHERE rootpage!=0" + " ORDER BY name", pTab->db->aDb[pTab->iDb].zName); + if( zSql==0 ){ + rc = SQLITE_NOMEM; + }else{ + rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0); + sqlite3_free(zSql); + } if( rc!=SQLITE_OK ){ sqlite3_free(pCsr); pCsr = 0; @@ -380,7 +398,7 @@ static int statDecodePage(Btree *pBt, StatPage *p){ */ static void statSizeAndOffset(StatCursor *pCsr){ StatTable *pTab = (StatTable *)((sqlite3_vtab_cursor *)pCsr)->pVtab; - Btree *pBt = pTab->db->aDb[0].pBt; + Btree *pBt = pTab->db->aDb[pTab->iDb].pBt; Pager *pPager = sqlite3BtreePager(pBt); sqlite3_file *fd; sqlite3_int64 x[2]; @@ -394,7 +412,7 @@ static void statSizeAndOffset(StatCursor *pCsr){ */ fd = sqlite3PagerFile(pPager); x[0] = pCsr->iPageno; - if( sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){ + if( fd->pMethods!=0 && sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){ pCsr->iOffset = x[0]; pCsr->szPage = (int)x[1]; } @@ -408,7 +426,7 @@ static int statNext(sqlite3_vtab_cursor *pCursor){ int nPayload; StatCursor *pCsr = (StatCursor *)pCursor; StatTable *pTab = (StatTable *)pCursor->pVtab; - Btree *pBt = pTab->db->aDb[0].pBt; + Btree *pBt = pTab->db->aDb[pTab->iDb].pBt; Pager *pPager = sqlite3BtreePager(pBt); sqlite3_free(pCsr->zPath); diff --git a/test/stat.test b/test/stat.test index f0447e4509..57c1b9eae1 100644 --- a/test/stat.test +++ b/test/stat.test @@ -166,8 +166,10 @@ sqlite3 db test.db register_dbstat_vtab db do_execsql_test stat-5.1 { PRAGMA auto_vacuum = OFF; - CREATE VIRTUAL TABLE temp.stat USING dbstat; - CREATE TABLE t1(x); + CREATE TABLE tx(y); + ATTACH ':memory:' AS aux1; + CREATE VIRTUAL TABLE temp.stat USING dbstat(aux1); + CREATE TABLE aux1.t1(x); INSERT INTO t1 VALUES(zeroblob(1513)); INSERT INTO t1 VALUES(zeroblob(1514)); SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload @@ -178,4 +180,8 @@ do_execsql_test stat-5.1 { t1 /001+000000 4 overflow 0 1020 0 0 \ ] +do_catchsql_test stat-6.1 { + CREATE VIRTUAL TABLE temp.s2 USING dbstat(mainx); +} {1 {no such database: mainx}} + finish_test From 5f36a833297253a88ffa7dd028d9c50e76367b67 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 May 2015 18:29:04 +0000 Subject: [PATCH 07/33] Testing improvements and corner-case bug fixes for the dbstat virtual table. FossilOrigin-Name: d51ce539327b4807150b030a10bb105fa34cbc24 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/dbstat.c | 19 ++++++++++++------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 0cbe50bfcb..a505bd9b18 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\sdbstat\svirtual\stable\swith\sthe\sability\sto\sanalyze\sATTACHed\ndatabases. -D 2015-05-07T14:41:56.372 +C Testing\simprovements\sand\scorner-case\sbug\sfixes\sfor\sthe\sdbstat\svirtual\stable. +D 2015-05-07T18:29:04.911 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -181,7 +181,7 @@ F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac -F src/dbstat.c a9c0550fe90b765e1ac38760e1822bb7a1dfe857 +F src/dbstat.c db36fbd268f778ea1cdb8b0c1eb9828c1f10bf70 F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e F src/expr.c 3fb2ab3ab69d15b4b75ae53fceb4e317f64cb306 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P cf975957b9ae671f34bb65f049acf351e650d437 -R e2036c834faa435fbd4ece874ab9ac24 +P 25ec09400b753fcb10a2aae57eb43dbf0548b7ca +R a722e2e22e0813a5eab44a056c8ee5fc U drh -Z cef1b7912e822bf40819db2b70a8eba6 +Z 6e76fa3acb898a213eb3b606e7343836 diff --git a/manifest.uuid b/manifest.uuid index dde28b002b..20d14f8a2c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -25ec09400b753fcb10a2aae57eb43dbf0548b7ca \ No newline at end of file +d51ce539327b4807150b030a10bb105fa34cbc24 \ No newline at end of file diff --git a/src/dbstat.c b/src/dbstat.c index 8351926dcc..64cd5d8120 100644 --- a/src/dbstat.c +++ b/src/dbstat.c @@ -424,6 +424,7 @@ static void statSizeAndOffset(StatCursor *pCsr){ static int statNext(sqlite3_vtab_cursor *pCursor){ int rc; int nPayload; + char *z; StatCursor *pCsr = (StatCursor *)pCursor; StatTable *pTab = (StatTable *)pCursor->pVtab; Btree *pBt = pTab->db->aDb[pTab->iDb].pBt; @@ -446,8 +447,9 @@ statNextRestart: rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg); pCsr->aPage[0].iPgno = iRoot; pCsr->aPage[0].iCell = 0; - pCsr->aPage[0].zPath = sqlite3_mprintf("/"); + pCsr->aPage[0].zPath = z = sqlite3_mprintf("/"); pCsr->iPage = 0; + if( z==0 ) rc = SQLITE_NOMEM; }else{ pCsr->isEof = 1; return sqlite3_reset(pCsr->pStmt); @@ -470,7 +472,7 @@ statNextRestart: pCsr->zPagetype = "overflow"; pCsr->nCell = 0; pCsr->nMxPayload = 0; - pCsr->zPath = sqlite3_mprintf( + pCsr->zPath = z = sqlite3_mprintf( "%s%.3x+%.6x", p->zPath, p->iCell, pCell->iOvfl ); if( pCell->iOvflnOvfl-1 ){ @@ -482,7 +484,7 @@ statNextRestart: } pCell->iOvfl++; statSizeAndOffset(pCsr); - return SQLITE_OK; + return z==0 ? SQLITE_NOMEM : SQLITE_OK; } if( p->iRightChildPg ) break; p->iCell++; @@ -504,8 +506,9 @@ statNextRestart: } rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg); p[1].iCell = 0; - p[1].zPath = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell); + p[1].zPath = z = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell); p->iCell++; + if( z==0 ) rc = SQLITE_NOMEM; } @@ -538,7 +541,8 @@ statNextRestart: pCsr->nCell = p->nCell; pCsr->nUnused = p->nUnused; pCsr->nMxPayload = p->nMxPayload; - pCsr->zPath = sqlite3_mprintf("%s", p->zPath); + pCsr->zPath = z = sqlite3_mprintf("%s", p->zPath); + if( z==0 ) rc = SQLITE_NOMEM; nPayload = 0; for(i=0; inCell; i++){ nPayload += p->aCell[i].nLocal; @@ -574,7 +578,7 @@ static int statColumn( StatCursor *pCsr = (StatCursor *)pCursor; switch( i ){ case 0: /* name */ - sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_STATIC); + sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_TRANSIENT); break; case 1: /* path */ sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT); @@ -600,7 +604,8 @@ static int statColumn( case 8: /* pgoffset */ sqlite3_result_int64(ctx, pCsr->iOffset); break; - case 9: /* pgsize */ + default: /* pgsize */ + assert( i==9 ); sqlite3_result_int(ctx, pCsr->szPage); break; } From cda9a933bd1b4b6291624239a97837885c743b20 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 May 2015 20:26:20 +0000 Subject: [PATCH 08/33] Add an entry to sqlite3_compileoption_used() for SQLITE_ENABLE_DBSTAT_VTAB. FossilOrigin-Name: 480b4cb04212277ea07e230b6c13cb81a7b769b5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/ctime.c | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index a505bd9b18..24fe07767a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Testing\simprovements\sand\scorner-case\sbug\sfixes\sfor\sthe\sdbstat\svirtual\stable. -D 2015-05-07T18:29:04.911 +C Add\san\sentry\sto\ssqlite3_compileoption_used()\sfor\s\nSQLITE_ENABLE_DBSTAT_VTAB. +D 2015-05-07T20:26:20.680 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 F src/build.c 61b47073f79f31e80a05db9ce13c5ca81bf8f74e F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 -F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 +F src/ctime.c 5a0b735dc95604766f5dac73973658eef782ee8b F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac F src/dbstat.c db36fbd268f778ea1cdb8b0c1eb9828c1f10bf70 F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 25ec09400b753fcb10a2aae57eb43dbf0548b7ca -R a722e2e22e0813a5eab44a056c8ee5fc +P d51ce539327b4807150b030a10bb105fa34cbc24 +R 3b5b2e980214b28c55465333df6bca07 U drh -Z 6e76fa3acb898a213eb3b606e7343836 +Z 098e50a61d449fdf99ad3beb0a05fa07 diff --git a/manifest.uuid b/manifest.uuid index 20d14f8a2c..3d1a964159 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d51ce539327b4807150b030a10bb105fa34cbc24 \ No newline at end of file +480b4cb04212277ea07e230b6c13cb81a7b769b5 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index 4f98ffef61..9503214f50 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -75,6 +75,9 @@ static const char * const azCompileOpt[] = { #if SQLITE_ENABLE_COLUMN_METADATA "ENABLE_COLUMN_METADATA", #endif +#if SQLITE_ENABLE_DBSTAT_VTAB + "ENABLE_DBSTAT_VTAB", +#endif #if SQLITE_ENABLE_EXPENSIVE_ASSERT "ENABLE_EXPENSIVE_ASSERT", #endif From 6a1285402408fd7ce37a92c227837dc8c4895efc Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 8 May 2015 00:58:39 +0000 Subject: [PATCH 09/33] Remove a couple stray test breakpoint calls. FossilOrigin-Name: 2860cebeeaebd346de60c762aa3e51dbab008578 --- ext/rtree/rtree9.test | 1 - manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/jrnlmode.test | 1 - 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ext/rtree/rtree9.test b/ext/rtree/rtree9.test index 6479516bed..571341b2a9 100644 --- a/ext/rtree/rtree9.test +++ b/ext/rtree/rtree9.test @@ -87,7 +87,6 @@ do_catchsql_test rtree9-4.3 { # register_circle_geom db -breakpoint do_execsql_test rtree9-5.1 { CREATE VIRTUAL TABLE rt2 USING rtree(id, xmin, xmax, ymin, ymax); diff --git a/manifest b/manifest index 24fe07767a..7f48c9f23f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\sentry\sto\ssqlite3_compileoption_used()\sfor\s\nSQLITE_ENABLE_DBSTAT_VTAB. -D 2015-05-07T20:26:20.680 +C Remove\sa\scouple\sstray\stest\sbreakpoint\scalls. +D 2015-05-08T00:58:39.650 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -134,7 +134,7 @@ F ext/rtree/rtree5.test 6a510494f12454bf57ef28f45bc7764ea279431e F ext/rtree/rtree6.test 773a90db2dce6a8353dd0d5b64bca69b29761196 F ext/rtree/rtree7.test 1fa710b9e6bf997a0c1a537b81be7bb6fded1971 F ext/rtree/rtree8.test db79c812f9e4a11f9b1f3f9934007884610a713a -F ext/rtree/rtree9.test d86ebf08ff6328895613ed577dd8a2a37c472c34 +F ext/rtree/rtree9.test b5eb13849545dfd271a54ff16784cb00d8792aea F ext/rtree/rtreeA.test ace05e729a36e342d40cf94e9efc7b4723d9dcdf F ext/rtree/rtreeB.test c85f9ce78766c4e68b8b89fbf2979ee9cfa82b4e F ext/rtree/rtreeC.test df158dcc81f1a43ce7eef361af03c48ec91f1e06 @@ -691,7 +691,7 @@ F test/join6.test cfe6503791ceb0cbb509966740286ec423cbf10b F test/journal1.test 69abc726c51b4a0409189f9a85191205297c0577 F test/journal2.test ae06f566c28552c313ded3fee79a6c69e6d049b1 F test/journal3.test ff8af941f9e06161d3db1b46bb9f965ff0e7f307 -F test/jrnlmode.test 6014ba5c11d66ff8bc7d87a7a2abc5c54be73b2e +F test/jrnlmode.test 7864d59cf7f6e552b9b99ba0f38acd167edc10fa F test/jrnlmode2.test 81610545a4e6ed239ea8fa661891893385e23a1d F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d51ce539327b4807150b030a10bb105fa34cbc24 -R 3b5b2e980214b28c55465333df6bca07 -U drh -Z 098e50a61d449fdf99ad3beb0a05fa07 +P 480b4cb04212277ea07e230b6c13cb81a7b769b5 +R 21f625b3bd733fe1fb68391f44c5179c +U mistachkin +Z 03eb70e9ee3446ef0b4c4aefb03ea173 diff --git a/manifest.uuid b/manifest.uuid index 3d1a964159..71191b8110 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -480b4cb04212277ea07e230b6c13cb81a7b769b5 \ No newline at end of file +2860cebeeaebd346de60c762aa3e51dbab008578 \ No newline at end of file diff --git a/test/jrnlmode.test b/test/jrnlmode.test index cebbfe5638..2ba56f2b00 100644 --- a/test/jrnlmode.test +++ b/test/jrnlmode.test @@ -559,7 +559,6 @@ do_execsql_test jrnlmode-8.30 { PRAGMA journal_mode=DELETE } {delete} do_test jrnlmode-9.1 { forcedelete test2.db sqlite3 db2 test2.db - breakpoint db2 eval {CREATE TEMP TABLE t(l); PRAGMA journal_mode=off;} db2 close } {} From 2c1820c824bfa79128057231f8cf2b6f9722d0fa Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 8 May 2015 01:04:39 +0000 Subject: [PATCH 10/33] Fix harmless compiler warning with MSVC. FossilOrigin-Name: 902d0cb8e31cf816ab054caccff24172a041160d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 7f48c9f23f..c69518fc39 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sa\scouple\sstray\stest\sbreakpoint\scalls. -D 2015-05-08T00:58:39.650 +C Fix\sharmless\scompiler\swarning\swith\sMSVC. +D 2015-05-08T01:04:39.640 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -232,7 +232,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 99eabf7eff0bfa65b75939b46caa82e2b2133f28 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 1b0bfc7d59e48c26b895a6b719157111a617d9e3 -F src/shell.c 1b6fc902d4455b7a4d6d9cc9a23d3f6af7089302 +F src/shell.c 07dda7cd692911d2f22269953418d049f2e2c0ee F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 480b4cb04212277ea07e230b6c13cb81a7b769b5 -R 21f625b3bd733fe1fb68391f44c5179c +P 2860cebeeaebd346de60c762aa3e51dbab008578 +R 2b88857e5f693a4a1c565ce1e1d17d93 U mistachkin -Z 03eb70e9ee3446ef0b4c4aefb03ea173 +Z 9082451360a5e29f616c75443f8db35c diff --git a/manifest.uuid b/manifest.uuid index 71191b8110..f15851fa9e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2860cebeeaebd346de60c762aa3e51dbab008578 \ No newline at end of file +902d0cb8e31cf816ab054caccff24172a041160d \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 542381a8ca..7db8dbda0a 100644 --- a/src/shell.c +++ b/src/shell.c @@ -3258,7 +3258,8 @@ static int do_meta_command(char *zLine, ShellState *p){ goto meta_command_exit; } if( nArg==3 ){ - sqlite3_limit(p->db, aLimit[iLimit].limitCode, integerValue(azArg[2])); + sqlite3_limit(p->db, aLimit[iLimit].limitCode, + (int)integerValue(azArg[2])); } printf("%20s %d\n", aLimit[iLimit].zLimitName, sqlite3_limit(p->db, aLimit[iLimit].limitCode, -1)); From 31aa001fcfdcc676faa9a50afe63108bb4605077 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 9 May 2015 10:27:19 +0000 Subject: [PATCH 11/33] Bump the version number to 3.8.10.1 FossilOrigin-Name: 9c6bf0c1865896c83ca69bf7f2e37735a71ca9a6 --- VERSION | 2 +- configure | 18 +++++++++--------- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/VERSION b/VERSION index d20cc2bf02..f2f3a0b554 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.8.10 +3.8.10.1 diff --git a/configure b/configure index 9a3d102a8a..5cd30ee4a0 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.62 for sqlite 3.8.10. +# Generated by GNU Autoconf 2.62 for sqlite 3.8.10.1. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. @@ -743,8 +743,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.8.10' -PACKAGE_STRING='sqlite 3.8.10' +PACKAGE_VERSION='3.8.10.1' +PACKAGE_STRING='sqlite 3.8.10.1' PACKAGE_BUGREPORT='' # Factoring default headers for most tests. @@ -1481,7 +1481,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.8.10 to adapt to many kinds of systems. +\`configure' configures sqlite 3.8.10.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1546,7 +1546,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.8.10:";; + short | recursive ) echo "Configuration of sqlite 3.8.10.1:";; esac cat <<\_ACEOF @@ -1660,7 +1660,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.8.10 +sqlite configure 3.8.10.1 generated by GNU Autoconf 2.62 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1674,7 +1674,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.8.10, which was +It was created by sqlite $as_me 3.8.10.1, which was generated by GNU Autoconf 2.62. Invocation command line was $ $0 $@ @@ -13953,7 +13953,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.8.10, which was +This file was extended by sqlite $as_me 3.8.10.1, which was generated by GNU Autoconf 2.62. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14006,7 +14006,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -sqlite config.status 3.8.10 +sqlite config.status 3.8.10.1 configured by $0, generated by GNU Autoconf 2.62, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/manifest b/manifest index c69518fc39..77527d5165 100644 --- a/manifest +++ b/manifest @@ -1,12 +1,12 @@ -C Fix\sharmless\scompiler\swarning\swith\sMSVC. -D 2015-05-08T01:04:39.640 +C Bump\sthe\sversion\snumber\sto\s3.8.10.1 +D 2015-05-09T10:27:19.293 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.msc c6241f7fa2912427410ef15429c8ab5601e19a71 F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 -F VERSION 2e244662b71e6e68a5c29b014ebc5b7564f4cc5a +F VERSION 8af05c43e00f7de32be74ff9984d792c96cdb0de F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F addopcodes.awk 9eb448a552d5c0185cf62c463f9c173cedae3811 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 @@ -38,7 +38,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 42b71ad3fe21c9e88fa59e8458ca1a6bc72eb0c0 F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 2ea5f5b58dd106da449ab598ab6e515339d7fa2a x +F configure dae9f0ec4df32a9e300befbcdbc4ff8874731357 x F configure.ac 0b775d383c536bbaafc1e46dd3cbb81a7ea11aeb F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html 334dbf6621b8fb8790297ec1abf3cfa4621709d1 @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2860cebeeaebd346de60c762aa3e51dbab008578 -R 2b88857e5f693a4a1c565ce1e1d17d93 -U mistachkin -Z 9082451360a5e29f616c75443f8db35c +P 902d0cb8e31cf816ab054caccff24172a041160d +R 52ad5aed0a515212a5cae24455eec5a5 +U drh +Z da5e3350e7e0689381d9911f0c40bc05 diff --git a/manifest.uuid b/manifest.uuid index f15851fa9e..96510bc842 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -902d0cb8e31cf816ab054caccff24172a041160d \ No newline at end of file +9c6bf0c1865896c83ca69bf7f2e37735a71ca9a6 \ No newline at end of file From a16cd04b430c0d8e3b51fe3db94a99b88ca156b5 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 9 May 2015 12:14:55 +0000 Subject: [PATCH 12/33] Version 3.8.10.1 FossilOrigin-Name: 05b4b1f2a937c06c90db70c09890038f6c98ec40 --- manifest | 11 +++++++---- manifest.uuid | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/manifest b/manifest index 77527d5165..c852904b46 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bump\sthe\sversion\snumber\sto\s3.8.10.1 -D 2015-05-09T10:27:19.293 +C Version\s3.8.10.1 +D 2015-05-09T12:14:55.159 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1256,7 +1256,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 902d0cb8e31cf816ab054caccff24172a041160d +P 9c6bf0c1865896c83ca69bf7f2e37735a71ca9a6 R 52ad5aed0a515212a5cae24455eec5a5 +T +bgcolor * #d0c0ff +T +sym-release * +T +sym-version-3.8.10.1 * U drh -Z da5e3350e7e0689381d9911f0c40bc05 +Z 2f070bdd5b3f9c1cfd8326cf20ed9566 diff --git a/manifest.uuid b/manifest.uuid index 96510bc842..44fa39d1cc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9c6bf0c1865896c83ca69bf7f2e37735a71ca9a6 \ No newline at end of file +05b4b1f2a937c06c90db70c09890038f6c98ec40 \ No newline at end of file From df5e1a00de2a3f75f03e5f2ee457b1ce48a2420c Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 10 May 2015 02:01:08 +0000 Subject: [PATCH 13/33] Fix the sqlite3_memory_used() and sqlite3_memory_highwater() interfaces so that they really do provide a 64-bit answer. FossilOrigin-Name: 8a0d5d5e9a4515603c47e9354af47550155a6f2d --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/malloc.c | 14 +++++--------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index c852904b46..1139d40711 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.8.10.1 -D 2015-05-09T12:14:55.159 +C Fix\sthe\ssqlite3_memory_used()\sand\ssqlite3_memory_highwater()\sinterfaces\sso\nthat\sthey\sreally\sdo\sprovide\sa\s64-bit\sanswer. +D 2015-05-10T02:01:08.271 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -197,7 +197,7 @@ F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770 F src/loadext.c 29255bbe1cfb2ce9bbff2526a5ecfddcb49b9271 F src/main.c 331fda6b255ae6a08e6ade89f0ac1d158691f3c6 -F src/malloc.c 6a370b83d54e4bbf6f94021221c2a311cff26a18 +F src/malloc.c 5bc15d525811d387b37c29f2e368143460e41e96 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987 F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 @@ -1256,10 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9c6bf0c1865896c83ca69bf7f2e37735a71ca9a6 -R 52ad5aed0a515212a5cae24455eec5a5 -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.8.10.1 * +P 05b4b1f2a937c06c90db70c09890038f6c98ec40 +R 9b6fcbbc8ca8af1c1035670670115add U drh -Z 2f070bdd5b3f9c1cfd8326cf20ed9566 +Z 0488f0f2f633ca7ffcc2d7caebddb063 diff --git a/manifest.uuid b/manifest.uuid index 44fa39d1cc..b9a773b53e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -05b4b1f2a937c06c90db70c09890038f6c98ec40 \ No newline at end of file +8a0d5d5e9a4515603c47e9354af47550155a6f2d \ No newline at end of file diff --git a/src/malloc.c b/src/malloc.c index f06e27d846..70b834579d 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -226,10 +226,8 @@ void sqlite3MallocEnd(void){ ** Return the amount of memory currently checked out. */ sqlite3_int64 sqlite3_memory_used(void){ - int n, mx; - sqlite3_int64 res; - sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, 0); - res = (sqlite3_int64)n; /* Work around bug in Borland C. Ticket #3216 */ + sqlite3_int64 res, mx; + sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &res, &mx, 0); return res; } @@ -239,11 +237,9 @@ sqlite3_int64 sqlite3_memory_used(void){ ** or since the most recent reset. */ sqlite3_int64 sqlite3_memory_highwater(int resetFlag){ - int n, mx; - sqlite3_int64 res; - sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, resetFlag); - res = (sqlite3_int64)mx; /* Work around bug in Borland C. Ticket #3216 */ - return res; + sqlite3_int64 res, mx; + sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &res, &mx, resetFlag); + return mx; } /* From 1fef289133ffd341e01da9e037faace4fef488b7 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 11 May 2015 06:22:22 +0000 Subject: [PATCH 14/33] Change autoconf/Makefile.am to avoid building target sqlite3.o as part of both the shared library and shell tool. Doing so causes problems for parallel builds. FossilOrigin-Name: 85bfa9a67f9970843c55c3fbe0ec44ace6985896 --- autoconf/Makefile.am | 5 +++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/autoconf/Makefile.am b/autoconf/Makefile.am index 88bc23df45..60d2ba2673 100644 --- a/autoconf/Makefile.am +++ b/autoconf/Makefile.am @@ -6,8 +6,9 @@ libsqlite3_la_SOURCES = sqlite3.c libsqlite3_la_LDFLAGS = -no-undefined -version-info 8:6:8 bin_PROGRAMS = sqlite3 -sqlite3_SOURCES = shell.c sqlite3.h -sqlite3_LDADD = sqlite3.$(OBJEXT) @READLINE_LIBS@ +sqlite3_SOURCES = shell.c sqlite3.c sqlite3.h +sqlite3_LDADD = @READLINE_LIBS@ +sqlite3_CFLAGS = $(AM_CFLAGS) include_HEADERS = sqlite3.h sqlite3ext.h diff --git a/manifest b/manifest index 1139d40711..367e02a4b7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\ssqlite3_memory_used()\sand\ssqlite3_memory_highwater()\sinterfaces\sso\nthat\sthey\sreally\sdo\sprovide\sa\s64-bit\sanswer. -D 2015-05-10T02:01:08.271 +C Change\sautoconf/Makefile.am\sto\savoid\sbuilding\starget\ssqlite3.o\sas\spart\sof\sboth\sthe\sshared\slibrary\sand\sshell\stool.\sDoing\sso\scauses\sproblems\sfor\sparallel\sbuilds. +D 2015-05-11T06:22:22.935 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -13,7 +13,7 @@ F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 -F autoconf/Makefile.am 4012e106208c7b86ba54d06e9ed400b59a4dee6b +F autoconf/Makefile.am 27de1af382c82e81f1fe36a7f38528fba004eb1a F autoconf/README 14458f1046c118efa721aadec5f227e876d3cd38 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/config.guess 94cc57e2a3fdb9c235b362ace86d77e89d188cad x @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 05b4b1f2a937c06c90db70c09890038f6c98ec40 -R 9b6fcbbc8ca8af1c1035670670115add -U drh -Z 0488f0f2f633ca7ffcc2d7caebddb063 +P 8a0d5d5e9a4515603c47e9354af47550155a6f2d +R 3193d17811806f4a9cbdb09f2be5bd14 +U dan +Z 11303427faf9306de18929db0c47633e diff --git a/manifest.uuid b/manifest.uuid index b9a773b53e..04374a848e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8a0d5d5e9a4515603c47e9354af47550155a6f2d \ No newline at end of file +85bfa9a67f9970843c55c3fbe0ec44ace6985896 \ No newline at end of file From 3e0327d5deadbfbf8550456b338d128f35c48bca Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 May 2015 11:59:15 +0000 Subject: [PATCH 15/33] Revamp the way the DBSTAT virtual table is registered. FossilOrigin-Name: 4e6520159e729b6ea96ccdb14f0ecb00a0ff7cbd --- Makefile.in | 2 +- manifest | 24 ++++++++++++------------ manifest.uuid | 2 +- src/dbstat.c | 2 +- src/main.c | 3 +-- src/sqliteInt.h | 4 ++++ src/tclsqlite.c | 47 ----------------------------------------------- src/test1.c | 36 +++++++++++++++++++++++++++++++++++- 8 files changed, 55 insertions(+), 65 deletions(-) diff --git a/Makefile.in b/Makefile.in index 0591150148..b706c84b6e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -995,7 +995,7 @@ smoketest: testfixture$(TEXE) fuzzershell$(TEXE) sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl echo "#define TCLSH 2" > $@ - echo "#define SQLITE_ENABLE_DBSTAT_VTAB" >> $@ + echo "#define SQLITE_ENABLE_DBSTAT_VTAB 1" >> $@ cat sqlite3.c $(TOP)/src/tclsqlite.c >> $@ echo "static const char *tclsh_main_loop(void){" >> $@ echo "static const char *zMainloop = " >> $@ diff --git a/manifest b/manifest index 367e02a4b7..e763ee54f3 100644 --- a/manifest +++ b/manifest @@ -1,7 +1,7 @@ -C Change\sautoconf/Makefile.am\sto\savoid\sbuilding\starget\ssqlite3.o\sas\spart\sof\sboth\sthe\sshared\slibrary\sand\sshell\stool.\sDoing\sso\scauses\sproblems\sfor\sparallel\sbuilds. -D 2015-05-11T06:22:22.935 +C Revamp\sthe\sway\sthe\sDBSTAT\svirtual\stable\sis\sregistered. +D 2015-05-11T11:59:15.863 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1 +F Makefile.in 72931ef100ef7dfbfc3d1f42d85da59f1aae430d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.msc c6241f7fa2912427410ef15429c8ab5601e19a71 F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 @@ -181,7 +181,7 @@ F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 5a0b735dc95604766f5dac73973658eef782ee8b F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac -F src/dbstat.c db36fbd268f778ea1cdb8b0c1eb9828c1f10bf70 +F src/dbstat.c fa5b981f37c2b4f7797b4496f1c10254e11a2f4a F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e F src/expr.c 3fb2ab3ab69d15b4b75ae53fceb4e317f64cb306 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -196,7 +196,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770 F src/loadext.c 29255bbe1cfb2ce9bbff2526a5ecfddcb49b9271 -F src/main.c 331fda6b255ae6a08e6ade89f0ac1d158691f3c6 +F src/main.c bf14bc6a321965e528d8ab30087e9440335f2e4b F src/malloc.c 5bc15d525811d387b37c29f2e368143460e41e96 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987 @@ -236,12 +236,12 @@ F src/shell.c 07dda7cd692911d2f22269953418d049f2e2c0ee F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d -F src/sqliteInt.h 20d9c59fd82774503b8953acfbcc6ecbdd9ee6aa +F src/sqliteInt.h c9f77bd02f419dcc8c644c5032c42eb29069a545 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179 F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e -F src/tclsqlite.c d4fa052d3fbb655150d4ca8eedc70384b98bfef3 -F src/test1.c 90fbedce75330d48d99eadb7d5f4223e86969585 +F src/tclsqlite.c 9111a95999edac92229c972e2c34fbc171bbb6c5 +F src/test1.c a8e09b811f70184ce65012f27f30cfee7e54f268 F src/test2.c 577961fe48961b2f2e5c8b56ee50c3f459d3359d F src/test3.c 64d2afdd68feac1bb5e2ffb8226c8c639f798622 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8a0d5d5e9a4515603c47e9354af47550155a6f2d -R 3193d17811806f4a9cbdb09f2be5bd14 -U dan -Z 11303427faf9306de18929db0c47633e +P 85bfa9a67f9970843c55c3fbe0ec44ace6985896 +R 189fc358e8ba2d525e3e3c8a3c5e8737 +U drh +Z 8b69c9f4cff7121b2fbd1c4aae9fe407 diff --git a/manifest.uuid b/manifest.uuid index 04374a848e..a2b8dd3f2c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -85bfa9a67f9970843c55c3fbe0ec44ace6985896 \ No newline at end of file +4e6520159e729b6ea96ccdb14f0ecb00a0ff7cbd \ No newline at end of file diff --git a/src/dbstat.c b/src/dbstat.c index 64cd5d8120..e0ab0cea67 100644 --- a/src/dbstat.c +++ b/src/dbstat.c @@ -621,7 +621,7 @@ static int statRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){ /* ** Invoke this routine to register the "dbstat" virtual table module */ -int sqlite3_dbstat_register(sqlite3 *db){ +int sqlite3DbstatRegister(sqlite3 *db){ static sqlite3_module dbstat_module = { 0, /* iVersion */ statConnect, /* xCreate */ diff --git a/src/main.c b/src/main.c index cc819c3fa1..83d0b99135 100644 --- a/src/main.c +++ b/src/main.c @@ -2878,8 +2878,7 @@ static int openDatabase( #ifdef SQLITE_ENABLE_DBSTAT_VTAB if( !db->mallocFailed && rc==SQLITE_OK){ - int sqlite3_dbstat_register(sqlite3*); - rc = sqlite3_dbstat_register(db); + rc = sqlite3DbstatRegister(db); } #endif diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 7b9542a96e..d809245a69 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3867,4 +3867,8 @@ int sqlite3ThreadCreate(SQLiteThread**,void*(*)(void*),void*); int sqlite3ThreadJoin(SQLiteThread*, void**); #endif +#if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST) +int sqlite3DbstatRegister(sqlite3*); +#endif + #endif /* _SQLITEINT_H_ */ diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 3e9c98664c..b44f5b8fa2 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -3706,43 +3706,6 @@ static int db_last_stmt_ptr( } #endif /* SQLITE_TEST */ -#if defined(SQLITE_TEST) || defined(SQLITE_ENABLE_DBSTAT_VTAB) -/* -** tclcmd: register_dbstat_vtab DB -** -** Cause the dbstat virtual table to be available on the connection DB -*/ -static int sqlite3RegisterDbstatCmd( - void *clientData, - Tcl_Interp *interp, - int objc, - Tcl_Obj *CONST objv[] -){ -#ifdef SQLITE_OMIT_VIRTUALTABLE - Tcl_AppendResult(interp, "dbstat not available because of " - "SQLITE_OMIT_VIRTUALTABLE", (void*)0); - return TCL_ERROR; -#else - struct SqliteDb { sqlite3 *db; }; - char *zDb; - Tcl_CmdInfo cmdInfo; - - if( objc!=2 ){ - Tcl_WrongNumArgs(interp, 1, objv, "DB"); - return TCL_ERROR; - } - - zDb = Tcl_GetString(objv[1]); - if( Tcl_GetCommandInfo(interp, zDb, &cmdInfo) ){ - int sqlite3_dbstat_register(sqlite3*); - sqlite3* db = ((struct SqliteDb*)cmdInfo.objClientData)->db; - sqlite3_dbstat_register(db); - } - return TCL_OK; -#endif /* SQLITE_OMIT_VIRTUALTABLE */ -} -#endif /* defined(SQLITE_TEST) || defined(SQLITE_ENABLE_DBSTAT_VTAB) */ - /* ** Configure the interpreter passed as the first argument to have access ** to the commands and linked variables that make up: @@ -3761,16 +3724,6 @@ static void init_all(Tcl_Interp *interp){ Md5_Init(interp); #endif - /* Install the [register_dbstat_vtab] command to access the implementation - ** of virtual table dbstat (source file test_stat.c). This command is - ** required for testfixture and sqlite3_analyzer, but not by the production - ** Tcl extension. */ -#if defined(SQLITE_TEST) || defined(SQLITE_ENABLE_DBSTAT_VTAB) - Tcl_CreateObjCommand( - interp, "register_dbstat_vtab", sqlite3RegisterDbstatCmd, 0, 0 - ); -#endif - #ifdef SQLITE_TEST { extern int Sqliteconfig_Init(Tcl_Interp*); diff --git a/src/test1.c b/src/test1.c index a87fcd859d..732ad9e049 100644 --- a/src/test1.c +++ b/src/test1.c @@ -6680,7 +6680,40 @@ static int test_bad_behavior( } return TCL_OK; } - + +/* +** tclcmd: register_dbstat_vtab DB +** +** Cause the dbstat virtual table to be available on the connection DB +*/ +static int test_register_dbstat_vtab( + void *clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ +#ifdef SQLITE_OMIT_VIRTUALTABLE + Tcl_AppendResult(interp, "dbstat not available because of " + "SQLITE_OMIT_VIRTUALTABLE", (void*)0); + return TCL_ERROR; +#else + struct SqliteDb { sqlite3 *db; }; + char *zDb; + Tcl_CmdInfo cmdInfo; + + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB"); + return TCL_ERROR; + } + + zDb = Tcl_GetString(objv[1]); + if( Tcl_GetCommandInfo(interp, zDb, &cmdInfo) ){ + sqlite3* db = ((struct SqliteDb*)cmdInfo.objClientData)->db; + sqlite3DbstatRegister(db); + } + return TCL_OK; +#endif /* SQLITE_OMIT_VIRTUALTABLE */ +} /* ** Register commands with the TCL interpreter. @@ -6752,6 +6785,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ void *clientData; } aObjCmd[] = { { "bad_behavior", test_bad_behavior, (void*)&iZero }, + { "register_dbstat_vtab", test_register_dbstat_vtab }, { "sqlite3_connection_pointer", get_sqlite_pointer, 0 }, { "sqlite3_bind_int", test_bind_int, 0 }, { "sqlite3_bind_zeroblob", test_bind_zeroblob, 0 }, From f4375446d156502b422f6deb64c9bba3672884d8 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 May 2015 12:15:45 +0000 Subject: [PATCH 16/33] Build the sqlite3_analyzer.exe and sqldiff.exe programs on "make test" and "make smoketest" and other similar test targets. FossilOrigin-Name: 1b83f2e7ddfdb488e732731f7a184d37edcad5af --- Makefile.in | 19 ++++++++++++++----- Makefile.msc | 19 ++++++++++++++----- main.mk | 18 +++++++++++++----- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 50 insertions(+), 24 deletions(-) diff --git a/Makefile.in b/Makefile.in index b706c84b6e..d137179084 100644 --- a/Makefile.in +++ b/Makefile.in @@ -510,6 +510,15 @@ EXTHDR += \ EXTHDR += \ $(TOP)/ext/rtree/sqlite3rtree.h +# executabled needed for testing +# +TESTPROGS = \ + testfixture$(TEXE) \ + sqlite3$(TEXE) \ + sqlite3_analyzer$(TEXE) \ + sqldiff$(TEXE) + + # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # @@ -955,11 +964,11 @@ testfixture$(TEXE): $(TESTFIXTURE_SRC) -o $@ $(TESTFIXTURE_SRC) $(LIBTCL) $(TLIBS) # A very detailed test running most or all test cases -fulltest: testfixture$(TEXE) sqlite3$(TEXE) fuzztest +fulltest: $(TESTPROGS) fuzztest ./testfixture$(TEXE) $(TOP)/test/all.test # Really really long testing -soaktest: testfixture$(TEXE) sqlite3$(TEXE) fuzzoomtest +soaktest: $(TESTPROGS) fuzzoomtest ./testfixture$(TEXE) $(TOP)/test/all.test -soak=1 # Do extra testing but not aeverything. @@ -976,13 +985,13 @@ fuzzoomtest: fuzzershell$(TEXE) # This is the common case. Run many tests but not those that take # a really long time. # -test: testfixture$(TEXE) sqlite3$(TEXE) fuzztest +test: $(TESTPROGS) fuzztest ./testfixture$(TEXE) $(TOP)/test/veryquick.test # Run a test using valgrind. This can take a really long time # because valgrind is so much slower than a native machine. # -valgrindtest: testfixture$(TEXE) sqlite3$(TEXE) fuzzershell$(TEXE) +valgrindtest: $(TESTPROGS) fuzzershell$(TEXE) valgrind -v ./fuzzershell$(TEXE) -f $(TOP)/test/fuzzdata1.txt OMIT_MISUSE=1 valgrind -v ./testfixture$(TEXE) $(TOP)/test/permutations.test valgrind @@ -990,7 +999,7 @@ valgrindtest: testfixture$(TEXE) sqlite3$(TEXE) fuzzershell$(TEXE) # the 60s-era electronics testing: "Turn it on and see if smoke # comes out." # -smoketest: testfixture$(TEXE) fuzzershell$(TEXE) +smoketest: $(TESTPROGS) fuzzershell$(TEXE) ./testfixture$(TEXE) $(TOP)/test/main.test sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl diff --git a/Makefile.msc b/Makefile.msc index df3985162c..013a0f3427 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1172,6 +1172,15 @@ EXTHDR = $(EXTHDR) \ EXTHDR = $(EXTHDR) \ $(TOP)\ext\rtree\sqlite3rtree.h +# executabled needed for testing +# +TESTPROGS = \ + testfixture.exe \ + sqlite3.exe \ + sqlite3_analyzer.exe \ + sqldiff.exe + + # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # @@ -1635,13 +1644,13 @@ testfixture.exe: $(TESTFIXTURE_SRC) $(LIBRESOBJS) $(HDR) extensiontest: testfixture.exe testloadext.dll .\testfixture.exe $(TOP)\test\loadext.test -fulltest: testfixture.exe sqlite3.exe fuzztest +fulltest: $(TESTPROGS) fuzztest .\testfixture.exe $(TOP)\test\all.test -soaktest: testfixture.exe sqlite3.exe fuzzoomtest +soaktest: $(TESTPROGS) fuzzoomtest .\testfixture.exe $(TOP)\test\all.test -soak=1 -fulltestonly: testfixture.exe sqlite3.exe fuzztest +fulltestonly: $(TESTPROGS) fuzztest .\testfixture.exe $(TOP)\test\full.test queryplantest: testfixture.exe sqlite3.exe @@ -1653,10 +1662,10 @@ fuzztest: fuzzershell.exe fuzzoomtest: fuzzershell.exe .\fuzzershell.exe -f $(TOP)\test\fuzzdata1.txt --oom -test: testfixture.exe sqlite3.exe fuzztest +test: $(TESTPROGS) fuzztest .\testfixture.exe $(TOP)\test\veryquick.test -smoketest: testfixture.exe +smoketest: $(TESTPROGS) .\testfixture.exe $(TOP)\test\main.test sqlite3_analyzer.c: $(SQLITE3C) $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl diff --git a/main.mk b/main.mk index 7ac686873a..6e0828be95 100644 --- a/main.mk +++ b/main.mk @@ -391,6 +391,14 @@ EXTHDR += \ EXTHDR += \ $(TOP)/ext/userauth/sqlite3userauth.h +# executabled needed for testing +# +TESTPROGS = \ + testfixture$(EXE) \ + sqlite3$(EXE) \ + sqlite3_analyzer$(EXE) \ + sqldiff$(EXE) + # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # @@ -635,13 +643,13 @@ fts3-testfixture$(EXE): sqlite3.c fts3amal.c $(TESTSRC) $(TOP)/src/tclsqlite.c $(TESTSRC) $(TOP)/src/tclsqlite.c sqlite3.c fts3amal.c \ -o testfixture$(EXE) $(LIBTCL) $(THREADLIB) -fulltest: testfixture$(EXE) sqlite3$(EXE) fuzztest +fulltest: $(TESTPROGS) fuzztest ./testfixture$(EXE) $(TOP)/test/all.test -soaktest: testfixture$(EXE) sqlite3$(EXE) fuzzoomtest +soaktest: $(TESTPROGS) fuzzoomtest ./testfixture$(EXE) $(TOP)/test/all.test -soak=1 -fulltestonly: testfixture$(EXE) sqlite3$(EXE) fuzztest +fulltestonly: $(TESTPROGS) fuzztest ./testfixture$(EXE) $(TOP)/test/full.test queryplantest: testfixture$(EXE) sqlite3$(EXE) @@ -653,13 +661,13 @@ fuzztest: fuzzershell$(EXE) fuzzoomtest: fuzzershell$(EXE) ./fuzzershell$(EXE) -f $(TOP)/test/fuzzdata1.txt --oom -test: testfixture$(EXE) sqlite3$(EXE) fuzztest +test: $(TESTPROGS) fuzztest ./testfixture$(EXE) $(TOP)/test/veryquick.test # Run a test using valgrind. This can take a really long time # because valgrind is so much slower than a native machine. # -valgrindtest: testfixture$(EXE) sqlite3$(EXE) fuzzershell$(EXE) +valgrindtest: $(TESTPROGS) fuzzershell$(EXE) valgrind -v ./fuzzershell$(EXE) -f $(TOP)/test/fuzzdata1.txt OMIT_MISUSE=1 valgrind -v ./testfixture$(EXE) $(TOP)/test/permutations.test valgrind diff --git a/manifest b/manifest index e763ee54f3..725b9adf2d 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Revamp\sthe\sway\sthe\sDBSTAT\svirtual\stable\sis\sregistered. -D 2015-05-11T11:59:15.863 +C Build\sthe\ssqlite3_analyzer.exe\sand\ssqldiff.exe\sprograms\son\s"make\stest"\nand\s"make\ssmoketest"\sand\sother\ssimilar\stest\stargets. +D 2015-05-11T12:15:45.279 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 72931ef100ef7dfbfc3d1f42d85da59f1aae430d +F Makefile.in 13f5add36234e93cbebf9153d3920623ca7fd7ab F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc c6241f7fa2912427410ef15429c8ab5601e19a71 +F Makefile.msc 042b52591ab5fe3047e2d37858e77b894f6d0ef0 F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 F VERSION 8af05c43e00f7de32be74ff9984d792c96cdb0de @@ -152,7 +152,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk f012feb95fc4acfb583f89b6f9d1dc6253a8f08d +F main.mk cb55a01d762d7dd6722232b98665843ef93d8d1e F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea F mkopcodeh.awk d5e22023b5238985bb54a72d33e0ac71fe4f8a32 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 85bfa9a67f9970843c55c3fbe0ec44ace6985896 -R 189fc358e8ba2d525e3e3c8a3c5e8737 +P 4e6520159e729b6ea96ccdb14f0ecb00a0ff7cbd +R efe77b0d0c67edf1e2c0b42f110eae7b U drh -Z 8b69c9f4cff7121b2fbd1c4aae9fe407 +Z 64fd5a5789d465ed8546db070d4d7ca4 diff --git a/manifest.uuid b/manifest.uuid index a2b8dd3f2c..a6dab124b1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4e6520159e729b6ea96ccdb14f0ecb00a0ff7cbd \ No newline at end of file +1b83f2e7ddfdb488e732731f7a184d37edcad5af \ No newline at end of file From d4ab1034c204047b91655a97acba225052da0534 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 11 May 2015 16:27:33 +0000 Subject: [PATCH 17/33] Fix minor Makefile typos. Improve consistency of MSVC makefile. Add new targets to clean. FossilOrigin-Name: f84fbe98994c602de6c0b242dcbad3ab77298425 --- Makefile.in | 8 +++++--- Makefile.msc | 11 +++++++---- main.mk | 11 ++++++++++- manifest | 18 +++++++++--------- manifest.uuid | 2 +- 5 files changed, 32 insertions(+), 18 deletions(-) diff --git a/Makefile.in b/Makefile.in index d137179084..a6984b2fd8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -510,7 +510,7 @@ EXTHDR += \ EXTHDR += \ $(TOP)/ext/rtree/sqlite3rtree.h -# executabled needed for testing +# executables needed for testing # TESTPROGS = \ testfixture$(TEXE) \ @@ -971,8 +971,8 @@ fulltest: $(TESTPROGS) fuzztest soaktest: $(TESTPROGS) fuzzoomtest ./testfixture$(TEXE) $(TOP)/test/all.test -soak=1 -# Do extra testing but not aeverything. -fulltestonly: testfixture$(TEXE) sqlite3$(TEXE) +# Do extra testing but not everything. +fulltestonly: $(TESTPROGS) ./testfixture$(TEXE) $(TOP)/test/full.test # Fuzz testing @@ -1115,6 +1115,8 @@ clean: rm -f sqlite3_analyzer$(TEXE) sqlite3_analyzer.c rm -f sqlite-*-output.vsix rm -f mptester mptester.exe + rm -f fuzzershell fuzzershell.exe + rm -f sqldiff sqldiff.exe distclean: clean rm -f config.log config.status libtool Makefile sqlite3.pc diff --git a/Makefile.msc b/Makefile.msc index 013a0f3427..487d85bfc7 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1172,7 +1172,7 @@ EXTHDR = $(EXTHDR) \ EXTHDR = $(EXTHDR) \ $(TOP)\ext\rtree\sqlite3rtree.h -# executabled needed for testing +# executables needed for testing # TESTPROGS = \ testfixture.exe \ @@ -1665,18 +1665,20 @@ fuzzoomtest: fuzzershell.exe test: $(TESTPROGS) fuzztest .\testfixture.exe $(TOP)\test\veryquick.test -smoketest: $(TESTPROGS) +smoketest: $(TESTPROGS) fuzzershell.exe .\testfixture.exe $(TOP)\test\main.test sqlite3_analyzer.c: $(SQLITE3C) $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl - copy $(SQLITE3C) + $(TOP)\src\tclsqlite.c $@ + echo #define TCLSH 2 > $@ + echo #define SQLITE_ENABLE_DBSTAT_VTAB 1 >> $@ + copy $@ + $(SQLITE3C) + $(TOP)\src\tclsqlite.c $@ echo static const char *tclsh_main_loop(void){ >> $@ echo static const char *zMainloop = >> $@ $(NAWK) -f $(TOP)\tool\tostr.awk $(TOP)\tool\spaceanal.tcl >> $@ echo ; return zMainloop; } >> $@ sqlite3_analyzer.exe: sqlite3_analyzer.c $(LIBRESOBJS) - $(LTLINK) $(NO_WARN) -DBUILD_sqlite -DSQLITE_ENABLE_DBSTAT_VTAB -DTCLSH=2 -I$(TCLINCDIR) sqlite3_analyzer.c \ + $(LTLINK) $(NO_WARN) -DBUILD_sqlite -I$(TCLINCDIR) sqlite3_analyzer.c \ /link $(LTLINKOPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LTLIBS) $(TLIBS) testloadext.lo: $(TOP)\src\test_loadext.c @@ -1746,6 +1748,7 @@ clean: del /Q shell.c sqlite3ext.h 2>NUL del /Q sqlite3_analyzer.exe sqlite3_analyzer.c 2>NUL del /Q sqlite-*-output.vsix 2>NUL + del /Q fuzzershell.exe sqldiff.exe 2>NUL # Dynamic link library section. # diff --git a/main.mk b/main.mk index 6e0828be95..a58547701c 100644 --- a/main.mk +++ b/main.mk @@ -391,7 +391,7 @@ EXTHDR += \ EXTHDR += \ $(TOP)/ext/userauth/sqlite3userauth.h -# executabled needed for testing +# executables needed for testing # TESTPROGS = \ testfixture$(EXE) \ @@ -671,6 +671,13 @@ valgrindtest: $(TESTPROGS) fuzzershell$(EXE) valgrind -v ./fuzzershell$(EXE) -f $(TOP)/test/fuzzdata1.txt OMIT_MISUSE=1 valgrind -v ./testfixture$(EXE) $(TOP)/test/permutations.test valgrind +# A very fast test that checks basic sanity. The name comes from +# the 60s-era electronics testing: "Turn it on and see if smoke +# comes out." +# +smoketest: $(TESTPROGS) fuzzershell$(EXE) + ./testfixture$(EXE) $(TOP)/test/main.test + # The next two rules are used to support the "threadtest" target. Building # threadtest runs a few thread-safety tests that are implemented in C. This # target is invoked by the releasetest.tcl script. @@ -777,3 +784,5 @@ clean: rm -f sqlite3_analyzer sqlite3_analyzer.exe sqlite3_analyzer.c rm -f sqlite-*-output.vsix rm -f mptester mptester.exe + rm -f fuzzershell fuzzershell.exe + rm -f sqldiff sqldiff.exe diff --git a/manifest b/manifest index 725b9adf2d..fbbd1c1ab5 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Build\sthe\ssqlite3_analyzer.exe\sand\ssqldiff.exe\sprograms\son\s"make\stest"\nand\s"make\ssmoketest"\sand\sother\ssimilar\stest\stargets. -D 2015-05-11T12:15:45.279 +C Fix\sminor\sMakefile\stypos.\s\sImprove\sconsistency\sof\sMSVC\smakefile.\s\sAdd\snew\stargets\sto\sclean. +D 2015-05-11T16:27:33.778 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 13f5add36234e93cbebf9153d3920623ca7fd7ab +F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 042b52591ab5fe3047e2d37858e77b894f6d0ef0 +F Makefile.msc c65882433fde5f35ff66e759938eaf2dde9f360d F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 F VERSION 8af05c43e00f7de32be74ff9984d792c96cdb0de @@ -152,7 +152,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk cb55a01d762d7dd6722232b98665843ef93d8d1e +F main.mk d49723483ee9e4fb71dc2bd0e6be58705a481e73 F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea F mkopcodeh.awk d5e22023b5238985bb54a72d33e0ac71fe4f8a32 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 @@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4e6520159e729b6ea96ccdb14f0ecb00a0ff7cbd -R efe77b0d0c67edf1e2c0b42f110eae7b -U drh -Z 64fd5a5789d465ed8546db070d4d7ca4 +P 1b83f2e7ddfdb488e732731f7a184d37edcad5af +R 9144e728928711a4d1e8e355f9e1d47b +U mistachkin +Z 7fbb5f9bc605e2a68894de61a25f2ba0 diff --git a/manifest.uuid b/manifest.uuid index a6dab124b1..23170d8f68 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1b83f2e7ddfdb488e732731f7a184d37edcad5af \ No newline at end of file +f84fbe98994c602de6c0b242dcbad3ab77298425 \ No newline at end of file From d13b2319234ddb4857b7b793ec3b26b76251a6ca Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 May 2015 17:46:14 +0000 Subject: [PATCH 18/33] Test cases for sqlite3_analyzer and sqldiff. Fix a problem with sqlite3_analyzer related to the renaming of the initialization routine. FossilOrigin-Name: 85a4a46c3bb9fd8124969c9e975086c795113b7e --- manifest | 16 +++++++------ manifest.uuid | 2 +- test/analyzer1.test | 39 +++++++++++++++++++++++++++++++ test/sqldiff1.test | 57 +++++++++++++++++++++++++++++++++++++++++++++ tool/spaceanal.tcl | 1 - 5 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 test/analyzer1.test create mode 100644 test/sqldiff1.test diff --git a/manifest b/manifest index fbbd1c1ab5..984c3ea4b5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sminor\sMakefile\stypos.\s\sImprove\sconsistency\sof\sMSVC\smakefile.\s\sAdd\snew\stargets\sto\sclean. -D 2015-05-11T16:27:33.778 +C Test\scases\sfor\ssqlite3_analyzer\sand\ssqldiff.\s\sFix\sa\sproblem\swith\s\nsqlite3_analyzer\srelated\sto\sthe\srenaming\sof\sthe\sinitialization\sroutine. +D 2015-05-11T17:46:14.438 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -334,6 +334,7 @@ F test/analyzeC.test 555a6cc388b9818b6eda6df816f01ce0a75d3a93 F test/analyzeD.test 08f9d0bee4e118a66fff3a32d02dbe0ee0a2b594 F test/analyzeE.test 8684e8ac5722fb97c251887ad97e5d496a98af1d F test/analyzeF.test 7ccd7a04f7d3061bde1a8a4dacc4792edccf6bf2 +F test/analyzer1.test 0f803d7d466d7c3e027dfe18bc412b634999995b F test/async.test 1d0e056ba1bb9729283a0f22718d3a25e82c277b F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7 @@ -901,6 +902,7 @@ F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b F test/speedtest1.c 2b416dca3a155fcaa849540b2e7fc1df12896c23 F test/spellfix.test 24f676831acddd2f4056a598fd731a72c6311f49 +F test/sqldiff1.test 4b6a8cb8619b970ac4869d3a9ec221cd314d6cae F test/sqllimits1.test e05786eaed7950ff6a2d00031d001d8a26131e68 F test/stat.test 8de91498c99f5298b303f70f1d1f3b9557af91bf F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1 @@ -1238,7 +1240,7 @@ F tool/showstat4.c 9515faa8ec176599d4a8288293ba8ec61f7b728a F tool/showwal.c 85cb36d4fe3e93e2fbd63e786e0d1ce42d0c4fad F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b -F tool/spaceanal.tcl d5a09620c66a6c144576cb9d2bdfa9a6fbe362a5 +F tool/spaceanal.tcl 713c587a057334de42c41ad9566f10e255d3ad27 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff @@ -1256,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1b83f2e7ddfdb488e732731f7a184d37edcad5af -R 9144e728928711a4d1e8e355f9e1d47b -U mistachkin -Z 7fbb5f9bc605e2a68894de61a25f2ba0 +P f84fbe98994c602de6c0b242dcbad3ab77298425 +R 07df1d707f9f5d9656bc9195b802cb19 +U drh +Z cfe7ea3673b7464899013ab57623434c diff --git a/manifest.uuid b/manifest.uuid index 23170d8f68..37ee30395b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f84fbe98994c602de6c0b242dcbad3ab77298425 \ No newline at end of file +85a4a46c3bb9fd8124969c9e975086c795113b7e \ No newline at end of file diff --git a/test/analyzer1.test b/test/analyzer1.test new file mode 100644 index 0000000000..9eac241d23 --- /dev/null +++ b/test/analyzer1.test @@ -0,0 +1,39 @@ +# 2015-05-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. +# +#*********************************************************************** +# +# Quick tests for the sqlite3_analyzer tool +# +set testdir [file dirname $argv0] +source $testdir/tester.tcl +if {$tcl_platform(platform)=="windows"} { + set PROG "sqlite3_analyzer.exe" +} else { + set PROG "./sqlite3_analyzer" +} +db close +forcedelete test.db test.db-journal test.db-wal +sqlite3 db test.db + +do_test analyzer1-1.0 { + db eval { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b); + CREATE TABLE t2(a INT PRIMARY KEY, b) WITHOUT ROWID; + WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<250) + INSERT INTO t1(a,b) SELECT x, randomblob(200) FROM c; + INSERT INTO t2(a,b) SELECT a, b FROM t1; + } + set line "exec $PROG test.db" + unset -nocomplain ::MSG + catch {eval $line} ::MSG +} {0} +do_test analyzer1-1.1 { + regexp {^/\*\* Disk-Space Utilization.*COMMIT;\W*$} $::MSG +} {1} diff --git a/test/sqldiff1.test b/test/sqldiff1.test new file mode 100644 index 0000000000..4f4cd7082c --- /dev/null +++ b/test/sqldiff1.test @@ -0,0 +1,57 @@ +# 2015-05-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. +# +#*********************************************************************** +# +# Quick tests for the sqldiff tool +# +set testdir [file dirname $argv0] +source $testdir/tester.tcl +if {$tcl_platform(platform)=="windows"} { + set PROG "sqldiff.exe" +} else { + set PROG "./sqldiff" +} +db close +forcedelete test.db test2.db +sqlite3 db test.db + +do_test sqldiff-1.0 { + db eval { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b); + CREATE TABLE t2(a INT PRIMARY KEY, b) WITHOUT ROWID; + WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100) + INSERT INTO t1(a,b) SELECT x, printf('abc-%d-xyz',x) FROM c; + INSERT INTO t2(a,b) SELECT a, b FROM t1; + } + db backup test2.db + db eval { + ATTACH 'test2.db' AS x2; + DELETE FROM x2.t1 WHERE a=49; + DELETE FROM x2.t2 WHERE a=48; + INSERT INTO x2.t1(a,b) VALUES(1234,'hello'); + INSERT INTO x2.t2(a,b) VALUES(50.5,'xyzzy'); + CREATE TABLE x2.t3(a,b,c); + INSERT INTO x2.t3 VALUES(111,222,333); + CREATE TABLE main.t4(x,y,z); + INSERT INTO t4 SELECT * FROM t3; + } + set line "exec $PROG test.db test2.db" + unset -nocomplain ::MSG + catch {eval $line} ::MSG +} {0} +do_test sqldiff-1.1 { + set ::MSG +} {DELETE FROM t1 WHERE a=49; +INSERT INTO t1(a,b) VALUES(1234,'hello'); +DELETE FROM t2 WHERE a=48; +INSERT INTO t2(a,b) VALUES(50.5,'xyzzy'); +CREATE TABLE t3(a,b,c); +INSERT INTO t3(rowid,a,b,c) VALUES(1,111,222,333); +DROP TABLE t4;} diff --git a/tool/spaceanal.tcl b/tool/spaceanal.tcl index 516d282445..cd3785bd7d 100644 --- a/tool/spaceanal.tcl +++ b/tool/spaceanal.tcl @@ -88,7 +88,6 @@ if {[catch {sqlite3 db $file_to_analyze -uri 1} msg]} { puts stderr "error trying to open $file_to_analyze: $msg" exit 1 } -register_dbstat_vtab db db eval {SELECT count(*) FROM sqlite_master} set pageSize [expr {wide([db one {PRAGMA page_size}])}] From 8906b7dbde7bfd06dbef07309d6e76e80ae8594c Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 May 2015 18:48:52 +0000 Subject: [PATCH 19/33] Add missing "finish_test" commands to the end of the two new test scripts for sqlite3_analyzer and sqldiff. FossilOrigin-Name: 1d5e72b1c4e0350c492e12f102acc41e1777ef98 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/analyzer1.test | 2 ++ test/sqldiff1.test | 2 ++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 984c3ea4b5..06e517c2f2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Test\scases\sfor\ssqlite3_analyzer\sand\ssqldiff.\s\sFix\sa\sproblem\swith\s\nsqlite3_analyzer\srelated\sto\sthe\srenaming\sof\sthe\sinitialization\sroutine. -D 2015-05-11T17:46:14.438 +C Add\smissing\s"finish_test"\scommands\sto\sthe\send\sof\sthe\stwo\snew\stest\sscripts\nfor\ssqlite3_analyzer\sand\ssqldiff. +D 2015-05-11T18:48:52.709 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -334,7 +334,7 @@ F test/analyzeC.test 555a6cc388b9818b6eda6df816f01ce0a75d3a93 F test/analyzeD.test 08f9d0bee4e118a66fff3a32d02dbe0ee0a2b594 F test/analyzeE.test 8684e8ac5722fb97c251887ad97e5d496a98af1d F test/analyzeF.test 7ccd7a04f7d3061bde1a8a4dacc4792edccf6bf2 -F test/analyzer1.test 0f803d7d466d7c3e027dfe18bc412b634999995b +F test/analyzer1.test ef9b179ac399d49eebd29a2eab1bff500cb7d5fd F test/async.test 1d0e056ba1bb9729283a0f22718d3a25e82c277b F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7 @@ -902,7 +902,7 @@ F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b F test/speedtest1.c 2b416dca3a155fcaa849540b2e7fc1df12896c23 F test/spellfix.test 24f676831acddd2f4056a598fd731a72c6311f49 -F test/sqldiff1.test 4b6a8cb8619b970ac4869d3a9ec221cd314d6cae +F test/sqldiff1.test 40e4d3b714f3a780bd7adff8b1dd1adfe1cefdf2 F test/sqllimits1.test e05786eaed7950ff6a2d00031d001d8a26131e68 F test/stat.test 8de91498c99f5298b303f70f1d1f3b9557af91bf F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1 @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f84fbe98994c602de6c0b242dcbad3ab77298425 -R 07df1d707f9f5d9656bc9195b802cb19 +P 85a4a46c3bb9fd8124969c9e975086c795113b7e +R dbcd907b1272e0530a99c0695a45d6f7 U drh -Z cfe7ea3673b7464899013ab57623434c +Z 28eaa7fe5ab9618b47710962d47606de diff --git a/manifest.uuid b/manifest.uuid index 37ee30395b..41a135a8ee 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -85a4a46c3bb9fd8124969c9e975086c795113b7e \ No newline at end of file +1d5e72b1c4e0350c492e12f102acc41e1777ef98 \ No newline at end of file diff --git a/test/analyzer1.test b/test/analyzer1.test index 9eac241d23..7658476443 100644 --- a/test/analyzer1.test +++ b/test/analyzer1.test @@ -37,3 +37,5 @@ do_test analyzer1-1.0 { do_test analyzer1-1.1 { regexp {^/\*\* Disk-Space Utilization.*COMMIT;\W*$} $::MSG } {1} + +finish_test diff --git a/test/sqldiff1.test b/test/sqldiff1.test index 4f4cd7082c..b345aee57b 100644 --- a/test/sqldiff1.test +++ b/test/sqldiff1.test @@ -55,3 +55,5 @@ INSERT INTO t2(a,b) VALUES(50.5,'xyzzy'); CREATE TABLE t3(a,b,c); INSERT INTO t3(rowid,a,b,c) VALUES(1,111,222,333); DROP TABLE t4;} + +finish_test From aa62e48cab38d976ab1288f2be18b3ef40bfc09c Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 May 2015 00:46:40 +0000 Subject: [PATCH 20/33] Fix sqldiff.exe so that it always runs in single-thread mode. FossilOrigin-Name: c223910e726131d7b718b556c83df5faa723369d --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/sqldiff.c | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 39e1dbdf06..0e1fe2c57d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\sfts3\smatchinfo\soption\s'b'.\sAlso\soptimize\sexisting\soption\s'y'. -D 2015-05-11T19:01:18.521 +C Fix\ssqldiff.exe\sso\sthat\sit\salways\sruns\sin\ssingle-thread\smode. +D 2015-05-12T00:46:40.670 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1247,7 +1247,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/sqldiff.c 10e3c01111f97b99627adf0954cf5ffbfba0723c +F tool/sqldiff.c e740816b93a27694380b45b92f9785f37f140575 F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1d5e72b1c4e0350c492e12f102acc41e1777ef98 82e5a6e088c58815140ad36715ac11c96527cb25 -R 795248e8534b4aa5326a7558d85be223 -U dan -Z ae2284b291e4689841953453008382e8 +P 2e7679a1df4020dc0166f5de8ffd664df18a3002 +R 359d8551ba323944bb8bb381428d219d +U drh +Z a4ba4cabfec9eaef7bbe324bf195de1a diff --git a/manifest.uuid b/manifest.uuid index b2c00ad996..e214addcbe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2e7679a1df4020dc0166f5de8ffd664df18a3002 \ No newline at end of file +c223910e726131d7b718b556c83df5faa723369d \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index 0b3f02cd6c..3aae46a1f4 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -1139,6 +1139,7 @@ int main(int argc, char **argv){ char **azExt = 0; g.zArgv0 = argv[0]; + sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); for(i=1; i Date: Tue, 12 May 2015 12:24:50 +0000 Subject: [PATCH 21/33] Try to get recent sqlite3_analyzer and sqldiff tests working for all tested combinations of compile-time options, especially SQLITE_OMIT_VIRTUALTABLE and SQLITE_OMIT_LOAD_EXTENSION. FossilOrigin-Name: 07c7d3925cbcf44c2f606c7f016ec56304e0ca24 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/dbstat.c | 2 ++ test/analyzer1.test | 6 ++++++ test/sqldiff1.test | 1 + tool/sqldiff.c | 4 ++++ 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 0e1fe2c57d..37a9d141f9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssqldiff.exe\sso\sthat\sit\salways\sruns\sin\ssingle-thread\smode. -D 2015-05-12T00:46:40.670 +C Try\sto\sget\srecent\ssqlite3_analyzer\sand\ssqldiff\stests\sworking\sfor\sall\ntested\scombinations\sof\scompile-time\soptions,\sespecially\nSQLITE_OMIT_VIRTUALTABLE\sand\sSQLITE_OMIT_LOAD_EXTENSION. +D 2015-05-12T12:24:50.764 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -181,7 +181,7 @@ F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 5a0b735dc95604766f5dac73973658eef782ee8b F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac -F src/dbstat.c fa5b981f37c2b4f7797b4496f1c10254e11a2f4a +F src/dbstat.c 7fd79cb56fe0535fa795ae79b0428bf1395663d9 F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e F src/expr.c 3fb2ab3ab69d15b4b75ae53fceb4e317f64cb306 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -334,7 +334,7 @@ F test/analyzeC.test 555a6cc388b9818b6eda6df816f01ce0a75d3a93 F test/analyzeD.test 08f9d0bee4e118a66fff3a32d02dbe0ee0a2b594 F test/analyzeE.test 8684e8ac5722fb97c251887ad97e5d496a98af1d F test/analyzeF.test 7ccd7a04f7d3061bde1a8a4dacc4792edccf6bf2 -F test/analyzer1.test ef9b179ac399d49eebd29a2eab1bff500cb7d5fd +F test/analyzer1.test e3bccac3be49382050464952998a631bf51e3ce1 F test/async.test 1d0e056ba1bb9729283a0f22718d3a25e82c277b F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7 @@ -902,7 +902,7 @@ F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b F test/speedtest1.c 2b416dca3a155fcaa849540b2e7fc1df12896c23 F test/spellfix.test 24f676831acddd2f4056a598fd731a72c6311f49 -F test/sqldiff1.test 40e4d3b714f3a780bd7adff8b1dd1adfe1cefdf2 +F test/sqldiff1.test e5ecfe95b3a2ff6380f0db6ea8bec246b675e122 F test/sqllimits1.test e05786eaed7950ff6a2d00031d001d8a26131e68 F test/stat.test 8de91498c99f5298b303f70f1d1f3b9557af91bf F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1 @@ -1247,7 +1247,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/sqldiff.c e740816b93a27694380b45b92f9785f37f140575 +F tool/sqldiff.c 0748c0daed08f31e5a8eab6de98ca57500e61ecf F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2e7679a1df4020dc0166f5de8ffd664df18a3002 -R 359d8551ba323944bb8bb381428d219d +P c223910e726131d7b718b556c83df5faa723369d +R e55107543f272121344d208983268384 U drh -Z a4ba4cabfec9eaef7bbe324bf195de1a +Z ab32b0f5550e44730f2f58e837fbdfe9 diff --git a/manifest.uuid b/manifest.uuid index e214addcbe..18283766c5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c223910e726131d7b718b556c83df5faa723369d \ No newline at end of file +07c7d3925cbcf44c2f606c7f016ec56304e0ca24 \ No newline at end of file diff --git a/src/dbstat.c b/src/dbstat.c index e0ab0cea67..5cc30d5ed5 100644 --- a/src/dbstat.c +++ b/src/dbstat.c @@ -646,4 +646,6 @@ int sqlite3DbstatRegister(sqlite3 *db){ }; return sqlite3_create_module(db, "dbstat", &dbstat_module, 0); } +#else /* Without the proper defines, sqlite3DbstatRegister is a no-op */ +int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; } #endif /* SQLITE_ENABLE_DBSTAT_VTAB */ diff --git a/test/analyzer1.test b/test/analyzer1.test index 7658476443..7da564ea2b 100644 --- a/test/analyzer1.test +++ b/test/analyzer1.test @@ -13,6 +13,12 @@ # set testdir [file dirname $argv0] source $testdir/tester.tcl + +ifcapable !vtab { + finish_test + return +} + if {$tcl_platform(platform)=="windows"} { set PROG "sqlite3_analyzer.exe" } else { diff --git a/test/sqldiff1.test b/test/sqldiff1.test index b345aee57b..723b7a5e13 100644 --- a/test/sqldiff1.test +++ b/test/sqldiff1.test @@ -13,6 +13,7 @@ # set testdir [file dirname $argv0] source $testdir/tester.tcl + if {$tcl_platform(platform)=="windows"} { set PROG "sqldiff.exe" } else { diff --git a/tool/sqldiff.c b/tool/sqldiff.c index 3aae46a1f4..6d72303545 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -1159,12 +1159,14 @@ int main(int argc, char **argv){ showHelp(); return 0; }else +#ifndef SQLITE_OMIT_LOAD_EXTENSION if( strcmp(z,"lib")==0 || strcmp(z,"L")==0 ){ if( i==argc-1 ) cmdlineError("missing argument to %s", argv[i]); azExt = realloc(azExt, sizeof(azExt[0])*(nExt+1)); if( azExt==0 ) cmdlineError("out of memory"); azExt[nExt++] = argv[++i]; }else +#endif if( strcmp(z,"primarykey")==0 ){ g.bSchemaPK = 1; }else @@ -1200,6 +1202,7 @@ int main(int argc, char **argv){ if( rc || zErrMsg ){ cmdlineError("\"%s\" does not appear to be a valid SQLite database", zDb1); } +#ifndef SQLITE_OMIT_LOAD_EXTENSION sqlite3_enable_load_extension(g.db, 1); for(i=0; i Date: Tue, 12 May 2015 13:32:55 +0000 Subject: [PATCH 22/33] Improvements to documentation of the sqlite3_column_xxxxx() interfaces. No code changes. FossilOrigin-Name: f1aa951a337037c18ee14e114e36314835e05926 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 21 +++++++-------------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 37a9d141f9..3211b521b7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Try\sto\sget\srecent\ssqlite3_analyzer\sand\ssqldiff\stests\sworking\sfor\sall\ntested\scombinations\sof\scompile-time\soptions,\sespecially\nSQLITE_OMIT_VIRTUALTABLE\sand\sSQLITE_OMIT_LOAD_EXTENSION. -D 2015-05-12T12:24:50.764 +C Improvements\sto\sdocumentation\sof\sthe\ssqlite3_column_xxxxx()\sinterfaces.\nNo\scode\schanges. +D 2015-05-12T13:32:55.686 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -233,7 +233,7 @@ F src/resolve.c 99eabf7eff0bfa65b75939b46caa82e2b2133f28 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 1b0bfc7d59e48c26b895a6b719157111a617d9e3 F src/shell.c 07dda7cd692911d2f22269953418d049f2e2c0ee -F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f +F src/sqlite.h.in bf3fe5eba3a5142477b8dae3cfce627c3e971455 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d F src/sqliteInt.h c9f77bd02f419dcc8c644c5032c42eb29069a545 @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c223910e726131d7b718b556c83df5faa723369d -R e55107543f272121344d208983268384 +P 07c7d3925cbcf44c2f606c7f016ec56304e0ca24 +R 232891624456fc55311da5c18d427088 U drh -Z ab32b0f5550e44730f2f58e837fbdfe9 +Z 86dda33358ab407f165215b386fe79a0 diff --git a/manifest.uuid b/manifest.uuid index 18283766c5..21e4d8b00e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -07c7d3925cbcf44c2f606c7f016ec56304e0ca24 \ No newline at end of file +f1aa951a337037c18ee14e114e36314835e05926 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 163bc69fe7..4a66626b8f 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3893,8 +3893,6 @@ int sqlite3_data_count(sqlite3_stmt *pStmt); ** KEYWORDS: {column access functions} ** METHOD: sqlite3_stmt ** -** These routines form the "result set" interface. -** ** ^These routines return information about a single column of the current ** result row of a query. ^In every case the first argument is a pointer ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] @@ -3954,13 +3952,14 @@ int sqlite3_data_count(sqlite3_stmt *pStmt); ** even empty strings, are always zero-terminated. ^The return ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. ** -** ^The object returned by [sqlite3_column_value()] is an -** [unprotected sqlite3_value] object. An unprotected sqlite3_value object -** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. +** Warning: ^The object returned by [sqlite3_column_value()] is an +** [unprotected sqlite3_value] object. In a multithreaded environment, +** an unprotected sqlite3_value object may only be used safely with +** [sqlite3_bind_value()] and [sqlite3_result_value()]. ** If the [unprotected sqlite3_value] object returned by ** [sqlite3_column_value()] is used in any other way, including calls ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], -** or [sqlite3_value_bytes()], then the behavior is undefined. +** or [sqlite3_value_bytes()], the behavior is not threadsafe. ** ** These routines attempt to convert the value where appropriate. ^For ** example, if the internal representation is FLOAT and a text result @@ -3991,12 +3990,6 @@ int sqlite3_data_count(sqlite3_stmt *pStmt); ** ** )^ ** -** The table above makes reference to standard C library functions atoi() -** and atof(). SQLite does not really use these functions. It has its -** own equivalent internal routines. The atoi() and atof() names are -** used in the table for brevity and because they are familiar to most -** C programmers. -** ** Note that when type conversions occur, pointers returned by prior ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or ** sqlite3_column_text16() may be invalidated. @@ -4021,7 +4014,7 @@ int sqlite3_data_count(sqlite3_stmt *pStmt); ** of conversion are done in place when it is possible, but sometimes they ** are not possible and in those cases prior pointers are invalidated. ** -** The safest and easiest to remember policy is to invoke these routines +** The safest policy is to invoke these routines ** in one of the following ways: ** **
    @@ -4041,7 +4034,7 @@ int sqlite3_data_count(sqlite3_stmt *pStmt); ** ^The pointers returned are valid until a type conversion occurs as ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or ** [sqlite3_finalize()] is called. ^The memory space used to hold strings -** and BLOBs is freed automatically. Do not pass the pointers returned +** and BLOBs is freed automatically. Do not pass the pointers returned ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into ** [sqlite3_free()]. ** From 10819251b793a9ee477bbd02a8a63370eea0f03d Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 May 2015 14:22:05 +0000 Subject: [PATCH 23/33] Fix a compiler warning when building with tclsqlite3.c and without SQLITE_ENABLE_DBSTAT_VTAB. FossilOrigin-Name: aad3ff257a156b572334b64aa57643ff3ea231a4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/dbstat.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 3211b521b7..d95104e767 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sdocumentation\sof\sthe\ssqlite3_column_xxxxx()\sinterfaces.\nNo\scode\schanges. -D 2015-05-12T13:32:55.686 +C Fix\sa\scompiler\swarning\swhen\sbuilding\swith\stclsqlite3.c\sand\swithout\nSQLITE_ENABLE_DBSTAT_VTAB. +D 2015-05-12T14:22:05.884 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -181,7 +181,7 @@ F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 5a0b735dc95604766f5dac73973658eef782ee8b F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac -F src/dbstat.c 7fd79cb56fe0535fa795ae79b0428bf1395663d9 +F src/dbstat.c d0b0757e491936a03768867dcfce271d28ef9a68 F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e F src/expr.c 3fb2ab3ab69d15b4b75ae53fceb4e317f64cb306 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 07c7d3925cbcf44c2f606c7f016ec56304e0ca24 -R 232891624456fc55311da5c18d427088 +P f1aa951a337037c18ee14e114e36314835e05926 +R 7fd0d11b6a2c1402aea56f1ab8267c55 U drh -Z 86dda33358ab407f165215b386fe79a0 +Z 5370d82879dee02ccaf08bd80ca71d1a diff --git a/manifest.uuid b/manifest.uuid index 21e4d8b00e..cba7135cf5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f1aa951a337037c18ee14e114e36314835e05926 \ No newline at end of file +aad3ff257a156b572334b64aa57643ff3ea231a4 \ No newline at end of file diff --git a/src/dbstat.c b/src/dbstat.c index 5cc30d5ed5..9b84c9ccf4 100644 --- a/src/dbstat.c +++ b/src/dbstat.c @@ -646,6 +646,6 @@ int sqlite3DbstatRegister(sqlite3 *db){ }; return sqlite3_create_module(db, "dbstat", &dbstat_module, 0); } -#else /* Without the proper defines, sqlite3DbstatRegister is a no-op */ +#elif defined(SQLITE_ENABLE_DBSTAT_VTAB) int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; } #endif /* SQLITE_ENABLE_DBSTAT_VTAB */ From 8755a5f50c74d3a2b7e39b63a369e89a5ad609ec Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 May 2015 19:10:18 +0000 Subject: [PATCH 24/33] Attempt to get DBSTAT to compile without warnings across all build configurations. FossilOrigin-Name: c3cbe3b06eb37b9949c5fcb0e257a845953de7a7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/dbstat.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index d95104e767..46b8084a52 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scompiler\swarning\swhen\sbuilding\swith\stclsqlite3.c\sand\swithout\nSQLITE_ENABLE_DBSTAT_VTAB. -D 2015-05-12T14:22:05.884 +C Attempt\sto\sget\sDBSTAT\sto\scompile\swithout\swarnings\sacross\sall\sbuild\nconfigurations. +D 2015-05-12T19:10:18.469 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -181,7 +181,7 @@ F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 5a0b735dc95604766f5dac73973658eef782ee8b F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac -F src/dbstat.c d0b0757e491936a03768867dcfce271d28ef9a68 +F src/dbstat.c f402e77e25089c6003d0c60b3233b9b3947d599a F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e F src/expr.c 3fb2ab3ab69d15b4b75ae53fceb4e317f64cb306 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f1aa951a337037c18ee14e114e36314835e05926 -R 7fd0d11b6a2c1402aea56f1ab8267c55 +P aad3ff257a156b572334b64aa57643ff3ea231a4 +R a7da5ff564874b4b543b1f2446af493d U drh -Z 5370d82879dee02ccaf08bd80ca71d1a +Z 76dbe37865affc77525affd7f0404dba diff --git a/manifest.uuid b/manifest.uuid index cba7135cf5..788a18d042 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aad3ff257a156b572334b64aa57643ff3ea231a4 \ No newline at end of file +c3cbe3b06eb37b9949c5fcb0e257a845953de7a7 \ No newline at end of file diff --git a/src/dbstat.c b/src/dbstat.c index 9b84c9ccf4..c36be020af 100644 --- a/src/dbstat.c +++ b/src/dbstat.c @@ -18,9 +18,9 @@ ** for an example implementation. */ +#include "sqliteInt.h" /* Requires access to internal data structures */ #if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \ && !defined(SQLITE_OMIT_VIRTUALTABLE) -#include "sqliteInt.h" /* Requires access to internal data structures */ /* ** Page paths: From ba02a63a4a18188fa9c373ce2c22fd0ccba33bf5 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 12 May 2015 19:53:15 +0000 Subject: [PATCH 25/33] Fix typo in Win32 VFS code enabled when the SQLITE_WIN32_USE_UUID compile-time option is used. FossilOrigin-Name: b33f1bacfdb34fe66b7b073e68bfac38498d6e88 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 46b8084a52..fd76aff333 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Attempt\sto\sget\sDBSTAT\sto\scompile\swithout\swarnings\sacross\sall\sbuild\nconfigurations. -D 2015-05-12T19:10:18.469 +C Fix\stypo\sin\sWin32\sVFS\scode\senabled\swhen\sthe\sSQLITE_WIN32_USE_UUID\scompile-time\soption\sis\sused. +D 2015-05-12T19:53:15.308 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -216,7 +216,7 @@ F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 23eb5f56fac54d8fe0cb204291f3b3b2d94f23fc -F src/os_win.c 2da99cf07da7db6bcb1974013abfd89ec74749b3 +F src/os_win.c 97f7828a9554d753665b6fcf7540e31c2b3d6a6e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 97110085b1321298412f1e5c37bddb95b36d9208 F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P aad3ff257a156b572334b64aa57643ff3ea231a4 -R a7da5ff564874b4b543b1f2446af493d -U drh -Z 76dbe37865affc77525affd7f0404dba +P c3cbe3b06eb37b9949c5fcb0e257a845953de7a7 +R f8a1a5e41ff600c683edb344c8800a3a +U mistachkin +Z 79fe1e789aa3c85e03551f9de21569c5 diff --git a/manifest.uuid b/manifest.uuid index 788a18d042..1a0c68cb9f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c3cbe3b06eb37b9949c5fcb0e257a845953de7a7 \ No newline at end of file +b33f1bacfdb34fe66b7b073e68bfac38498d6e88 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 0ebea5afc0..63afac81ae 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -5411,14 +5411,14 @@ static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){ UUID id; memset(&id, 0, sizeof(UUID)); osUuidCreate(&id); - memcpy(zBuf, &id, sizeof(UUID)); + memcpy(&zBuf[n], &id, sizeof(UUID)); n += sizeof(UUID); } if( sizeof(UUID)<=nBuf-n ){ UUID id; memset(&id, 0, sizeof(UUID)); osUuidCreateSequential(&id); - memcpy(zBuf, &id, sizeof(UUID)); + memcpy(&zBuf[n], &id, sizeof(UUID)); n += sizeof(UUID); } #endif From 13a24f841c86f6e8c64c9ceb1dcce8eb89e162ac Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 13 May 2015 04:50:30 +0000 Subject: [PATCH 26/33] Enhancements to the MSVC makefile. FossilOrigin-Name: 59e3e9e764440b7feaafadff74f422535d21bca2 --- Makefile.msc | 21 ++++++++++++++------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 487d85bfc7..cd39e48ab9 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -36,6 +36,13 @@ USE_STDCALL = 0 DYNAMIC_SHELL = 0 !ENDIF +# Set this non-0 to enable extra code that attempts to detect misuse of the +# SQLite API. +# +!IFNDEF API_ARMOR +API_ARMOR = 0 +!ENDIF + # If necessary, create a list of harmless compiler warnings to disable when # compiling the various tools. For the SQLite source code itself, warnings, # if any, will be disabled from within it. @@ -491,14 +498,14 @@ BCC = $(BCC) -DNDEBUG RCC = $(RCC) -DNDEBUG !ENDIF -!IF $(DEBUG)>0 -TCC = $(TCC) -DSQLITE_ENABLE_API_ARMOR -RCC = $(RCC) -DSQLITE_ENABLE_API_ARMOR +!IF $(DEBUG)>0 || $(API_ARMOR)!=0 +TCC = $(TCC) -DSQLITE_ENABLE_API_ARMOR=1 +RCC = $(RCC) -DSQLITE_ENABLE_API_ARMOR=1 !ENDIF !IF $(DEBUG)>2 -TCC = $(TCC) -DSQLITE_DEBUG -RCC = $(RCC) -DSQLITE_DEBUG +TCC = $(TCC) -DSQLITE_DEBUG=1 +RCC = $(RCC) -DSQLITE_DEBUG=1 !ENDIF !IF $(DEBUG)>4 || $(OSTRACE)!=0 @@ -507,8 +514,8 @@ RCC = $(RCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1 !ENDIF !IF $(DEBUG)>5 -TCC = $(TCC) -DSQLITE_ENABLE_IOTRACE -RCC = $(RCC) -DSQLITE_ENABLE_IOTRACE +TCC = $(TCC) -DSQLITE_ENABLE_IOTRACE=1 +RCC = $(RCC) -DSQLITE_ENABLE_IOTRACE=1 !ENDIF # Prevent warnings about "insecure" MSVC runtime library functions diff --git a/manifest b/manifest index fd76aff333..0c5a5294e3 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Fix\stypo\sin\sWin32\sVFS\scode\senabled\swhen\sthe\sSQLITE_WIN32_USE_UUID\scompile-time\soption\sis\sused. -D 2015-05-12T19:53:15.308 +C Enhancements\sto\sthe\sMSVC\smakefile. +D 2015-05-13T04:50:30.732 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc c65882433fde5f35ff66e759938eaf2dde9f360d +F Makefile.msc a9fd7fd02265aa5b3b2522f5e39d975972ff906d F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 F VERSION 8af05c43e00f7de32be74ff9984d792c96cdb0de @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c3cbe3b06eb37b9949c5fcb0e257a845953de7a7 -R f8a1a5e41ff600c683edb344c8800a3a +P b33f1bacfdb34fe66b7b073e68bfac38498d6e88 +R 786cf9bafb843a30daaea508385a36b1 U mistachkin -Z 79fe1e789aa3c85e03551f9de21569c5 +Z cf0d8cd171ac487c0fd87c289759c254 diff --git a/manifest.uuid b/manifest.uuid index 1a0c68cb9f..af09740391 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b33f1bacfdb34fe66b7b073e68bfac38498d6e88 \ No newline at end of file +59e3e9e764440b7feaafadff74f422535d21bca2 \ No newline at end of file From fcd49531c9fc2b5a75b713ac8d817f8dd722e6fa Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 May 2015 15:24:07 +0000 Subject: [PATCH 27/33] An early attempt to get indexes to work with the IS operator. This code passes tests, but much more testing is needed to verify that it works on all corner cases. FossilOrigin-Name: 6f7f1673d00d216a5aa456acb44793a14f3b3d91 --- manifest | 19 +++++++++++-------- manifest.uuid | 2 +- src/where.c | 32 +++++++++++++++++++------------- src/whereInt.h | 1 + 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 0c5a5294e3..ec12a04f7c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhancements\sto\sthe\sMSVC\smakefile. -D 2015-05-13T04:50:30.732 +C An\searly\sattempt\sto\sget\sindexes\sto\swork\swith\sthe\sIS\soperator.\s\sThis\scode\npasses\stests,\sbut\smuch\smore\stesting\sis\sneeded\sto\sverify\sthat\sit\sworks\son\nall\scorner\scases. +D 2015-05-13T15:24:07.257 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -307,8 +307,8 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c ce2cb2d06faab54d1bce3e739bec79e063dd9113 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c 85fff9c40569ccb79c3177419b339e7d7df566cb -F src/whereInt.h cbe4aa57326998d89e7698ca65bb7c28541d483c +F src/where.c 48e3c1f0a8a7ecbaeb5a57c195254243d49430ba +F src/whereInt.h 6b5a8ac7b4adc055176c3330d755735ed674335d F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test b35b4cd69fc913f90d39a575e171e1116c3a4bb7 @@ -1258,7 +1258,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b33f1bacfdb34fe66b7b073e68bfac38498d6e88 -R 786cf9bafb843a30daaea508385a36b1 -U mistachkin -Z cf0d8cd171ac487c0fd87c289759c254 +P 59e3e9e764440b7feaafadff74f422535d21bca2 +R 9f6038338a4c8e424f8c4ba92f9afc16 +T *branch * index-is-operator +T *sym-index-is-operator * +T -sym-trunk * +U drh +Z a0eadd388567e992c46f2fabbded464e diff --git a/manifest.uuid b/manifest.uuid index af09740391..877d59c28e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -59e3e9e764440b7feaafadff74f422535d21bca2 \ No newline at end of file +6f7f1673d00d216a5aa456acb44793a14f3b3d91 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 85eb00b46b..6bbfaca879 100644 --- a/src/where.c +++ b/src/where.c @@ -363,7 +363,7 @@ static int allowedOp(int op){ assert( TK_LT>TK_EQ && TK_LTTK_EQ && TK_LE=TK_EQ && op<=TK_GE) || op==TK_ISNULL; + return op==TK_IN || (op>=TK_EQ && op<=TK_GE) || op==TK_ISNULL || op==TK_IS; } /* @@ -416,6 +416,8 @@ static u16 operatorMask(int op){ c = WO_IN; }else if( op==TK_ISNULL ){ c = WO_ISNULL; + }else if( op==TK_IS ){ + c = WO_EQ; }else{ assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff ); c = (u16)(WO_EQ<<(op-TK_EQ)); @@ -427,6 +429,7 @@ static u16 operatorMask(int op){ assert( op!=TK_LE || c==WO_LE ); assert( op!=TK_GT || c==WO_GT ); assert( op!=TK_GE || c==WO_GE ); + assert( op!=TK_IS || c==WO_EQ ); return c; } @@ -1254,6 +1257,7 @@ static void exprAnalyze( pTerm->u.leftColumn = pLeft->iColumn; pTerm->eOperator = operatorMask(op) & opMask; } + if( op==TK_IS ) pTerm->wtFlags |= TERM_NULLOK; if( pRight && pRight->op==TK_COLUMN ){ WhereTerm *pNew; Expr *pDup; @@ -1278,6 +1282,7 @@ static void exprAnalyze( pTerm->eOperator |= WO_EQUIV; eExtraOp = WO_EQUIV; } + if( op==TK_IS ) pNew->wtFlags |= TERM_NULLOK; }else{ pDup = pExpr; pNew = pTerm; @@ -1468,10 +1473,8 @@ static void exprAnalyze( ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a ** virtual term of that form. ** - ** Note that the virtual term must be tagged with TERM_VNULL. This - ** TERM_VNULL tag will suppress the not-null check at the beginning - ** of the loop. Without the TERM_VNULL flag, the not-null check at - ** the start of the loop will prevent any results from being returned. + ** Note that the virtual term must be tagged with both TERM_VNULL + ** and TERM_NULLOK. */ if( pExpr->op==TK_NOTNULL && pExpr->pLeft->op==TK_COLUMN @@ -1488,7 +1491,7 @@ static void exprAnalyze( sqlite3PExpr(pParse, TK_NULL, 0, 0, 0), 0); idxNew = whereClauseInsert(pWC, pNewExpr, - TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL); + TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL|TERM_NULLOK); if( idxNew ){ pNewTerm = &pWC->a[idxNew]; pNewTerm->prereqRight = 0; @@ -2792,7 +2795,7 @@ static int codeEqualityTerm( int iReg; /* Register holding results */ assert( iTarget>0 ); - if( pX->op==TK_EQ ){ + if( pX->op==TK_EQ || pX->op==TK_IS ){ iReg = sqlite3ExprCodeTarget(pParse, pX->pRight, iTarget); }else if( pX->op==TK_ISNULL ){ iReg = iTarget; @@ -2977,7 +2980,9 @@ static int codeAllEqualityTerms( testcase( pTerm->eOperator & WO_IN ); if( (pTerm->eOperator & (WO_ISNULL|WO_IN))==0 ){ Expr *pRight = pTerm->pExpr->pRight; - if( sqlite3ExprCanBeNull(pRight) ){ + if( (pTerm->wtFlags & TERM_NULLOK)==0 + && sqlite3ExprCanBeNull(pRight) + ){ sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk); VdbeCoverage(v); } @@ -3626,7 +3631,7 @@ static Bitmask codeOneLoopStart( Expr *pRight = pRangeStart->pExpr->pRight; sqlite3ExprCode(pParse, pRight, regBase+nEq); whereLikeOptimizationStringFixup(v, pLevel, pRangeStart); - if( (pRangeStart->wtFlags & TERM_VNULL)==0 + if( (pRangeStart->wtFlags & TERM_NULLOK)==0 && sqlite3ExprCanBeNull(pRight) ){ sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt); @@ -3672,7 +3677,7 @@ static Bitmask codeOneLoopStart( sqlite3ExprCacheRemove(pParse, regBase+nEq, 1); sqlite3ExprCode(pParse, pRight, regBase+nEq); whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd); - if( (pRangeEnd->wtFlags & TERM_VNULL)==0 + if( (pRangeEnd->wtFlags & TERM_NULLOK)==0 && sqlite3ExprCanBeNull(pRight) ){ sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt); @@ -4158,9 +4163,10 @@ static void whereTermPrint(WhereTerm *pTerm, int iTerm){ if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V'; if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E'; if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L'; - sqlite3DebugPrintf("TERM-%-3d %p %s cursor=%-3d prob=%-3d op=0x%03x\n", - iTerm, pTerm, zType, pTerm->leftCursor, pTerm->truthProb, - pTerm->eOperator); + sqlite3DebugPrintf( + "TERM-%-3d %p %s cursor=%-3d prob=%-3d op=0x%03x wtFlags=0x%04x\n", + iTerm, pTerm, zType, pTerm->leftCursor, pTerm->truthProb, + pTerm->eOperator, pTerm->wtFlags); sqlite3TreeViewExpr(0, pTerm->pExpr, 0); } } diff --git a/src/whereInt.h b/src/whereInt.h index 04cc2029d8..915d7b8d68 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -280,6 +280,7 @@ struct WhereTerm { #define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */ #define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */ #define TERM_LIKE 0x400 /* The original LIKE operator */ +#define TERM_NULLOK 0x800 /* Comparison operators against NULL work */ /* ** An instance of the WhereScan object is used as an iterator for locating From e0cc3c296caa6a62967b50238f3563215727d11c Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 May 2015 17:54:08 +0000 Subject: [PATCH 28/33] Add testcase() macros and comments and a few test-cases. FossilOrigin-Name: 24263d08b11c88416d270013bdaf5ff45125cb4d --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/where.c | 15 ++++++++++++--- test/where.test | 30 ++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index ec12a04f7c..4413996a08 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C An\searly\sattempt\sto\sget\sindexes\sto\swork\swith\sthe\sIS\soperator.\s\sThis\scode\npasses\stests,\sbut\smuch\smore\stesting\sis\sneeded\sto\sverify\sthat\sit\sworks\son\nall\scorner\scases. -D 2015-05-13T15:24:07.257 +C Add\stestcase()\smacros\sand\scomments\sand\sa\sfew\stest-cases. +D 2015-05-13T17:54:08.892 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -307,7 +307,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c ce2cb2d06faab54d1bce3e739bec79e063dd9113 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c 48e3c1f0a8a7ecbaeb5a57c195254243d49430ba +F src/where.c 98964edb2a27d6f87976b85a8b00862558a277b2 F src/whereInt.h 6b5a8ac7b4adc055176c3330d755735ed674335d F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1165,7 +1165,7 @@ F test/walro.test 34422d1d95aaff0388f0791ec20edb34e2a3ed57 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417 F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e -F test/where.test 28b64e93428961b07b0d486778d63fd672948f6b +F test/where.test 1ff3d9f8da0a6c0dc5ccfd38d9225b2cdb5b6afb F test/where2.test 23fdb5d8e756554aad4ca7ae03de9dd8367a2c6e F test/where3.test 1ad55ba900bd7747f98b6082e65bd3e442c5004e F test/where4.test d8420ceeb8323a41ceff1f1841fc528e824e1ecf @@ -1258,10 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 59e3e9e764440b7feaafadff74f422535d21bca2 -R 9f6038338a4c8e424f8c4ba92f9afc16 -T *branch * index-is-operator -T *sym-index-is-operator * -T -sym-trunk * +P 6f7f1673d00d216a5aa456acb44793a14f3b3d91 +R 3ff0212a0c4cf6ad597a241e62c5ab7c U drh -Z a0eadd388567e992c46f2fabbded464e +Z fddf4aa627339444877435638e7a9621 diff --git a/manifest.uuid b/manifest.uuid index 877d59c28e..d093009b2a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6f7f1673d00d216a5aa456acb44793a14f3b3d91 \ No newline at end of file +24263d08b11c88416d270013bdaf5ff45125cb4d \ No newline at end of file diff --git a/src/where.c b/src/where.c index 6bbfaca879..1c2c0931be 100644 --- a/src/where.c +++ b/src/where.c @@ -417,7 +417,7 @@ static u16 operatorMask(int op){ }else if( op==TK_ISNULL ){ c = WO_ISNULL; }else if( op==TK_IS ){ - c = WO_EQ; + c = WO_EQ; /* IS works like ==, just without the IsNull tests */ }else{ assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff ); c = (u16)(WO_EQ<<(op-TK_EQ)); @@ -1117,6 +1117,7 @@ static void exprAnalyzeOrTerm( okToChngToIN = 1; for(; i>=0 && okToChngToIN; i--, pOrTerm++){ assert( pOrTerm->eOperator & WO_EQ ); + testcase( pOrTerm->pExpr->op==TK_IS ); if( pOrTerm->leftCursor!=iCursor ){ pOrTerm->wtFlags &= ~TERM_OR_OK; }else if( pOrTerm->u.leftColumn!=iColumn ){ @@ -1153,6 +1154,7 @@ static void exprAnalyzeOrTerm( assert( pOrTerm->eOperator & WO_EQ ); assert( pOrTerm->leftCursor==iCursor ); assert( pOrTerm->u.leftColumn==iColumn ); + testcase( pOrTerm->pExpr->op==TK_IS ); pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0); pList = sqlite3ExprListAppend(pWInfo->pParse, pList, pDup); pLeft = pOrTerm->pExpr->pLeft; @@ -1683,6 +1685,7 @@ static int termCanDriveIndex( if( pTerm->u.leftColumn<0 ) return 0; aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity; if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0; + testcase( pTerm->pExpr->op==TK_IS ); return 1; } #endif @@ -2980,6 +2983,7 @@ static int codeAllEqualityTerms( testcase( pTerm->eOperator & WO_IN ); if( (pTerm->eOperator & (WO_ISNULL|WO_IN))==0 ){ Expr *pRight = pTerm->pExpr->pRight; + testcase( pTerm->pExpr->op==TK_IS ); if( (pTerm->wtFlags & TERM_NULLOK)==0 && sqlite3ExprCanBeNull(pRight) ){ @@ -3631,6 +3635,7 @@ static Bitmask codeOneLoopStart( Expr *pRight = pRangeStart->pExpr->pRight; sqlite3ExprCode(pParse, pRight, regBase+nEq); whereLikeOptimizationStringFixup(v, pLevel, pRangeStart); + testcase( pRangeStart->pExpr->op==TK_IS ); if( (pRangeStart->wtFlags & TERM_NULLOK)==0 && sqlite3ExprCanBeNull(pRight) ){ @@ -3677,6 +3682,7 @@ static Bitmask codeOneLoopStart( sqlite3ExprCacheRemove(pParse, regBase+nEq, 1); sqlite3ExprCode(pParse, pRight, regBase+nEq); whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd); + testcase( pRangeEnd->pExpr->op==TK_IS ); if( (pRangeEnd->wtFlags & TERM_NULLOK)==0 && sqlite3ExprCanBeNull(pRight) ){ @@ -4113,7 +4119,7 @@ static Bitmask codeOneLoopStart( pAlt = findTerm(pWC, iCur, pTerm->u.leftColumn, notReady, WO_EQ|WO_IN, 0); if( pAlt==0 ) continue; if( pAlt->wtFlags & (TERM_CODED) ) continue; - testcase( pAlt->eOperator & WO_EQ ); + testcase( (pAlt->eOperator & WO_EQ)!=0 && pAlt->pExpr->op==TK_IS ); testcase( pAlt->eOperator & WO_IN ); VdbeModuleComment((v, "begin transitive constraint")); pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt)); @@ -4658,6 +4664,7 @@ static void whereLoopOutputAdjust( pLoop->nOut--; if( pTerm->eOperator&WO_EQ ){ Expr *pRight = pTerm->pExpr->pRight; + testcase( pTerm->pExpr->op==TK_IS ); if( sqlite3ExprIsInteger(pRight, &k) && k>=(-1) && k<=1 ){ k = 10; }else{ @@ -4859,7 +4866,7 @@ static int whereLoopAddBtreeIndex( ){ Expr *pExpr = pTerm->pExpr; if( (eOp & (WO_EQ|WO_ISNULL))!=0 ){ - testcase( eOp & WO_EQ ); + testcase( (eOp & WO_EQ)!=0 && pExpr->op==TK_IS ); testcase( eOp & WO_ISNULL ); rc = whereEqualScanEst(pParse, pBuilder, pExpr->pRight, &nOut); }else{ @@ -5707,6 +5714,7 @@ static i8 wherePathSatisfiesOrderBy( if( !pColl ) pColl = db->pDfltColl; z2 = pColl->zName; if( sqlite3StrICmp(z1, z2)!=0 ) continue; + testcase( pTerm->pExpr->op==TK_IS ); } obSat |= MASKBIT(i); } @@ -6329,6 +6337,7 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx); if( pTerm==0 ) break; pLoop->aLTerm[j] = pTerm; + testcase( pTerm->pExpr->op==TK_IS ); } if( j!=pIdx->nKeyCol ) continue; pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED; diff --git a/test/where.test b/test/where.test index f560708cca..72fd696306 100644 --- a/test/where.test +++ b/test/where.test @@ -65,9 +65,15 @@ proc count sql { do_test where-1.1.1 { count {SELECT x, y, w FROM t1 WHERE w=10} } {3 121 10 3} +do_test where-1.1.1b { + count {SELECT x, y, w FROM t1 WHERE w IS 10} +} {3 121 10 3} do_eqp_test where-1.1.2 { SELECT x, y, w FROM t1 WHERE w=10 } {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} +do_eqp_test where-1.1.2b { + SELECT x, y, w FROM t1 WHERE w IS 10 +} {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} do_test where-1.1.3 { db status step } {0} @@ -101,12 +107,21 @@ do_test where-1.3.1 { do_test where-1.3.2 { count {SELECT x, y, w AS abc FROM t1 WHERE 11=abc} } {3 144 11 3} +do_test where-1.3.3 { + count {SELECT x, y, w AS abc FROM t1 WHERE 11 IS abc} +} {3 144 11 3} do_test where-1.4.1 { count {SELECT w, x, y FROM t1 WHERE 11=w AND x>2} } {11 3 144 3} +do_test where-1.4.1b { + count {SELECT w, x, y FROM t1 WHERE 11 IS w AND x>2} +} {11 3 144 3} do_eqp_test where-1.4.2 { SELECT w, x, y FROM t1 WHERE 11=w AND x>2 } {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} +do_eqp_test where-1.4.2b { + SELECT w, x, y FROM t1 WHERE 11 IS w AND x>2 +} {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} do_test where-1.4.3 { count {SELECT w AS a, x AS b, y FROM t1 WHERE 11=a AND b>2} } {11 3 144 3} @@ -143,6 +158,9 @@ do_test where-1.10 { do_test where-1.11 { count {SELECT x, y FROM t1 WHERE x=3 AND y=100 AND w<10} } {3 100 3} +do_test where-1.11b { + count {SELECT x, y FROM t1 WHERE x IS 3 AND y IS 100 AND w<10} +} {3 100 3} # New for SQLite version 2.1: Verify that that inequality constraints # are used correctly. @@ -150,12 +168,18 @@ do_test where-1.11 { do_test where-1.12 { count {SELECT w FROM t1 WHERE x=3 AND y<100} } {8 3} +do_test where-1.12b { + count {SELECT w FROM t1 WHERE x IS 3 AND y<100} +} {8 3} do_test where-1.13 { count {SELECT w FROM t1 WHERE x=3 AND 100>y} } {8 3} do_test where-1.14 { count {SELECT w FROM t1 WHERE 3=x AND y<100} } {8 3} +do_test where-1.14b { + count {SELECT w FROM t1 WHERE 3 IS x AND y<100} +} {8 3} do_test where-1.15 { count {SELECT w FROM t1 WHERE 3=x AND 100>y} } {8 3} @@ -168,6 +192,9 @@ do_test where-1.17 { do_test where-1.18 { count {SELECT w FROM t1 WHERE x=3 AND y>225} } {15 3} +do_test where-1.18b { + count {SELECT w FROM t1 WHERE x IS 3 AND y>225} +} {15 3} do_test where-1.19 { count {SELECT w FROM t1 WHERE x=3 AND 225121 AND y<196} } {11 12 5} +do_test where-1.22b { + count {SELECT w FROM t1 WHERE x IS 3 AND y>121 AND y<196} +} {11 12 5} do_test where-1.23 { count {SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<=196} } {10 11 12 13 9} From 9be18709947d14443a4769c01e9be0050d247df2 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 May 2015 19:33:41 +0000 Subject: [PATCH 29/33] Simplified implementation of indexing with the IS operator. FossilOrigin-Name: 95b1f9bf14e490c6c6bba9ea78aeab712a44aab5 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/where.c | 20 +++++++------------- src/whereInt.h | 4 ++-- test/whereC.test | 1 + 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index 4413996a08..88aafccee7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stestcase()\smacros\sand\scomments\sand\sa\sfew\stest-cases. -D 2015-05-13T17:54:08.892 +C Simplified\simplementation\sof\sindexing\swith\sthe\sIS\soperator. +D 2015-05-13T19:33:41.990 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -307,8 +307,8 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c ce2cb2d06faab54d1bce3e739bec79e063dd9113 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c 98964edb2a27d6f87976b85a8b00862558a277b2 -F src/whereInt.h 6b5a8ac7b4adc055176c3330d755735ed674335d +F src/where.c fa61aca146422a2a056aeb0381a6bb1c37d46c07 +F src/whereInt.h 31d30e83621c21358d031510d5c6a3e474cd8bb7 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test b35b4cd69fc913f90d39a575e171e1116c3a4bb7 @@ -1177,7 +1177,7 @@ F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739 F test/where9.test 729c3ba9b47e8f9f1aab96bae7dad2a524f1d1a2 F test/whereA.test 4d253178d135ec46d1671e440cd8f2b916aa6e6b F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5 -F test/whereC.test d6f4ecd4fa2d9429681a5b22a25d2bda8e86ab8a +F test/whereC.test cae295158703cb3fc23bf1a108a9ab730efff0f6 F test/whereD.test 9eba1f9b18e5b19a0b0bcaae5e8c037260195f2b F test/whereE.test b3a055eef928c992b0a33198a7b8dc10eea5ad2f F test/whereF.test 5b2ba0dbe8074aa13e416b37c753991f0a2492d7 @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6f7f1673d00d216a5aa456acb44793a14f3b3d91 -R 3ff0212a0c4cf6ad597a241e62c5ab7c +P 24263d08b11c88416d270013bdaf5ff45125cb4d +R 16be24e7bac77474bad7ab9d3d121f18 U drh -Z fddf4aa627339444877435638e7a9621 +Z 3bc6b705447a86373e017a72613abb32 diff --git a/manifest.uuid b/manifest.uuid index d093009b2a..660fdcd247 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -24263d08b11c88416d270013bdaf5ff45125cb4d \ No newline at end of file +95b1f9bf14e490c6c6bba9ea78aeab712a44aab5 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 1c2c0931be..aad9799211 100644 --- a/src/where.c +++ b/src/where.c @@ -1259,7 +1259,7 @@ static void exprAnalyze( pTerm->u.leftColumn = pLeft->iColumn; pTerm->eOperator = operatorMask(op) & opMask; } - if( op==TK_IS ) pTerm->wtFlags |= TERM_NULLOK; + if( op==TK_IS ) pTerm->wtFlags |= TERM_IS; if( pRight && pRight->op==TK_COLUMN ){ WhereTerm *pNew; Expr *pDup; @@ -1284,7 +1284,7 @@ static void exprAnalyze( pTerm->eOperator |= WO_EQUIV; eExtraOp = WO_EQUIV; } - if( op==TK_IS ) pNew->wtFlags |= TERM_NULLOK; + if( op==TK_IS ) pNew->wtFlags |= TERM_IS; }else{ pDup = pExpr; pNew = pTerm; @@ -1475,8 +1475,7 @@ static void exprAnalyze( ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a ** virtual term of that form. ** - ** Note that the virtual term must be tagged with both TERM_VNULL - ** and TERM_NULLOK. + ** Note that the virtual term must be tagged with TERM_VNULL. */ if( pExpr->op==TK_NOTNULL && pExpr->pLeft->op==TK_COLUMN @@ -1493,7 +1492,7 @@ static void exprAnalyze( sqlite3PExpr(pParse, TK_NULL, 0, 0, 0), 0); idxNew = whereClauseInsert(pWC, pNewExpr, - TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL|TERM_NULLOK); + TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL); if( idxNew ){ pNewTerm = &pWC->a[idxNew]; pNewTerm->prereqRight = 0; @@ -2983,10 +2982,7 @@ static int codeAllEqualityTerms( testcase( pTerm->eOperator & WO_IN ); if( (pTerm->eOperator & (WO_ISNULL|WO_IN))==0 ){ Expr *pRight = pTerm->pExpr->pRight; - testcase( pTerm->pExpr->op==TK_IS ); - if( (pTerm->wtFlags & TERM_NULLOK)==0 - && sqlite3ExprCanBeNull(pRight) - ){ + if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){ sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk); VdbeCoverage(v); } @@ -3635,8 +3631,7 @@ static Bitmask codeOneLoopStart( Expr *pRight = pRangeStart->pExpr->pRight; sqlite3ExprCode(pParse, pRight, regBase+nEq); whereLikeOptimizationStringFixup(v, pLevel, pRangeStart); - testcase( pRangeStart->pExpr->op==TK_IS ); - if( (pRangeStart->wtFlags & TERM_NULLOK)==0 + if( (pRangeStart->wtFlags & TERM_VNULL)==0 && sqlite3ExprCanBeNull(pRight) ){ sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt); @@ -3682,8 +3677,7 @@ static Bitmask codeOneLoopStart( sqlite3ExprCacheRemove(pParse, regBase+nEq, 1); sqlite3ExprCode(pParse, pRight, regBase+nEq); whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd); - testcase( pRangeEnd->pExpr->op==TK_IS ); - if( (pRangeEnd->wtFlags & TERM_NULLOK)==0 + if( (pRangeEnd->wtFlags & TERM_VNULL)==0 && sqlite3ExprCanBeNull(pRight) ){ sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt); diff --git a/src/whereInt.h b/src/whereInt.h index 915d7b8d68..e7730d71ed 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -280,7 +280,7 @@ struct WhereTerm { #define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */ #define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */ #define TERM_LIKE 0x400 /* The original LIKE operator */ -#define TERM_NULLOK 0x800 /* Comparison operators against NULL work */ +#define TERM_IS 0x800 /* Term.pExpr is an IS operator */ /* ** An instance of the WhereScan object is used as an iterator for locating @@ -430,7 +430,7 @@ struct WhereInfo { ** particular WhereTerms within a WhereClause. */ #define WO_IN 0x001 -#define WO_EQ 0x002 +#define WO_EQ 0x002 /* Used for both == and IS */ #define WO_LT (WO_EQ<<(TK_LT-TK_EQ)) #define WO_LE (WO_EQ<<(TK_LE-TK_EQ)) #define WO_GT (WO_EQ<<(TK_GT-TK_EQ)) diff --git a/test/whereC.test b/test/whereC.test index bd7fe9ad82..f172069675 100644 --- a/test/whereC.test +++ b/test/whereC.test @@ -59,6 +59,7 @@ foreach {tn sql res} { 12 "SELECT i FROM t1 WHERE a=2 AND b=2 AND i=NULL" {} 14 "SELECT i FROM t1 WHERE a=1 AND b='2' AND i<4.5" {3 4} + 15 "SELECT i FROM t1 WHERE rowid IS '12'" {12} } { do_execsql_test 1.$tn.1 $sql $res do_execsql_test 1.$tn.2 "$sql ORDER BY i ASC" [lsort -integer -inc $res] From e8d0c61f0aa723d698d36be3bcb13c4d3feb746d Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 May 2015 01:05:25 +0000 Subject: [PATCH 30/33] A new implementation of indexing with the IS operator that works correctly when the IS operator is in the WHERE clause and the operands are from opposite sides of a LEFT JOIN. FossilOrigin-Name: 4541688b3f56f5cd3d5b299594b58c577ad633bb --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/where.c | 49 +++++++++++++++++++++++++++--------------------- src/whereInt.h | 21 +++++++++++---------- test/where4.test | 15 +++++++++++++++ 5 files changed, 63 insertions(+), 40 deletions(-) diff --git a/manifest b/manifest index 88aafccee7..438ec23110 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplified\simplementation\sof\sindexing\swith\sthe\sIS\soperator. -D 2015-05-13T19:33:41.990 +C A\snew\simplementation\sof\sindexing\swith\sthe\sIS\soperator\sthat\sworks\scorrectly\nwhen\sthe\sIS\soperator\sis\sin\sthe\sWHERE\sclause\sand\sthe\soperands\sare\sfrom\s\nopposite\ssides\sof\sa\sLEFT\sJOIN. +D 2015-05-14T01:05:25.274 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -307,8 +307,8 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c ce2cb2d06faab54d1bce3e739bec79e063dd9113 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c fa61aca146422a2a056aeb0381a6bb1c37d46c07 -F src/whereInt.h 31d30e83621c21358d031510d5c6a3e474cd8bb7 +F src/where.c 64afb483fe8bede1e31e6c66bc532530a4600543 +F src/whereInt.h a6f5a762bc1b4b1c76e1cea79976b437ac35a435 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test b35b4cd69fc913f90d39a575e171e1116c3a4bb7 @@ -1168,7 +1168,7 @@ F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e F test/where.test 1ff3d9f8da0a6c0dc5ccfd38d9225b2cdb5b6afb F test/where2.test 23fdb5d8e756554aad4ca7ae03de9dd8367a2c6e F test/where3.test 1ad55ba900bd7747f98b6082e65bd3e442c5004e -F test/where4.test d8420ceeb8323a41ceff1f1841fc528e824e1ecf +F test/where4.test a4603fa0d018bd4b9430dac840c9c522af421dd5 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b F test/where7.test 5a4b0abc207d71da4deecd734ad8579e8dd40aa8 @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 24263d08b11c88416d270013bdaf5ff45125cb4d -R 16be24e7bac77474bad7ab9d3d121f18 +P 95b1f9bf14e490c6c6bba9ea78aeab712a44aab5 +R 6e0cd1da1bcd5d739d5d402ab5201f6c U drh -Z 3bc6b705447a86373e017a72613abb32 +Z 3608a708c2f560b3e002545b6da23dda diff --git a/manifest.uuid b/manifest.uuid index 660fdcd247..2dcd8f7064 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -95b1f9bf14e490c6c6bba9ea78aeab712a44aab5 \ No newline at end of file +4541688b3f56f5cd3d5b299594b58c577ad633bb \ No newline at end of file diff --git a/src/where.c b/src/where.c index aad9799211..3c96f93a7e 100644 --- a/src/where.c +++ b/src/where.c @@ -417,7 +417,7 @@ static u16 operatorMask(int op){ }else if( op==TK_ISNULL ){ c = WO_ISNULL; }else if( op==TK_IS ){ - c = WO_EQ; /* IS works like ==, just without the IsNull tests */ + c = WO_IS; }else{ assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff ); c = (u16)(WO_EQ<<(op-TK_EQ)); @@ -429,7 +429,7 @@ static u16 operatorMask(int op){ assert( op!=TK_LE || c==WO_LE ); assert( op!=TK_GT || c==WO_GT ); assert( op!=TK_GE || c==WO_GE ); - assert( op!=TK_IS || c==WO_EQ ); + assert( op!=TK_IS || c==WO_IS ); return c; } @@ -490,11 +490,12 @@ static WhereTerm *whereScanNext(WhereScan *pScan){ continue; } } - if( (pTerm->eOperator & WO_EQ)!=0 + if( (pTerm->eOperator & (WO_EQ|WO_IS))!=0 && (pX = pTerm->pExpr->pRight)->op==TK_COLUMN && pX->iTable==pScan->aEquiv[0] && pX->iColumn==pScan->aEquiv[1] ){ + testcase( pTerm->eOperator & WO_IS ); continue; } pScan->k = k+1; @@ -596,9 +597,11 @@ static WhereTerm *findTerm( WhereScan scan; p = whereScanInit(&scan, pWC, iCur, iColumn, op, pIdx); + op &= WO_EQ|WO_IS; while( p ){ if( (p->prereqRight & notReady)==0 ){ - if( p->prereqRight==0 && (p->eOperator&WO_EQ)!=0 ){ + if( p->prereqRight==0 && (p->eOperator&op)!=0 ){ + testcase( p->eOperator & WO_IS ); return p; } if( pResult==0 ) pResult = p; @@ -1679,7 +1682,7 @@ static int termCanDriveIndex( ){ char aff; if( pTerm->leftCursor!=pSrc->iCursor ) return 0; - if( (pTerm->eOperator & WO_EQ)==0 ) return 0; + if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0; if( (pTerm->prereqRight & notReady)!=0 ) return 0; if( pTerm->u.leftColumn<0 ) return 0; aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity; @@ -1955,7 +1958,7 @@ static sqlite3_index_info *allocateIndexInfo( testcase( pTerm->eOperator & WO_IN ); testcase( pTerm->eOperator & WO_ISNULL ); testcase( pTerm->eOperator & WO_ALL ); - if( (pTerm->eOperator & ~(WO_ISNULL|WO_EQUIV))==0 ) continue; + if( (pTerm->eOperator & ~(WO_ISNULL|WO_EQUIV|WO_IS))==0 ) continue; if( pTerm->wtFlags & TERM_VNULL ) continue; pIdxCons[j].iColumn = pTerm->u.leftColumn; pIdxCons[j].iTermOffset = i; @@ -4104,16 +4107,18 @@ static Bitmask codeOneLoopStart( Expr *pE, *pEAlt; WhereTerm *pAlt; if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; - if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue; + if( (pTerm->eOperator&(WO_EQUIV|WO_EQ|WO_IS))<=WO_EQUIV ) continue; if( pTerm->leftCursor!=iCur ) continue; if( pLevel->iLeftJoin ) continue; pE = pTerm->pExpr; assert( !ExprHasProperty(pE, EP_FromJoin) ); assert( (pTerm->prereqRight & pLevel->notReady)!=0 ); - pAlt = findTerm(pWC, iCur, pTerm->u.leftColumn, notReady, WO_EQ|WO_IN, 0); + pAlt = findTerm(pWC, iCur, pTerm->u.leftColumn, notReady, + WO_EQ|WO_IN|WO_IS, 0); if( pAlt==0 ) continue; if( pAlt->wtFlags & (TERM_CODED) ) continue; - testcase( (pAlt->eOperator & WO_EQ)!=0 && pAlt->pExpr->op==TK_IS ); + testcase( pAlt->eOperator & WO_EQ ); + testcase( pAlt->eOperator & WO_IS ); testcase( pAlt->eOperator & WO_IN ); VdbeModuleComment((v, "begin transitive constraint")); pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt)); @@ -4656,7 +4661,7 @@ static void whereLoopOutputAdjust( /* In the absence of explicit truth probabilities, use heuristics to ** guess a reasonable truth probability. */ pLoop->nOut--; - if( pTerm->eOperator&WO_EQ ){ + if( pTerm->eOperator&(WO_EQ|WO_IS) ){ Expr *pRight = pTerm->pExpr->pRight; testcase( pTerm->pExpr->op==TK_IS ); if( sqlite3ExprIsInteger(pRight, &k) && k>=(-1) && k<=1 ){ @@ -4729,7 +4734,7 @@ static int whereLoopAddBtreeIndex( }else if( pProbe->tnum<=0 || (pSrc->jointype & JT_LEFT)!=0 ){ opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE; }else{ - opMask = WO_EQ|WO_IN|WO_ISNULL|WO_GT|WO_GE|WO_LT|WO_LE; + opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS; } if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE); @@ -4792,7 +4797,7 @@ static int whereLoopAddBtreeIndex( assert( nIn>0 ); /* RHS always has 2 or more terms... The parser ** changes "x IN (?)" into "x=?". */ - }else if( eOp & (WO_EQ) ){ + }else if( eOp & (WO_EQ|WO_IS) ){ pNew->wsFlags |= WHERE_COLUMN_EQ; if( iCol<0 || (nInMul==0 && pNew->u.btree.nEq==pProbe->nKeyCol-1) ){ if( iCol>=0 && pProbe->uniqNotNull==0 ){ @@ -4842,7 +4847,7 @@ static int whereLoopAddBtreeIndex( whereRangeScanEst(pParse, pBuilder, pBtm, pTop, pNew); }else{ int nEq = ++pNew->u.btree.nEq; - assert( eOp & (WO_ISNULL|WO_EQ|WO_IN) ); + assert( eOp & (WO_ISNULL|WO_EQ|WO_IN|WO_IS) ); assert( pNew->nOut==saved_nOut ); if( pTerm->truthProb<=0 && iCol>=0 ){ @@ -4859,8 +4864,9 @@ static int whereLoopAddBtreeIndex( && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect)) ){ Expr *pExpr = pTerm->pExpr; - if( (eOp & (WO_EQ|WO_ISNULL))!=0 ){ - testcase( (eOp & WO_EQ)!=0 && pExpr->op==TK_IS ); + if( (eOp & (WO_EQ|WO_ISNULL|WO_IS))!=0 ){ + testcase( eOp & WO_EQ ); + testcase( eOp & WO_IS ); testcase( eOp & WO_ISNULL ); rc = whereEqualScanEst(pParse, pBuilder, pExpr->pRight, &nOut); }else{ @@ -5697,9 +5703,9 @@ static i8 wherePathSatisfiesOrderBy( if( pOBExpr->op!=TK_COLUMN ) continue; if( pOBExpr->iTable!=iCur ) continue; pTerm = findTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn, - ~ready, WO_EQ|WO_ISNULL, 0); + ~ready, WO_EQ|WO_ISNULL|WO_IS, 0); if( pTerm==0 ) continue; - if( (pTerm->eOperator&WO_EQ)!=0 && pOBExpr->iColumn>=0 ){ + if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){ const char *z1, *z2; pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr); if( !pColl ) pColl = db->pDfltColl; @@ -5739,7 +5745,7 @@ static i8 wherePathSatisfiesOrderBy( /* Skip over == and IS NULL terms */ if( ju.btree.nEq && pLoop->nSkip==0 - && ((i = pLoop->aLTerm[j]->eOperator) & (WO_EQ|WO_ISNULL))!=0 + && ((i = pLoop->aLTerm[j]->eOperator) & (WO_EQ|WO_ISNULL|WO_IS))!=0 ){ if( i & WO_ISNULL ){ testcase( isOrderDistinct ); @@ -6312,8 +6318,9 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ pLoop = pBuilder->pNew; pLoop->wsFlags = 0; pLoop->nSkip = 0; - pTerm = findTerm(pWC, iCur, -1, 0, WO_EQ, 0); + pTerm = findTerm(pWC, iCur, -1, 0, WO_EQ|WO_IS, 0); if( pTerm ){ + testcase( pTerm->eOperator & WO_IS ); pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW; pLoop->aLTerm[0] = pTerm; pLoop->nLTerm = 1; @@ -6328,10 +6335,10 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ || pIdx->nKeyCol>ArraySize(pLoop->aLTermSpace) ) continue; for(j=0; jnKeyCol; j++){ - pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx); + pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ|WO_IS, pIdx); if( pTerm==0 ) break; + testcase( pTerm->eOperator & WO_IS ); pLoop->aLTerm[j] = pTerm; - testcase( pTerm->pExpr->op==TK_IS ); } if( j!=pIdx->nKeyCol ) continue; pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED; diff --git a/src/whereInt.h b/src/whereInt.h index e7730d71ed..3a5a48e840 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -429,21 +429,22 @@ struct WhereInfo { ** OR-ed combination of these values can be used when searching for ** particular WhereTerms within a WhereClause. */ -#define WO_IN 0x001 -#define WO_EQ 0x002 /* Used for both == and IS */ +#define WO_IN 0x0001 +#define WO_EQ 0x0002 #define WO_LT (WO_EQ<<(TK_LT-TK_EQ)) #define WO_LE (WO_EQ<<(TK_LE-TK_EQ)) #define WO_GT (WO_EQ<<(TK_GT-TK_EQ)) #define WO_GE (WO_EQ<<(TK_GE-TK_EQ)) -#define WO_MATCH 0x040 -#define WO_ISNULL 0x080 -#define WO_OR 0x100 /* Two or more OR-connected terms */ -#define WO_AND 0x200 /* Two or more AND-connected terms */ -#define WO_EQUIV 0x400 /* Of the form A==B, both columns */ -#define WO_NOOP 0x800 /* This term does not restrict search space */ +#define WO_MATCH 0x0040 +#define WO_IS 0x0080 +#define WO_ISNULL 0x0100 +#define WO_OR 0x0200 /* Two or more OR-connected terms */ +#define WO_AND 0x0400 /* Two or more AND-connected terms */ +#define WO_EQUIV 0x0800 /* Of the form A==B, both columns */ +#define WO_NOOP 0x1000 /* This term does not restrict search space */ -#define WO_ALL 0xfff /* Mask of all possible WO_* values */ -#define WO_SINGLE 0x0ff /* Mask of all non-compound WO_* values */ +#define WO_ALL 0x1fff /* Mask of all possible WO_* values */ +#define WO_SINGLE 0x01ff /* Mask of all non-compound WO_* values */ /* ** These are definitions of bits in the WhereLoop.wsFlags field. diff --git a/test/where4.test b/test/where4.test index a26e9ad355..6bceb9174b 100644 --- a/test/where4.test +++ b/test/where4.test @@ -57,6 +57,10 @@ proc count sql { do_test where4-1.1 { count {SELECT rowid FROM t1 WHERE w IS NULL} } {7 2} +do_test where4-1.1b { + unset -nocomplain null + count {SELECT rowid FROM t1 WHERE w IS $null} +} {7 2} do_test where4-1.2 { count {SELECT rowid FROM t1 WHERE +w IS NULL} } {7 6} @@ -143,6 +147,17 @@ do_test where4-3.2 { SELECT * FROM t2 LEFT JOIN t3 ON a=x WHERE y IS NULL; } } {2 2 {} 3 {} {}} +do_test where4-3.3 { + execsql { + SELECT * FROM t2 LEFT JOIN t3 ON a=x WHERE NULL is y; + } +} {2 2 {} 3 {} {}} +do_test where4-3.4 { + unset -nocomplain null + execsql { + SELECT * FROM t2 LEFT JOIN t3 ON a=x WHERE y IS $null; + } +} {2 2 {} 3 {} {}} # Ticket #2189. Probably the same bug as #2177. # From ee14587c3953f85e31ff38268ac91f268792b470 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 May 2015 13:18:47 +0000 Subject: [PATCH 31/33] Add testcase() macros. Get transitive WHERE clause constraints on IS operators working again. FossilOrigin-Name: d195d4a65d7184e34a2a08c3ac3db7f6c8c1c21c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 11 +++++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 438ec23110..6fdcf36695 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C A\snew\simplementation\sof\sindexing\swith\sthe\sIS\soperator\sthat\sworks\scorrectly\nwhen\sthe\sIS\soperator\sis\sin\sthe\sWHERE\sclause\sand\sthe\soperands\sare\sfrom\s\nopposite\ssides\sof\sa\sLEFT\sJOIN. -D 2015-05-14T01:05:25.274 +C Add\stestcase()\smacros.\s\sGet\stransitive\sWHERE\sclause\sconstraints\son\sIS\soperators\nworking\sagain. +D 2015-05-14T13:18:47.128 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -307,7 +307,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c ce2cb2d06faab54d1bce3e739bec79e063dd9113 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c 64afb483fe8bede1e31e6c66bc532530a4600543 +F src/where.c cabecc4a0f647f552b7467a86ff3c2e48487399d F src/whereInt.h a6f5a762bc1b4b1c76e1cea79976b437ac35a435 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 95b1f9bf14e490c6c6bba9ea78aeab712a44aab5 -R 6e0cd1da1bcd5d739d5d402ab5201f6c +P 4541688b3f56f5cd3d5b299594b58c577ad633bb +R 201c526060c4a057a45ebf1fee55c845 U drh -Z 3608a708c2f560b3e002545b6da23dda +Z 9f199a1ff5417af5f644d4d006d00b95 diff --git a/manifest.uuid b/manifest.uuid index 2dcd8f7064..ccbe8e23d7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4541688b3f56f5cd3d5b299594b58c577ad633bb \ No newline at end of file +d195d4a65d7184e34a2a08c3ac3db7f6c8c1c21c \ No newline at end of file diff --git a/src/where.c b/src/where.c index 3c96f93a7e..4792b13e60 100644 --- a/src/where.c +++ b/src/where.c @@ -1280,7 +1280,7 @@ static void exprAnalyze( markTermAsChild(pWC, idxNew, idxTerm); pTerm = &pWC->a[idxTerm]; pTerm->wtFlags |= TERM_COPIED; - if( pExpr->op==TK_EQ + if( (op==TK_EQ || op==TK_IS) && !ExprHasProperty(pExpr, EP_FromJoin) && OptimizationEnabled(db, SQLITE_Transitive) ){ @@ -1904,8 +1904,9 @@ static sqlite3_index_info *allocateIndexInfo( assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) ); testcase( pTerm->eOperator & WO_IN ); testcase( pTerm->eOperator & WO_ISNULL ); + testcase( pTerm->eOperator & WO_IS ); testcase( pTerm->eOperator & WO_ALL ); - if( (pTerm->eOperator & ~(WO_ISNULL|WO_EQUIV))==0 ) continue; + if( (pTerm->eOperator & ~(WO_ISNULL|WO_EQUIV|WO_IS))==0 ) continue; if( pTerm->wtFlags & TERM_VNULL ) continue; nTerm++; } @@ -1956,6 +1957,7 @@ static sqlite3_index_info *allocateIndexInfo( if( pTerm->leftCursor != pSrc->iCursor ) continue; assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) ); testcase( pTerm->eOperator & WO_IN ); + testcase( pTerm->eOperator & WO_IS ); testcase( pTerm->eOperator & WO_ISNULL ); testcase( pTerm->eOperator & WO_ALL ); if( (pTerm->eOperator & ~(WO_ISNULL|WO_EQUIV|WO_IS))==0 ) continue; @@ -4107,7 +4109,8 @@ static Bitmask codeOneLoopStart( Expr *pE, *pEAlt; WhereTerm *pAlt; if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; - if( (pTerm->eOperator&(WO_EQUIV|WO_EQ|WO_IS))<=WO_EQUIV ) continue; + if( (pTerm->eOperator & WO_EQUIV)==0 ) continue; + if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) continue; if( pTerm->leftCursor!=iCur ) continue; if( pLevel->iLeftJoin ) continue; pE = pTerm->pExpr; @@ -4731,7 +4734,7 @@ static int whereLoopAddBtreeIndex( assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 ); if( pNew->wsFlags & WHERE_BTM_LIMIT ){ opMask = WO_LT|WO_LE; - }else if( pProbe->tnum<=0 || (pSrc->jointype & JT_LEFT)!=0 ){ + }else if( /*pProbe->tnum<=0 ||*/ (pSrc->jointype & JT_LEFT)!=0 ){ opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE; }else{ opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS; From 4a00b33c026622956adaa9bc13904b999de01269 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 May 2015 13:41:22 +0000 Subject: [PATCH 32/33] More test cases. Remove some invalid testcase() macros. Rearrange some code for improved testability. FossilOrigin-Name: b3676377b257bd8bb7fefe9c365d76cdc9e44856 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 4 +--- test/vtab1.test | 13 ++++++++++++- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 6fdcf36695..40483626d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stestcase()\smacros.\s\sGet\stransitive\sWHERE\sclause\sconstraints\son\sIS\soperators\nworking\sagain. -D 2015-05-14T13:18:47.128 +C More\stest\scases.\s\sRemove\ssome\sinvalid\stestcase()\smacros.\s\sRearrange\ssome\scode\nfor\simproved\stestability. +D 2015-05-14T13:41:22.643 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -307,7 +307,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c ce2cb2d06faab54d1bce3e739bec79e063dd9113 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c cabecc4a0f647f552b7467a86ff3c2e48487399d +F src/where.c 08fadd0d211699348349be5449f3a1e391adf20e F src/whereInt.h a6f5a762bc1b4b1c76e1cea79976b437ac35a435 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1120,7 +1120,7 @@ F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 F test/view.test f311691d696a5cc27e3c1b875cec1b0866b4ccd9 -F test/vtab1.test d1e5ec7a818f1d3f0402382b6a1d0c06071b770f +F test/vtab1.test dbe0e9e121102d0ba365f20d126a72676aa2343f F test/vtab2.test 3644649aa8d1daac57fd541f6a5f914cac59203e F test/vtab3.test b45f47d20f225ccc9c28dc915d92740c2dee311e F test/vtab4.test 942f8b8280b3ea8a41dae20e7822d065ca1cb275 @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4541688b3f56f5cd3d5b299594b58c577ad633bb -R 201c526060c4a057a45ebf1fee55c845 +P d195d4a65d7184e34a2a08c3ac3db7f6c8c1c21c +R f1988e6e31a1e471b8c207ba95b50e6f U drh -Z 9f199a1ff5417af5f644d4d006d00b95 +Z 903b5f8a9a56d496508b20810e19ed0d diff --git a/manifest.uuid b/manifest.uuid index ccbe8e23d7..0a0e87ef8a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d195d4a65d7184e34a2a08c3ac3db7f6c8c1c21c \ No newline at end of file +b3676377b257bd8bb7fefe9c365d76cdc9e44856 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 4792b13e60..e6023dd035 100644 --- a/src/where.c +++ b/src/where.c @@ -1120,7 +1120,6 @@ static void exprAnalyzeOrTerm( okToChngToIN = 1; for(; i>=0 && okToChngToIN; i--, pOrTerm++){ assert( pOrTerm->eOperator & WO_EQ ); - testcase( pOrTerm->pExpr->op==TK_IS ); if( pOrTerm->leftCursor!=iCursor ){ pOrTerm->wtFlags &= ~TERM_OR_OK; }else if( pOrTerm->u.leftColumn!=iColumn ){ @@ -1157,7 +1156,6 @@ static void exprAnalyzeOrTerm( assert( pOrTerm->eOperator & WO_EQ ); assert( pOrTerm->leftCursor==iCursor ); assert( pOrTerm->u.leftColumn==iColumn ); - testcase( pOrTerm->pExpr->op==TK_IS ); pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0); pList = sqlite3ExprListAppend(pWInfo->pParse, pList, pDup); pLeft = pOrTerm->pExpr->pLeft; @@ -4109,8 +4107,8 @@ static Bitmask codeOneLoopStart( Expr *pE, *pEAlt; WhereTerm *pAlt; if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; - if( (pTerm->eOperator & WO_EQUIV)==0 ) continue; if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) continue; + if( (pTerm->eOperator & WO_EQUIV)==0 ) continue; if( pTerm->leftCursor!=iCur ) continue; if( pLevel->iLeftJoin ) continue; pE = pTerm->pExpr; diff --git a/test/vtab1.test b/test/vtab1.test index c0cf3e4e8d..cd21153f06 100644 --- a/test/vtab1.test +++ b/test/vtab1.test @@ -1085,11 +1085,22 @@ do_test vtab1.13-3 { SELECT * FROM echo_c WHERE b IS NULL } } {15 {} 16} -do_test vtab1.13-3 { +do_test vtab1.13-4 { + unset -nocomplain null + execsql { + SELECT * FROM echo_c WHERE b IS $null + } +} {15 {} 16} +do_test vtab1.13-5 { execsql { SELECT * FROM echo_c WHERE b IS NULL AND a = 15; } } {15 {} 16} +do_test vtab1.13-6 { + execsql { + SELECT * FROM echo_c WHERE NULL IS b AND a IS 15; + } +} {15 {} 16} do_test vtab1-14.001 { From 5d8806e07c90d80cfda629473c847970c25453db Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 May 2015 14:03:21 +0000 Subject: [PATCH 33/33] A few more test cases for the IS operator. FossilOrigin-Name: f397c8622ae5a36a71f81d9f2549ca314005ece5 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/transitive1.test | 18 +++++++++++++++++- test/vtab2.test | 9 ++++++++- test/vtab6.test | 5 +++++ 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 40483626d7..be7f8e7025 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\stest\scases.\s\sRemove\ssome\sinvalid\stestcase()\smacros.\s\sRearrange\ssome\scode\nfor\simproved\stestability. -D 2015-05-14T13:41:22.643 +C A\sfew\smore\stest\scases\sfor\sthe\sIS\soperator. +D 2015-05-14T14:03:21.962 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1082,7 +1082,7 @@ F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 -F test/transitive1.test 03f532954f46cdf5608f7766bff0b0c52bf2a7cd +F test/transitive1.test 875a9f0097a15b30a62431d183f989364d5accac F test/trigger1.test dc47573ac79ffe0ee3eecaa517d70d8dacbccd03 F test/trigger2.test 5cd7d69a7ba1143ee045e4ae2963ff32ae4c87a6 F test/trigger3.test aa640bb2bbb03edd5ff69c055117ea088f121945 @@ -1121,11 +1121,11 @@ F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 F test/view.test f311691d696a5cc27e3c1b875cec1b0866b4ccd9 F test/vtab1.test dbe0e9e121102d0ba365f20d126a72676aa2343f -F test/vtab2.test 3644649aa8d1daac57fd541f6a5f914cac59203e +F test/vtab2.test f8cd1bb9aba7143eba97812d9617880a36d247ad F test/vtab3.test b45f47d20f225ccc9c28dc915d92740c2dee311e F test/vtab4.test 942f8b8280b3ea8a41dae20e7822d065ca1cb275 F test/vtab5.test 889f444970393c73f1e077e2bdc5d845e157a391 -F test/vtab6.test 5f5380c425e52993560ab4763db4f826d2ba7b09 +F test/vtab6.test d2986cf418dc51e7fb81d12366bea2caa8b812df F test/vtab7.test ae560ebea870ed04e9aa4177cc302f910faaabb5 F test/vtab8.test e19fa4a538fcd1bb66c22825fa8f71618fb13583 F test/vtab9.test ea58d2b95d61955f87226381716b2d0b1d4e4f9b @@ -1258,7 +1258,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d195d4a65d7184e34a2a08c3ac3db7f6c8c1c21c -R f1988e6e31a1e471b8c207ba95b50e6f +P b3676377b257bd8bb7fefe9c365d76cdc9e44856 +R bdc88e4814b826734527d4ac723cdd70 U drh -Z 903b5f8a9a56d496508b20810e19ed0d +Z e30ac775b8d8ec0dc6dc3a554502ca78 diff --git a/manifest.uuid b/manifest.uuid index 0a0e87ef8a..db9f372632 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b3676377b257bd8bb7fefe9c365d76cdc9e44856 \ No newline at end of file +f397c8622ae5a36a71f81d9f2549ca314005ece5 \ No newline at end of file diff --git a/test/transitive1.test b/test/transitive1.test index 200dc610fa..3b76d2b01e 100644 --- a/test/transitive1.test +++ b/test/transitive1.test @@ -66,6 +66,12 @@ do_execsql_test transitive1-301 { WHERE w=y AND y IS NOT NULL ORDER BY w; } {1 2 1 3 3 4 3 6 5 6 5 7} +do_execsql_test transitive1-302 { + SELECT * + FROM t301 CROSS JOIN t302 + WHERE w IS y AND y IS NOT NULL + ORDER BY w; +} {1 2 1 3 3 4 3 6 5 6 5 7} do_execsql_test transitive1-310 { SELECT * FROM t301 CROSS JOIN t302 ON w=y @@ -103,7 +109,7 @@ do_execsql_test transitive1-332 { } {3 4 3 6 1 2 1 3} # Ticket [c620261b5b5dc] circa 2013-10-28. -# Make sureconstraints are not used with LEFT JOINs. +# Make sure constraints are not used with LEFT JOINs. # # The next case is from the ticket report. It outputs no rows in 3.8.1 # prior to the bug-fix. @@ -116,6 +122,16 @@ do_execsql_test transitive1-400 { INSERT INTO t403 VALUES(1); SELECT '1-row' FROM t401 LEFT JOIN t402 ON b=a JOIN t403 ON c=a; } {1-row} +do_execsql_test transitive1-401 { + SELECT '1-row' FROM t401 LEFT JOIN t402 ON b IS a JOIN t403 ON c=a; +} {1-row} +do_execsql_test transitive1-402 { + SELECT '1-row' FROM t401 LEFT JOIN t402 ON b=a JOIN t403 ON c IS a; +} {1-row} +do_execsql_test transitive1-403 { + SELECT '1-row' FROM t401 LEFT JOIN t402 ON b IS a JOIN t403 ON c IS a; +} {1-row} + # The following is a script distilled from the XBMC project where the # bug was originally encountered. The correct answer is a single row diff --git a/test/vtab2.test b/test/vtab2.test index 3884ec57df..f0616513bd 100644 --- a/test/vtab2.test +++ b/test/vtab2.test @@ -104,6 +104,14 @@ do_test vtab2-3.2 { WHERE a.rowid=1 } } {main schema 0 database {} 0 {} 0 {} {} {} {} {} {} {} {} {}} +do_test vtab2-3.3 { + execsql { + SELECT *, b.rowid + FROM schema a LEFT JOIN schema b ON a.dflt_value IS b.dflt_value + AND a.dflt_value IS NOT NULL + WHERE a.rowid=1 + } +} {main schema 0 database {} 0 {} 0 {} {} {} {} {} {} {} {} {}} do_test vtab2-4.1 { execsql { @@ -153,4 +161,3 @@ ifcapable fts3 { finish_test - diff --git a/test/vtab6.test b/test/vtab6.test index 10bf286ab0..f8e0935a28 100644 --- a/test/vtab6.test +++ b/test/vtab6.test @@ -233,6 +233,11 @@ do_test vtab6-2.4 { SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d } } {1 2 3 {} {} {} 2 3 4 {} {} {} 3 4 5 1 2 3} +do_test vtab6-2.4.1 { + execsql { + SELECT * FROM t1 LEFT JOIN t2 ON t1.a IS t2.d + } +} {1 2 3 {} {} {} 2 3 4 {} {} {} 3 4 5 1 2 3} do_test vtab6-2.5 { execsql { SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d WHERE t1.a>1