From 882ef0b8c08fd475df3785b37094b00b4173eeb2 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Aug 2016 19:26:57 +0000 Subject: [PATCH 01/14] Have fts5 interpret column lists that begin with a "-" character as "match any column except" lists. FossilOrigin-Name: e517545650631d1e8a7ee63c6646a8b183a0a894 --- ext/fts5/fts5Int.h | 1 + ext/fts5/fts5_expr.c | 61 +++++++++++++++++++++++++++++++++++ ext/fts5/fts5_index.c | 12 +++++++ ext/fts5/fts5parse.y | 11 ++++++- ext/fts5/test/fts5colset.test | 59 +++++++++++++++++++++++++++++++++ manifest | 24 +++++++------- manifest.uuid | 2 +- 7 files changed, 155 insertions(+), 15 deletions(-) create mode 100644 ext/fts5/test/fts5colset.test diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index c7169a113b..9b1316d454 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -737,6 +737,7 @@ void sqlite3Fts5ParseNodeFree(Fts5ExprNode*); void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*); void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*); +void sqlite3Fts5ParseColsetNegative(Fts5Parse*, int); void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p); void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*); diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 9119813c85..be6d768a68 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -124,6 +124,7 @@ struct Fts5Parse { char *zErr; int rc; int nPhrase; /* Size of apPhrase array */ + int bNegativeCollist; /* Column list being parsed started with - */ Fts5ExprPhrase **apPhrase; /* Array of all phrases */ Fts5ExprNode *pExpr; /* Result of a successful parse */ }; @@ -167,6 +168,7 @@ static int fts5ExprGetToken( case ',': tok = FTS5_COMMA; break; case '+': tok = FTS5_PLUS; break; case '*': tok = FTS5_STAR; break; + case '-': tok = FTS5_MINUS; break; case '\0': tok = FTS5_EOF; break; case '"': { @@ -1793,6 +1795,53 @@ static Fts5Colset *fts5ParseColset( return pNew; } +/* +** The second argument passed to this function may be NULL, or it may be +** an existing Fts5Colset object. If it is passed NULL, this function +** returns a pointer to a new Fts5Colset object containing entries for +** all table columns except column iCol. If an OOM error occurs trying to +** allocate the Fts5Colset object, an error code is stored in pParse and +** NULL returned. +** +** If the second argument is not NULL, a copy of it is returned. Before +** returning, any entry for column iCol is removed. It is not an error +** if the Fts5Colset object does not contain an entry for column iCol +** when this function is called. +*/ +static Fts5Colset *fts5ParseNegativeColset( + Fts5Parse *pParse, /* Store SQLITE_NOMEM here if required */ + Fts5Colset *p, /* Existing colset object */ + int iCol /* New column to add to colset object */ +){ + int i; + Fts5Colset *pRet = p; + + if( pRet==0 ){ + int nCol = pParse->pConfig->nCol; + pRet = (Fts5Colset*)sqlite3Fts5MallocZero(&pParse->rc, + sizeof(Fts5Colset) + sizeof(int)*nCol + ); + if( pRet==0 ) return 0; + pRet->nCol = nCol; + for(i=0; iaiCol[i] = i; + } + } + + for(i=0; inCol; i++){ + if( pRet->aiCol[i]==iCol ){ + int nByte = sizeof(int)*(pRet->nCol-i-1); + if( nByte ){ + memmove(&pRet->aiCol[i], &pRet->aiCol[i+1], nByte); + } + pRet->nCol--; + break; + } + } + + return pRet; +} + Fts5Colset *sqlite3Fts5ParseColset( Fts5Parse *pParse, /* Store SQLITE_NOMEM here if required */ Fts5Colset *pColset, /* Existing colset object */ @@ -1811,6 +1860,8 @@ Fts5Colset *sqlite3Fts5ParseColset( } if( iCol==pConfig->nCol ){ sqlite3Fts5ParseError(pParse, "no such column: %s", z); + }else if( pParse->bNegativeCollist ){ + pRet = fts5ParseNegativeColset(pParse, pColset, iCol); }else{ pRet = fts5ParseColset(pParse, pColset, iCol); } @@ -1825,6 +1876,16 @@ Fts5Colset *sqlite3Fts5ParseColset( return pRet; } +/* +** Set (bVal==1) or clear (bVal==0) the Fts5Parse.bNegativeCollist flag. +** +** The parser calls this function as it begins to parse a colset (Fts5Colset +** object) with bVal set to 1 if the colset begins with a "-" or 0 otherwise. +*/ +void sqlite3Fts5ParseColsetNegative(Fts5Parse *pParse, int bVal){ + pParse->bNegativeCollist = bVal; +} + void sqlite3Fts5ParseSetColset( Fts5Parse *pParse, Fts5ExprNearset *pNear, diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 1d5ebe1428..52fdc634a5 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -3195,6 +3195,14 @@ static void fts5IterSetOutputs_Nocolset(Fts5Iter *pIter, Fts5SegIter *pSeg){ } } +/* +** xSetOutputs callback used when the Fts5Colset object has nCol==0 (match +** against no columns at all). +*/ +static void fts5IterSetOutputs_ZeroColset(Fts5Iter *pIter, Fts5SegIter *pSeg){ + pIter->base.nData = 0; +} + /* ** xSetOutputs callback used by detail=col when there is a column filter ** and there are 100 or more columns. Also called as a fallback from @@ -3300,6 +3308,10 @@ static void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){ pIter->xSetOutputs = fts5IterSetOutputs_Nocolset; } + else if( pIter->pColset->nCol==0 ){ + pIter->xSetOutputs = fts5IterSetOutputs_ZeroColset; + } + else if( pConfig->eDetail==FTS5_DETAIL_FULL ){ pIter->xSetOutputs = fts5IterSetOutputs_Full; } diff --git a/ext/fts5/fts5parse.y b/ext/fts5/fts5parse.y index 1607d3846a..8bc95f7364 100644 --- a/ext/fts5/fts5parse.y +++ b/ext/fts5/fts5parse.y @@ -119,18 +119,27 @@ cnearset(A) ::= colset(X) COLON nearset(Y). { %destructor colset { sqlite3_free($$); } %type colsetlist {Fts5Colset*} %destructor colsetlist { sqlite3_free($$); } +%type minus_opt {int} colset(A) ::= LCP colsetlist(X) RCP. { A = X; } +colset(A) ::= MINUS STRING(X). { + sqlite3Fts5ParseColsetNegative(pParse, 1); + A = sqlite3Fts5ParseColset(pParse, 0, &X); +} colset(A) ::= STRING(X). { + sqlite3Fts5ParseColsetNegative(pParse, 0); A = sqlite3Fts5ParseColset(pParse, 0, &X); } colsetlist(A) ::= colsetlist(Y) STRING(X). { A = sqlite3Fts5ParseColset(pParse, Y, &X); } -colsetlist(A) ::= STRING(X). { +colsetlist(A) ::= minus_opt(M) STRING(X). { + sqlite3Fts5ParseColsetNegative(pParse, M); A = sqlite3Fts5ParseColset(pParse, 0, &X); } +minus_opt(A) ::= MINUS. { A = 1; } +minus_opt(A) ::= . { A = 0; } %type nearset {Fts5ExprNearset*} %type nearphrases {Fts5ExprNearset*} diff --git a/ext/fts5/test/fts5colset.test b/ext/fts5/test/fts5colset.test new file mode 100644 index 0000000000..c09974a742 --- /dev/null +++ b/ext/fts5/test/fts5colset.test @@ -0,0 +1,59 @@ +# 2016 August 10 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# This file implements regression tests for SQLite library. The +# focus of this script is testing the FTS5 module. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5colset + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +foreach_detail_mode $::testprefix { + if {[detail_is_none]} continue + + do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, d, detail=%DETAIL%); + INSERT INTO t1 VALUES('a', 'b', 'c', 'd'); -- 1 + INSERT INTO t1 VALUES('d', 'a', 'b', 'c'); -- 2 + INSERT INTO t1 VALUES('c', 'd', 'a', 'b'); -- 3 + INSERT INTO t1 VALUES('b', 'c', 'd', 'a'); -- 4 + } + + foreach {tn q res} { + 1 "a" {1 2 3 4} + 2 "{a} : a" {1} + 3 "{-a} : a" {2 3 4} + 4 "{-a c} : a" {2 4} + 5 "{-d d c} : a" {1 2} + 6 "{-d c b a} : a" {} + 7 "{-\"a\"} : b" {1 2 3} + 8 "- c : a" {1 2 4} + 9 "-c : a" {1 2 4} + 10 "-\"c\" : a" {1 2 4} + } { + breakpoint + do_execsql_test 1.$tn { + SELECT rowid FROM t1($q) + } $res + } + + +} + + +finish_test + + diff --git a/manifest b/manifest index 9d5c14e49e..df25caa15d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.14 -D 2016-08-08T13:40:27.974 +C Have\sfts5\sinterpret\scolumn\slists\sthat\sbegin\swith\sa\s"-"\scharacter\sas\s"match\sany\scolumn\sexcept"\slists. +D 2016-08-09T19:26:57.822 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -98,13 +98,13 @@ F ext/fts3/unicode/mkunicode.tcl 2debed3f582d77b3fdd0b8830880250021571fd8 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 62f3e33ceeb9a428db139f9c012186b371da1cc7 -F ext/fts5/fts5Int.h 9bd0c7c64285b5b368eca0ac63613185c5ad24ba +F ext/fts5/fts5Int.h 51eb867d9afbd1a4130fde00c39acf9aacabe1b6 F ext/fts5/fts5_aux.c daa57fb45216491814520bbb587e97bf81ced458 F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 -F ext/fts5/fts5_expr.c bcb238ee4ac1164302ab528487520488516bd030 +F ext/fts5/fts5_expr.c 8e975ae07dbff244adea3a3697f027fa5387a991 F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 -F ext/fts5/fts5_index.c b429e23fabb57506f71e406997cc46b89190dc97 +F ext/fts5/fts5_index.c e25ac419fc66f412e6044595b20b4bf8f7cea284 F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 F ext/fts5/fts5_storage.c de0ed8a06738bde433afe11e92295ceaffbc4e58 F ext/fts5/fts5_tcl.c 4a901f00c8553740dba63511603f5527d741c26a @@ -114,7 +114,7 @@ F ext/fts5/fts5_tokenize.c 2ce7b44183538ec46b7907726262ee43ffdd39a8 F ext/fts5/fts5_unicode2.c b450b209b157d598f7b9df9f837afb75a14c24bf F ext/fts5/fts5_varint.c a5aceacda04dafcbae725413d7a16818ecd65738 F ext/fts5/fts5_vocab.c dba72ca393d71c2588548b51380387f6b44c77a8 -F ext/fts5/fts5parse.y fcc5e92e570d38cab38488b2109cbf67468923b2 +F ext/fts5/fts5parse.y bc2f2d9a726e69443ca58a5c0164283a63da819e F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl b01c584144b5064f30e6c648145a2dd6bc440841 F ext/fts5/test/fts5aa.test bd2d88182b9f7f30d300044048ad14683306b745 @@ -135,6 +135,7 @@ F ext/fts5/test/fts5aux.test 5dd158a1e7869e27e9762a2a452b189c728d1be3 F ext/fts5/test/fts5auxdata.test 141a7cbffcceb1bd2799b4b29c183ff8780d586e F ext/fts5/test/fts5bigpl.test 04ee0d7eebbebf17c31f5a0b5c5f9494eac3a0cb F ext/fts5/test/fts5bigtok.test 017a9397b14e7598883a6328ead4a6539b42d59a +F ext/fts5/test/fts5colset.test ad686cc648264f0334d2cc11b842e99f6e2bc10a F ext/fts5/test/fts5columnsize.test a8cfef21ffa1c264b9f670a7d94eeaccb5341c07 F ext/fts5/test/fts5config.test 7788b9c058074d640dfcdd81d97b6a9480000368 F ext/fts5/test/fts5conflict.test 26f4e46c4d31e16221794832a990dc4e30e18de5 @@ -1509,10 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ebc396a19fa79bea208ecda277ffff5d02166d0b -R e7962d3372d6a1e29e3980753a6f0162 -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.14.0 * -U drh -Z ecb9b7072c2b71d36f58909f83563ec2 +P d5e98057028abcf7217d0d2b2e29bbbcdf09d6de +R bd788c6a4ffbd14fc48e3960d75681eb +U dan +Z 8eb6c4d9289f254e7f02b4786ea43ed2 diff --git a/manifest.uuid b/manifest.uuid index 732a4af61b..0c0e3e4b5b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d5e98057028abcf7217d0d2b2e29bbbcdf09d6de \ No newline at end of file +e517545650631d1e8a7ee63c6646a8b183a0a894 \ No newline at end of file From ccf03677a38901d7d21fdd04a9338a31a8b850ab Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Aug 2016 19:48:37 +0000 Subject: [PATCH 02/14] Minor update to the way fts5 column filters are parsed. FossilOrigin-Name: 14864f2b8470fe98dbd17f59963bf1be8d4962f9 --- ext/fts5/fts5Int.h | 1 + ext/fts5/fts5_expr.c | 66 +++++++++-------------------------- ext/fts5/fts5parse.y | 17 ++++----- ext/fts5/test/fts5colset.test | 10 +++--- manifest | 18 +++++----- manifest.uuid | 2 +- 6 files changed, 40 insertions(+), 74 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 9b1316d454..273b5bba29 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -738,6 +738,7 @@ void sqlite3Fts5ParseNodeFree(Fts5ExprNode*); void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*); void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*); void sqlite3Fts5ParseColsetNegative(Fts5Parse*, int); +Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*); void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p); void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*); diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index be6d768a68..ca795a6b35 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -124,7 +124,6 @@ struct Fts5Parse { char *zErr; int rc; int nPhrase; /* Size of apPhrase array */ - int bNegativeCollist; /* Column list being parsed started with - */ Fts5ExprPhrase **apPhrase; /* Array of all phrases */ Fts5ExprNode *pExpr; /* Result of a successful parse */ }; @@ -1796,49 +1795,30 @@ static Fts5Colset *fts5ParseColset( } /* -** The second argument passed to this function may be NULL, or it may be -** an existing Fts5Colset object. If it is passed NULL, this function -** returns a pointer to a new Fts5Colset object containing entries for -** all table columns except column iCol. If an OOM error occurs trying to -** allocate the Fts5Colset object, an error code is stored in pParse and -** NULL returned. -** -** If the second argument is not NULL, a copy of it is returned. Before -** returning, any entry for column iCol is removed. It is not an error -** if the Fts5Colset object does not contain an entry for column iCol -** when this function is called. +** Allocate and return an Fts5Colset object specifying the inverse of +** the colset passed as the second argument. Free the colset passed +** as the second argument before returning. */ -static Fts5Colset *fts5ParseNegativeColset( - Fts5Parse *pParse, /* Store SQLITE_NOMEM here if required */ - Fts5Colset *p, /* Existing colset object */ - int iCol /* New column to add to colset object */ -){ - int i; - Fts5Colset *pRet = p; +Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse *pParse, Fts5Colset *p){ + Fts5Colset *pRet; + int nCol = pParse->pConfig->nCol; - if( pRet==0 ){ - int nCol = pParse->pConfig->nCol; - pRet = (Fts5Colset*)sqlite3Fts5MallocZero(&pParse->rc, - sizeof(Fts5Colset) + sizeof(int)*nCol - ); - if( pRet==0 ) return 0; - pRet->nCol = nCol; + pRet = (Fts5Colset*)sqlite3Fts5MallocZero(&pParse->rc, + sizeof(Fts5Colset) + sizeof(int)*nCol + ); + if( pRet ){ + int i; + int iOld = 0; for(i=0; iaiCol[i] = i; - } - } - - for(i=0; inCol; i++){ - if( pRet->aiCol[i]==iCol ){ - int nByte = sizeof(int)*(pRet->nCol-i-1); - if( nByte ){ - memmove(&pRet->aiCol[i], &pRet->aiCol[i+1], nByte); + if( iOld>=p->nCol || p->aiCol[iOld]!=i ){ + pRet->aiCol[pRet->nCol++] = i; + }else{ + iOld++; } - pRet->nCol--; - break; } } + sqlite3_free(p); return pRet; } @@ -1860,8 +1840,6 @@ Fts5Colset *sqlite3Fts5ParseColset( } if( iCol==pConfig->nCol ){ sqlite3Fts5ParseError(pParse, "no such column: %s", z); - }else if( pParse->bNegativeCollist ){ - pRet = fts5ParseNegativeColset(pParse, pColset, iCol); }else{ pRet = fts5ParseColset(pParse, pColset, iCol); } @@ -1876,16 +1854,6 @@ Fts5Colset *sqlite3Fts5ParseColset( return pRet; } -/* -** Set (bVal==1) or clear (bVal==0) the Fts5Parse.bNegativeCollist flag. -** -** The parser calls this function as it begins to parse a colset (Fts5Colset -** object) with bVal set to 1 if the colset begins with a "-" or 0 otherwise. -*/ -void sqlite3Fts5ParseColsetNegative(Fts5Parse *pParse, int bVal){ - pParse->bNegativeCollist = bVal; -} - void sqlite3Fts5ParseSetColset( Fts5Parse *pParse, Fts5ExprNearset *pNear, diff --git a/ext/fts5/fts5parse.y b/ext/fts5/fts5parse.y index 8bc95f7364..1cc4b88e18 100644 --- a/ext/fts5/fts5parse.y +++ b/ext/fts5/fts5parse.y @@ -119,28 +119,25 @@ cnearset(A) ::= colset(X) COLON nearset(Y). { %destructor colset { sqlite3_free($$); } %type colsetlist {Fts5Colset*} %destructor colsetlist { sqlite3_free($$); } -%type minus_opt {int} +colset(A) ::= MINUS LCP colsetlist(X) RCP. { + A = sqlite3Fts5ParseColsetInvert(pParse, X); +} colset(A) ::= LCP colsetlist(X) RCP. { A = X; } -colset(A) ::= MINUS STRING(X). { - sqlite3Fts5ParseColsetNegative(pParse, 1); +colset(A) ::= STRING(X). { A = sqlite3Fts5ParseColset(pParse, 0, &X); } -colset(A) ::= STRING(X). { - sqlite3Fts5ParseColsetNegative(pParse, 0); +colset(A) ::= MINUS STRING(X). { A = sqlite3Fts5ParseColset(pParse, 0, &X); + A = sqlite3Fts5ParseColsetInvert(pParse, A); } colsetlist(A) ::= colsetlist(Y) STRING(X). { A = sqlite3Fts5ParseColset(pParse, Y, &X); } -colsetlist(A) ::= minus_opt(M) STRING(X). { - sqlite3Fts5ParseColsetNegative(pParse, M); +colsetlist(A) ::= STRING(X). { A = sqlite3Fts5ParseColset(pParse, 0, &X); } -minus_opt(A) ::= MINUS. { A = 1; } -minus_opt(A) ::= . { A = 0; } - %type nearset {Fts5ExprNearset*} %type nearphrases {Fts5ExprNearset*} %destructor nearset { sqlite3Fts5ParseNearsetFree($$); } diff --git a/ext/fts5/test/fts5colset.test b/ext/fts5/test/fts5colset.test index c09974a742..e3333241ee 100644 --- a/ext/fts5/test/fts5colset.test +++ b/ext/fts5/test/fts5colset.test @@ -35,11 +35,11 @@ foreach_detail_mode $::testprefix { foreach {tn q res} { 1 "a" {1 2 3 4} 2 "{a} : a" {1} - 3 "{-a} : a" {2 3 4} - 4 "{-a c} : a" {2 4} - 5 "{-d d c} : a" {1 2} - 6 "{-d c b a} : a" {} - 7 "{-\"a\"} : b" {1 2 3} + 3 "-{a} : a" {2 3 4} + 4 "- {a c} : a" {2 4} + 5 " - {d d c} : a" {1 2} + 6 "- {d c b a} : a" {} + 7 "-{\"a\"} : b" {1 2 3} 8 "- c : a" {1 2 4} 9 "-c : a" {1 2 4} 10 "-\"c\" : a" {1 2 4} diff --git a/manifest b/manifest index df25caa15d..ce75d33797 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sfts5\sinterpret\scolumn\slists\sthat\sbegin\swith\sa\s"-"\scharacter\sas\s"match\sany\scolumn\sexcept"\slists. -D 2016-08-09T19:26:57.822 +C Minor\supdate\sto\sthe\sway\sfts5\scolumn\sfilters\sare\sparsed. +D 2016-08-09T19:48:37.555 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -98,11 +98,11 @@ F ext/fts3/unicode/mkunicode.tcl 2debed3f582d77b3fdd0b8830880250021571fd8 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 62f3e33ceeb9a428db139f9c012186b371da1cc7 -F ext/fts5/fts5Int.h 51eb867d9afbd1a4130fde00c39acf9aacabe1b6 +F ext/fts5/fts5Int.h 17d72c55d6e0d23cd6a3936312a5fd8cddcbd962 F ext/fts5/fts5_aux.c daa57fb45216491814520bbb587e97bf81ced458 F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 -F ext/fts5/fts5_expr.c 8e975ae07dbff244adea3a3697f027fa5387a991 +F ext/fts5/fts5_expr.c df0004b5bffcbe34c329f2992669c6352443f415 F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 F ext/fts5/fts5_index.c e25ac419fc66f412e6044595b20b4bf8f7cea284 F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 @@ -114,7 +114,7 @@ F ext/fts5/fts5_tokenize.c 2ce7b44183538ec46b7907726262ee43ffdd39a8 F ext/fts5/fts5_unicode2.c b450b209b157d598f7b9df9f837afb75a14c24bf F ext/fts5/fts5_varint.c a5aceacda04dafcbae725413d7a16818ecd65738 F ext/fts5/fts5_vocab.c dba72ca393d71c2588548b51380387f6b44c77a8 -F ext/fts5/fts5parse.y bc2f2d9a726e69443ca58a5c0164283a63da819e +F ext/fts5/fts5parse.y e51b375403421b8b37428a89b095d00597129aae F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl b01c584144b5064f30e6c648145a2dd6bc440841 F ext/fts5/test/fts5aa.test bd2d88182b9f7f30d300044048ad14683306b745 @@ -135,7 +135,7 @@ F ext/fts5/test/fts5aux.test 5dd158a1e7869e27e9762a2a452b189c728d1be3 F ext/fts5/test/fts5auxdata.test 141a7cbffcceb1bd2799b4b29c183ff8780d586e F ext/fts5/test/fts5bigpl.test 04ee0d7eebbebf17c31f5a0b5c5f9494eac3a0cb F ext/fts5/test/fts5bigtok.test 017a9397b14e7598883a6328ead4a6539b42d59a -F ext/fts5/test/fts5colset.test ad686cc648264f0334d2cc11b842e99f6e2bc10a +F ext/fts5/test/fts5colset.test 1cdf56e079316005aabda790059aee86f2222ee4 F ext/fts5/test/fts5columnsize.test a8cfef21ffa1c264b9f670a7d94eeaccb5341c07 F ext/fts5/test/fts5config.test 7788b9c058074d640dfcdd81d97b6a9480000368 F ext/fts5/test/fts5conflict.test 26f4e46c4d31e16221794832a990dc4e30e18de5 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d5e98057028abcf7217d0d2b2e29bbbcdf09d6de -R bd788c6a4ffbd14fc48e3960d75681eb +P e517545650631d1e8a7ee63c6646a8b183a0a894 +R da20bee26e7c2a9f4b1bf24d21e0ff86 U dan -Z 8eb6c4d9289f254e7f02b4786ea43ed2 +Z a6c95b8c36e7e9259f54069259e2a828 diff --git a/manifest.uuid b/manifest.uuid index 0c0e3e4b5b..7cd334dbf2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e517545650631d1e8a7ee63c6646a8b183a0a894 \ No newline at end of file +14864f2b8470fe98dbd17f59963bf1be8d4962f9 \ No newline at end of file From 8d57d7af23f942dd44b16dea77c0045701cc6e5e Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 9 Aug 2016 21:01:52 +0000 Subject: [PATCH 03/14] Fix harmless compiler warning. FossilOrigin-Name: 9a5a4f6e3bc265fecf79a7f63d14abbf239da636 --- ext/fts5/fts5Int.h | 1 - manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 273b5bba29..9ef338e821 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -737,7 +737,6 @@ void sqlite3Fts5ParseNodeFree(Fts5ExprNode*); void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*); void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*); -void sqlite3Fts5ParseColsetNegative(Fts5Parse*, int); Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*); void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p); void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*); diff --git a/manifest b/manifest index ce75d33797..850a297904 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\supdate\sto\sthe\sway\sfts5\scolumn\sfilters\sare\sparsed. -D 2016-08-09T19:48:37.555 +C Fix\sharmless\scompiler\swarning. +D 2016-08-09T21:01:52.333 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -98,7 +98,7 @@ F ext/fts3/unicode/mkunicode.tcl 2debed3f582d77b3fdd0b8830880250021571fd8 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 62f3e33ceeb9a428db139f9c012186b371da1cc7 -F ext/fts5/fts5Int.h 17d72c55d6e0d23cd6a3936312a5fd8cddcbd962 +F ext/fts5/fts5Int.h b2eda36e0f224365c8e23dc8f559311834f1c13f F ext/fts5/fts5_aux.c daa57fb45216491814520bbb587e97bf81ced458 F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e517545650631d1e8a7ee63c6646a8b183a0a894 -R da20bee26e7c2a9f4b1bf24d21e0ff86 -U dan -Z a6c95b8c36e7e9259f54069259e2a828 +P 14864f2b8470fe98dbd17f59963bf1be8d4962f9 +R 3c3d32515aedcf447480f55f3548a5e0 +U drh +Z 4951f1f9d58f89a54689c68080c6d7fb diff --git a/manifest.uuid b/manifest.uuid index 7cd334dbf2..a3c154d615 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -14864f2b8470fe98dbd17f59963bf1be8d4962f9 \ No newline at end of file +9a5a4f6e3bc265fecf79a7f63d14abbf239da636 \ No newline at end of file From c83db9e4e1c0cba15effedb4bf5411653b5c9005 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 01:43:30 +0000 Subject: [PATCH 04/14] Performance optimization in the yy_find_shift_action() routine of the Lemon-generated parser. FossilOrigin-Name: ba6663beefcc8060e6f3be6ab37c13fdbb08b7de --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lempar.c | 53 ++++++++++++++++++++++++--------------------------- 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/manifest b/manifest index 850a297904..679af7eda6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarning. -D 2016-08-09T21:01:52.333 +C Performance\soptimization\sin\sthe\syy_find_shift_action()\sroutine\sof\sthe\nLemon-generated\sparser. +D 2016-08-10T01:43:30.837 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1438,7 +1438,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 -F tool/lempar.c 57ffa9852901f6abc45981f0d882f31d1ccb06c0 +F tool/lempar.c 321ebbf1c85ab5435434042590eca0616da24b3d F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 14864f2b8470fe98dbd17f59963bf1be8d4962f9 -R 3c3d32515aedcf447480f55f3548a5e0 +P 9a5a4f6e3bc265fecf79a7f63d14abbf239da636 +R fb6cb5f47404a4ca8ae3044e53622029 U drh -Z 4951f1f9d58f89a54689c68080c6d7fb +Z 1ed24d5681cad4ee5c357b2d89914ae1 diff --git a/manifest.uuid b/manifest.uuid index a3c154d615..f5266c615d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9a5a4f6e3bc265fecf79a7f63d14abbf239da636 \ No newline at end of file +ba6663beefcc8060e6f3be6ab37c13fdbb08b7de \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index e0d0e88565..74906ae17f 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -450,50 +450,47 @@ static unsigned int yy_find_shift_action( assert( stateno <= YY_SHIFT_COUNT ); do{ i = yy_shift_ofst[stateno]; - if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno]; assert( iLookAhead!=YYNOCODE ); i += iLookAhead; if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ - if( iLookAhead>0 ){ #ifdef YYFALLBACK - YYCODETYPE iFallback; /* Fallback token */ - if( iLookAhead %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); - } -#endif - assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */ - iLookAhead = iFallback; - continue; + if( yyTraceFILE ){ + fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", + yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); } +#endif + assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */ + iLookAhead = iFallback; + continue; + } #endif #ifdef YYWILDCARD - { - int j = i - iLookAhead + YYWILDCARD; - if( + { + int j = i - iLookAhead + YYWILDCARD; + if( #if YY_SHIFT_MIN+YYWILDCARD<0 - j>=0 && + j>=0 && #endif #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j0 + ){ #ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", - yyTracePrompt, yyTokenName[iLookAhead], - yyTokenName[YYWILDCARD]); - } -#endif /* NDEBUG */ - return yy_action[j]; + if( yyTraceFILE ){ + fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", + yyTracePrompt, yyTokenName[iLookAhead], + yyTokenName[YYWILDCARD]); } +#endif /* NDEBUG */ + return yy_action[j]; } -#endif /* YYWILDCARD */ } +#endif /* YYWILDCARD */ return yy_default[stateno]; }else{ return yy_action[i]; From d9fabbcc5beff63ef8eb29d36dee0ffae55b67b6 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 11:50:12 +0000 Subject: [PATCH 05/14] Fix pcache1TruncateUnsafe() run faster for the case where iLimit is very close to iMaxKey. FossilOrigin-Name: b07a26df06a2ffb946ff8a1cc7f43eaf701a94b5 --- manifest | 13 +++++++------ manifest.uuid | 2 +- src/pcache1.c | 34 +++++++++++++++++++++++++++------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 679af7eda6..316b95fb86 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\soptimization\sin\sthe\syy_find_shift_action()\sroutine\sof\sthe\nLemon-generated\sparser. -D 2016-08-10T01:43:30.837 +C Fix\spcache1TruncateUnsafe()\srun\sfaster\sfor\sthe\scase\swhere\siLimit\sis\nvery\sclose\sto\siMaxKey. +D 2016-08-10T11:50:12.345 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -376,7 +376,7 @@ F src/pager.h 966d2769e76ae347c8a32c4165faf6e6cb64546d F src/parse.y 99b676e6fc2f4e331ab93e76b3987cffdbd28efa F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 -F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d +F src/pcache1.c dc8a6052e5136d6b5e6afe51f37485145646f5ab F src/pragma.c c8b499756658cb8b82cfdbb5845c22cf11f297aa F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e @@ -1510,7 +1510,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9a5a4f6e3bc265fecf79a7f63d14abbf239da636 -R fb6cb5f47404a4ca8ae3044e53622029 +P ba6663beefcc8060e6f3be6ab37c13fdbb08b7de +Q +9ab53605d562a926c5620cba9dc96a3b812a432f +R 045183d4dc58e68027bf139105903731 U drh -Z 1ed24d5681cad4ee5c357b2d89914ae1 +Z 7fb6739dae3ac730e38720df5d5c1de9 diff --git a/manifest.uuid b/manifest.uuid index f5266c615d..5bb9a78a83 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ba6663beefcc8060e6f3be6ab37c13fdbb08b7de \ No newline at end of file +b07a26df06a2ffb946ff8a1cc7f43eaf701a94b5 \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 5fe963ad05..1af1ef5bb7 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -632,12 +632,30 @@ static void pcache1TruncateUnsafe( PCache1 *pCache, /* The cache to truncate */ unsigned int iLimit /* Drop pages with this pgno or larger */ ){ - TESTONLY( unsigned int nPage = 0; ) /* To assert pCache->nPage is correct */ - unsigned int h; + TESTONLY( int nPage = 0; ) /* To assert pCache->nPage is correct */ + unsigned int h, iStop; assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); - for(h=0; hnHash; h++){ - PgHdr1 **pp = &pCache->apHash[h]; + assert( pCache->iMaxKey >= iLimit ); + assert( pCache->nHash > 0 ); + if( pCache->iMaxKey - iLimit < pCache->nHash/2 ){ + /* If we are just shaving the last few pages off the end of the + ** cache, then there is no point in scanning the entire hash table. + ** Only scan those hash slots that might contain pages that need to + ** be removed. */ + iStop = iLimit % pCache->nHash; + h = pCache->iMaxKey % pCache->nHash; + TESTONLY( nPage = -10; ) /* Disable the pCache->nPage validity check */ + }else{ + /* This is the general case where many pages are being removed. + ** It is necessary to scan the entire hash table */ + iStop = 0; + h = pCache->nHash - 1; + } + for(;;){ + PgHdr1 **pp; PgHdr1 *pPage; + assert( hnHash ); + pp = &pCache->apHash[h]; while( (pPage = *pp)!=0 ){ if( pPage->iKey>=iLimit ){ pCache->nPage--; @@ -646,11 +664,13 @@ static void pcache1TruncateUnsafe( pcache1FreePage(pPage); }else{ pp = &pPage->pNext; - TESTONLY( nPage++; ) + TESTONLY( if( nPage>=0 ) nPage++; ) } } + if( h==iStop ) break; + h = h ? h-1 : pCache->nHash - 1; } - assert( pCache->nPage==nPage ); + assert( nPage<0 || pCache->nPage==(unsigned)nPage ); } /******************************************************************************/ @@ -1127,7 +1147,7 @@ static void pcache1Destroy(sqlite3_pcache *p){ PGroup *pGroup = pCache->pGroup; assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) ); pcache1EnterMutex(pGroup); - pcache1TruncateUnsafe(pCache, 0); + if( pCache->nPage ) pcache1TruncateUnsafe(pCache, 0); assert( pGroup->nMaxPage >= pCache->nMax ); pGroup->nMaxPage -= pCache->nMax; assert( pGroup->nMinPage >= pCache->nMin ); From 701b68879c06620e0e4b7dcbb644fbeb951867ba Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 13:30:43 +0000 Subject: [PATCH 06/14] Improved comments on the lempar.c parser template. Adjust the YY_SHIFT_USE_DFLT constant in the Lemon-generated parser tables so as to guarantee that it is always out of range of the yy_lookahead[] table. FossilOrigin-Name: 83622f3f50030e4d6abafb99d99742928aaf157c --- manifest | 15 +++++++-------- manifest.uuid | 2 +- tool/lemon.c | 13 +++++++------ tool/lempar.c | 20 ++++++++++++-------- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 316b95fb86..a0534bfabe 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\spcache1TruncateUnsafe()\srun\sfaster\sfor\sthe\scase\swhere\siLimit\sis\nvery\sclose\sto\siMaxKey. -D 2016-08-10T11:50:12.345 +C Improved\scomments\son\sthe\slempar.c\sparser\stemplate.\s\sAdjust\sthe\nYY_SHIFT_USE_DFLT\sconstant\sin\sthe\sLemon-generated\sparser\stables\sso\sas\nto\sguarantee\sthat\sit\sis\salways\sout\sof\srange\sof\sthe\syy_lookahead[]\stable. +D 2016-08-10T13:30:43.279 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1437,8 +1437,8 @@ F tool/fuzzershell.c 94019b185caceffc9f7c7b678a6489e42bc2aefa F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 -F tool/lempar.c 321ebbf1c85ab5435434042590eca0616da24b3d +F tool/lemon.c e3aa9ba3469804d7cae13b5e041aab192b7b381a +F tool/lempar.c 147e42a5cd83ce38275fde0d07a5df3330cb9b3b F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1510,8 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ba6663beefcc8060e6f3be6ab37c13fdbb08b7de -Q +9ab53605d562a926c5620cba9dc96a3b812a432f -R 045183d4dc58e68027bf139105903731 +P b07a26df06a2ffb946ff8a1cc7f43eaf701a94b5 +R f8409033fe00bbe724670b3d36a1f97d U drh -Z 7fb6739dae3ac730e38720df5d5c1de9 +Z c9080bc44cd5d5b39b4e8d736cb94a4a diff --git a/manifest.uuid b/manifest.uuid index 5bb9a78a83..d2f3f5ca4a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b07a26df06a2ffb946ff8a1cc7f43eaf701a94b5 \ No newline at end of file +83622f3f50030e4d6abafb99d99742928aaf157c \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 5f124601db..df758a5da6 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -4231,20 +4231,21 @@ void ReportTable( fprintf(out, "};\n"); lineno++; /* Output the yy_shift_ofst[] table */ - fprintf(out, "#define YY_SHIFT_USE_DFLT (%d)\n", mnTknOfst-1); lineno++; n = lemp->nxstate; while( n>0 && lemp->sorted[n-1]->iTknOfst==NO_OFFSET ) n--; - fprintf(out, "#define YY_SHIFT_COUNT (%d)\n", n-1); lineno++; - fprintf(out, "#define YY_SHIFT_MIN (%d)\n", mnTknOfst); lineno++; - fprintf(out, "#define YY_SHIFT_MAX (%d)\n", mxTknOfst); lineno++; + fprintf(out, "#define YY_SHIFT_USE_DFLT (%d)\n", lemp->nactiontab); lineno++; + fprintf(out, "#define YY_SHIFT_COUNT (%d)\n", n-1); lineno++; + fprintf(out, "#define YY_SHIFT_MIN (%d)\n", mnTknOfst); lineno++; + fprintf(out, "#define YY_SHIFT_MAX (%d)\n", mxTknOfst); lineno++; fprintf(out, "static const %s yy_shift_ofst[] = {\n", - minimum_size_type(mnTknOfst-1, mxTknOfst, &sz)); lineno++; + minimum_size_type(mnTknOfst, lemp->nterminal+lemp->nactiontab, &sz)); + lineno++; lemp->tablesize += n*sz; for(i=j=0; isorted[i]; ofst = stp->iTknOfst; - if( ofst==NO_OFFSET ) ofst = mnTknOfst - 1; + if( ofst==NO_OFFSET ) ofst = lemp->nactiontab; if( j==0 ) fprintf(out," /* %5d */ ", i); fprintf(out, " %4d,", ofst); if( j==9 || i==n-1 ){ diff --git a/tool/lempar.c b/tool/lempar.c index 74906ae17f..61d19451e9 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -116,7 +116,7 @@ ** ** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE ** and YY_MAX_REDUCE - +** ** N == YY_ERROR_ACTION A syntax error has occurred. ** ** N == YY_ACCEPT_ACTION The parser accepts its input. @@ -125,16 +125,20 @@ ** slots in the yy_action[] table. ** ** The action table is constructed as a single large table named yy_action[]. -** Given state S and lookahead X, the action is computed as +** Given state S and lookahead X, the action is computed as either: ** -** yy_action[ yy_shift_ofst[S] + X ] +** (A) N = yy_action[ yy_shift_ofst[S] + X ] +** (B) N = yy_default[S] ** -** If the index value yy_shift_ofst[S]+X is out of range or if the value -** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] -** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table -** and that yy_default[S] should be used instead. +** The (A) formula is preferred. The B formula is used instead if: +** (1) The yy_shift_ofst[S]+X value is out of range, or +** (2) yy_lookahead[yy_shift_ofst[S]+X] is not equal to X, or +** (3) yy_shift_ofst[S] equal YY_SHIFT_USE_DFLT. +** (Implementation note: YY_SHIFT_USE_DFLT is chosen so that +** YY_SHIFT_USE_DFLT+X will be out of range for all possible lookaheads X. +** Hence only tests (1) and (2) need to be evaluated.) ** -** The formula above is for computing the action when the lookahead is +** The formulas above are for computing the action when the lookahead is ** a terminal symbol. If the lookahead is a non-terminal (as occurs after ** a reduce action) then the yy_reduce_ofst[] array is used in place of ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of From 765fecf0103292e1dec8117bf4dff134cbbc58fc Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 13:34:16 +0000 Subject: [PATCH 07/14] Increment the version number to 3.15. FossilOrigin-Name: 8c2701e70ab2553d7a586ff5fe7afa02d8c63199 --- VERSION | 2 +- configure | 18 +++++++++--------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index f982feb41b..f02113fe87 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.14.0 +3.15.0 diff --git a/configure b/configure index fbcf7309b1..75c7a3720d 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.69 for sqlite 3.14.0. +# Generated by GNU Autoconf 2.69 for sqlite 3.15.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -726,8 +726,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.14.0' -PACKAGE_STRING='sqlite 3.14.0' +PACKAGE_VERSION='3.15.0' +PACKAGE_STRING='sqlite 3.15.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1463,7 +1463,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.14.0 to adapt to many kinds of systems. +\`configure' configures sqlite 3.15.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1528,7 +1528,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.14.0:";; + short | recursive ) echo "Configuration of sqlite 3.15.0:";; esac cat <<\_ACEOF @@ -1652,7 +1652,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.14.0 +sqlite configure 3.15.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2071,7 +2071,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.14.0, which was +It was created by sqlite $as_me 3.15.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -12151,7 +12151,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=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.14.0, which was +This file was extended by sqlite $as_me 3.15.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -12217,7 +12217,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sqlite config.status 3.14.0 +sqlite config.status 3.15.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/manifest b/manifest index a0534bfabe..3a6e935e56 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Improved\scomments\son\sthe\slempar.c\sparser\stemplate.\s\sAdjust\sthe\nYY_SHIFT_USE_DFLT\sconstant\sin\sthe\sLemon-generated\sparser\stables\sso\sas\nto\sguarantee\sthat\sit\sis\salways\sout\sof\srange\sof\sthe\syy_lookahead[]\stable. -D 2016-08-10T13:30:43.279 +C Increment\sthe\sversion\snumber\sto\s3.15. +D 2016-08-10T13:34:16.502 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 -F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e +F VERSION 25e2e333adeff5965520bc8db999c658898c972d F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 @@ -30,7 +30,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 35ce04a15ca046262bf9baaa2ced9337708cc653 x +F configure 3f44893bc0e51c30653e02b0fd4dc2ab585e446a x F configure.ac b5d3df43161374f8dffd2e5f4b88fbb51685b975 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b07a26df06a2ffb946ff8a1cc7f43eaf701a94b5 -R f8409033fe00bbe724670b3d36a1f97d +P 83622f3f50030e4d6abafb99d99742928aaf157c +R d9d741532efbea2110f3ccf4d8076cf7 U drh -Z c9080bc44cd5d5b39b4e8d736cb94a4a +Z 14b0337226a0ad8779ef18ae936fbfbf diff --git a/manifest.uuid b/manifest.uuid index d2f3f5ca4a..14b26b5a65 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -83622f3f50030e4d6abafb99d99742928aaf157c \ No newline at end of file +8c2701e70ab2553d7a586ff5fe7afa02d8c63199 \ No newline at end of file From 167fbbe195c67fbc2b26bd75fc7c167820ff11c4 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 14:40:00 +0000 Subject: [PATCH 08/14] Rearrange the code inside sqlite3RunParser() routine so that sqlite3Parser() is only called from a single place. This allows sqlite3Parser() to be in-lined, which results in a 0.25% overall performance gain. FossilOrigin-Name: 25d1d02b3ea126ade22b2a72649ae55509aa1777 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/tokenize.c | 35 +++++++++++++++++++---------------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 3a6e935e56..65d4efd170 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Increment\sthe\sversion\snumber\sto\s3.15. -D 2016-08-10T13:34:16.502 +C Rearrange\sthe\scode\sinside\ssqlite3RunParser()\sroutine\sso\sthat\ssqlite3Parser()\nis\sonly\scalled\sfrom\sa\ssingle\splace.\s\sThis\sallows\ssqlite3Parser()\sto\sbe\nin-lined,\swhich\sresults\sin\sa\s0.25%\soverall\sperformance\sgain. +D 2016-08-10T14:40:00.773 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -443,7 +443,7 @@ F src/test_windirent.c 8f5fada630348558d5745b334702f301da1ffc61 F src/test_windirent.h b12055cab6227f7be10f5c19296f67c60cc5e2a5 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c 3b29883b0ce4a6c6f643965b66b5ca6613178e59 +F src/tokenize.c 78c8085bc7af1922aa687f0f4bbd716821330de5 F src/treeview.c c56d6ddbed564efda746236b35bcbb8238daac4b F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 83622f3f50030e4d6abafb99d99742928aaf157c -R d9d741532efbea2110f3ccf4d8076cf7 +P 8c2701e70ab2553d7a586ff5fe7afa02d8c63199 +R d55f09ced5a54b7cb7985c5709f82b8d U drh -Z 14b0337226a0ad8779ef18ae936fbfbf +Z f780132273cb4e2f41bbf55d6f67764f diff --git a/manifest.uuid b/manifest.uuid index 14b26b5a65..806e1635fa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c2701e70ab2553d7a586ff5fe7afa02d8c63199 \ No newline at end of file +25d1d02b3ea126ade22b2a72649ae55509aa1777 \ No newline at end of file diff --git a/src/tokenize.c b/src/tokenize.c index 62e770b79c..9230da2a0f 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -502,14 +502,26 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ assert( pParse->nVar==0 ); assert( pParse->nzVar==0 ); assert( pParse->azVar==0 ); - while( zSql[i]!=0 ){ + while( 1 ){ assert( i>=0 ); - pParse->sLastToken.z = &zSql[i]; - pParse->sLastToken.n = sqlite3GetToken((unsigned char*)&zSql[i],&tokenType); - i += pParse->sLastToken.n; - if( i>mxSqlLen ){ - pParse->rc = SQLITE_TOOBIG; - break; + if( zSql[i]!=0 ){ + pParse->sLastToken.z = &zSql[i]; + pParse->sLastToken.n = sqlite3GetToken((u8*)&zSql[i],&tokenType); + i += pParse->sLastToken.n; + if( i>mxSqlLen ){ + pParse->rc = SQLITE_TOOBIG; + break; + } + }else{ + /* Upon reaching the end of input, call the parser two more times + ** with tokens TK_SEMI and 0, in that order. */ + if( lastTokenParsed==TK_SEMI ){ + tokenType = 0; + }else if( lastTokenParsed==0 ){ + break; + }else{ + tokenType = TK_SEMI; + } } if( tokenType>=TK_SPACE ){ assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL ); @@ -530,15 +542,6 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ } assert( nErr==0 ); pParse->zTail = &zSql[i]; - if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){ - assert( zSql[i]==0 ); - if( lastTokenParsed!=TK_SEMI ){ - sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse); - } - if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){ - sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse); - } - } #ifdef YYTRACKMAXSTACKDEPTH sqlite3_mutex_enter(sqlite3MallocMutex()); sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK, From f5dbe7f8d8486f79f0ee1be6ff16176d14156ac4 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 15:02:49 +0000 Subject: [PATCH 09/14] Tweaks to pcache1TruncateUnsafe() to make it slightly smaller and faster and easier to test. FossilOrigin-Name: 059f4e2efefb7b9deaf539110c19bceaeb10c6ce --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pcache1.c | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 65d4efd170..40aa0f764a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rearrange\sthe\scode\sinside\ssqlite3RunParser()\sroutine\sso\sthat\ssqlite3Parser()\nis\sonly\scalled\sfrom\sa\ssingle\splace.\s\sThis\sallows\ssqlite3Parser()\sto\sbe\nin-lined,\swhich\sresults\sin\sa\s0.25%\soverall\sperformance\sgain. -D 2016-08-10T14:40:00.773 +C Tweaks\sto\spcache1TruncateUnsafe()\sto\smake\sit\sslightly\ssmaller\sand\sfaster\sand\neasier\sto\stest. +D 2016-08-10T15:02:49.189 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -376,7 +376,7 @@ F src/pager.h 966d2769e76ae347c8a32c4165faf6e6cb64546d F src/parse.y 99b676e6fc2f4e331ab93e76b3987cffdbd28efa F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 -F src/pcache1.c dc8a6052e5136d6b5e6afe51f37485145646f5ab +F src/pcache1.c 4bb7a6a5300c67d0b033d25adb509c120c03e812 F src/pragma.c c8b499756658cb8b82cfdbb5845c22cf11f297aa F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8c2701e70ab2553d7a586ff5fe7afa02d8c63199 -R d55f09ced5a54b7cb7985c5709f82b8d +P 25d1d02b3ea126ade22b2a72649ae55509aa1777 +R 828a3811914080064b74ae479ed3b60e U drh -Z f780132273cb4e2f41bbf55d6f67764f +Z 4a1a54abd34521e8d97a121a8de840a3 diff --git a/manifest.uuid b/manifest.uuid index 806e1635fa..3afecdeb57 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -25d1d02b3ea126ade22b2a72649ae55509aa1777 \ No newline at end of file +059f4e2efefb7b9deaf539110c19bceaeb10c6ce \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 1af1ef5bb7..1b1971a399 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -637,19 +637,19 @@ static void pcache1TruncateUnsafe( assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); assert( pCache->iMaxKey >= iLimit ); assert( pCache->nHash > 0 ); - if( pCache->iMaxKey - iLimit < pCache->nHash/2 ){ + if( pCache->iMaxKey - iLimit < pCache->nHash ){ /* If we are just shaving the last few pages off the end of the ** cache, then there is no point in scanning the entire hash table. ** Only scan those hash slots that might contain pages that need to ** be removed. */ - iStop = iLimit % pCache->nHash; - h = pCache->iMaxKey % pCache->nHash; + h = iLimit % pCache->nHash; + iStop = pCache->iMaxKey % pCache->nHash; TESTONLY( nPage = -10; ) /* Disable the pCache->nPage validity check */ }else{ /* This is the general case where many pages are being removed. ** It is necessary to scan the entire hash table */ - iStop = 0; - h = pCache->nHash - 1; + h = pCache->nHash/2; + iStop = h - 1; } for(;;){ PgHdr1 **pp; @@ -668,7 +668,7 @@ static void pcache1TruncateUnsafe( } } if( h==iStop ) break; - h = h ? h-1 : pCache->nHash - 1; + h = (h+1) % pCache->nHash; } assert( nPage<0 || pCache->nPage==(unsigned)nPage ); } From 922802c44e912e9d854408afa9f7e48f8ff1208a Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 18:56:32 +0000 Subject: [PATCH 10/14] Performance enhancement in the expression walker. FossilOrigin-Name: ebccbd96094ac64de39dbd0d220d3a7afd8cd40e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/walker.c | 18 ++++++++---------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 40aa0f764a..5d7ed0ac68 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Tweaks\sto\spcache1TruncateUnsafe()\sto\smake\sit\sslightly\ssmaller\sand\sfaster\sand\neasier\sto\stest. -D 2016-08-10T15:02:49.189 +C Performance\senhancement\sin\sthe\sexpression\swalker. +D 2016-08-10T18:56:32.070 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -463,7 +463,7 @@ F src/vtab.c 6b3cfaff7e4397739d6b48511e777ca58c6d06d4 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 -F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 +F src/walker.c 2d2cc7fb0f320f7f415215d7247f3c584141ac09 F src/where.c 5c9df42d50888be8274a5a0eb062eb0629869bd3 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 25d1d02b3ea126ade22b2a72649ae55509aa1777 -R 828a3811914080064b74ae479ed3b60e +P 059f4e2efefb7b9deaf539110c19bceaeb10c6ce +R e10ecf5680d55c2be7b6807b82221bef U drh -Z 4a1a54abd34521e8d97a121a8de840a3 +Z 07228f4a19a0e884d96dc70fff71df0f diff --git a/manifest.uuid b/manifest.uuid index 3afecdeb57..821d79b57b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -059f4e2efefb7b9deaf539110c19bceaeb10c6ce \ No newline at end of file +ebccbd96094ac64de39dbd0d220d3a7afd8cd40e \ No newline at end of file diff --git a/src/walker.c b/src/walker.c index 1e0ad32871..82aae67a61 100644 --- a/src/walker.c +++ b/src/walker.c @@ -41,17 +41,15 @@ static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){ testcase( ExprHasProperty(pExpr, EP_TokenOnly) ); testcase( ExprHasProperty(pExpr, EP_Reduced) ); rc = pWalker->xExprCallback(pWalker, pExpr); - if( rc==WRC_Continue - && !ExprHasProperty(pExpr,EP_TokenOnly) ){ - if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; - if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort; - if( ExprHasProperty(pExpr, EP_xIsSelect) ){ - if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort; - }else{ - if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort; - } + if( rc || ExprHasProperty(pExpr,EP_TokenOnly) ) return rc & WRC_Abort; + if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; + if( pExpr->pRight && walkExpr(pWalker, pExpr->pRight) ) return WRC_Abort; + if( ExprHasProperty(pExpr, EP_xIsSelect) ){ + if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort; + }else{ + if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort; } - return rc & WRC_Abort; + return WRC_Continue; } int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){ return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue; From e104dd3cc301c0fe79e59502b13a953f6369c6dc Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 19:43:29 +0000 Subject: [PATCH 11/14] List of MATCH operator names in isMatchOfColumn() should be constant. FossilOrigin-Name: 7319d676aaf95ba7391379f4cdf193b6aa898893 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/whereexpr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5d7ed0ac68..d87a893d49 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\senhancement\sin\sthe\sexpression\swalker. -D 2016-08-10T18:56:32.070 +C List\sof\sMATCH\soperator\snames\sin\sisMatchOfColumn()\sshould\sbe\sconstant. +D 2016-08-10T19:43:29.424 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -467,7 +467,7 @@ F src/walker.c 2d2cc7fb0f320f7f415215d7247f3c584141ac09 F src/where.c 5c9df42d50888be8274a5a0eb062eb0629869bd3 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 -F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563 +F src/whereexpr.c 600e6c619d69f5455dd99c69fec8c42ac44e5c9d F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 059f4e2efefb7b9deaf539110c19bceaeb10c6ce -R e10ecf5680d55c2be7b6807b82221bef +P ebccbd96094ac64de39dbd0d220d3a7afd8cd40e +R fac33bc7c9b64529fad9a6567bc0fbba U drh -Z 07228f4a19a0e884d96dc70fff71df0f +Z d9cf90e53680d487c9bbc0ab8247d4aa diff --git a/manifest.uuid b/manifest.uuid index 821d79b57b..1286c1b8bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ebccbd96094ac64de39dbd0d220d3a7afd8cd40e \ No newline at end of file +7319d676aaf95ba7391379f4cdf193b6aa898893 \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index 1cb6be8458..2461d1ddf8 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -290,7 +290,7 @@ static int isMatchOfColumn( Expr *pExpr, /* Test this expression */ unsigned char *peOp2 /* OUT: 0 for MATCH, or else an op2 value */ ){ - struct Op2 { + static const struct Op2 { const char *zOp; unsigned char eOp2; } aOp[] = { From 93ca3933d17bca3cd5dbad1731d722c6d0108bf0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 20:02:21 +0000 Subject: [PATCH 12/14] Optimization to sqlite3WhereExprUsage(). FossilOrigin-Name: 95493058fcf40306727a281f21c5a2a0011b7d02 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/whereexpr.c | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d87a893d49..842f885dfd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C List\sof\sMATCH\soperator\snames\sin\sisMatchOfColumn()\sshould\sbe\sconstant. -D 2016-08-10T19:43:29.424 +C Optimization\sto\ssqlite3WhereExprUsage(). +D 2016-08-10T20:02:21.519 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -467,7 +467,7 @@ F src/walker.c 2d2cc7fb0f320f7f415215d7247f3c584141ac09 F src/where.c 5c9df42d50888be8274a5a0eb062eb0629869bd3 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 -F src/whereexpr.c 600e6c619d69f5455dd99c69fec8c42ac44e5c9d +F src/whereexpr.c 98ce9f3b8d92b6f741b9f3498f9619695739256e F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ebccbd96094ac64de39dbd0d220d3a7afd8cd40e -R fac33bc7c9b64529fad9a6567bc0fbba +P 7319d676aaf95ba7391379f4cdf193b6aa898893 +R 35b146f4e31088e5d413861ddde93f74 U drh -Z d9cf90e53680d487c9bbc0ab8247d4aa +Z 2c745f38c120984510a4f6c92123cc21 diff --git a/manifest.uuid b/manifest.uuid index 1286c1b8bf..99c25a4923 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7319d676aaf95ba7391379f4cdf193b6aa898893 \ No newline at end of file +95493058fcf40306727a281f21c5a2a0011b7d02 \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index 2461d1ddf8..2768428e2d 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -1275,13 +1275,14 @@ void sqlite3WhereClauseClear(WhereClause *pWC){ ** tree. */ Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){ - Bitmask mask = 0; + Bitmask mask; if( p==0 ) return 0; if( p->op==TK_COLUMN ){ mask = sqlite3WhereGetMask(pMaskSet, p->iTable); return mask; } - mask = sqlite3WhereExprUsage(pMaskSet, p->pRight); + assert( !ExprHasProperty(p, EP_TokenOnly) ); + mask = p->pRight ? sqlite3WhereExprUsage(pMaskSet, p->pRight) : 0; if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft); if( ExprHasProperty(p, EP_xIsSelect) ){ mask |= exprSelectUsage(pMaskSet, p->x.pSelect); From c73bd0a5ccba807c7f18673063326f9929702473 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 11 Aug 2016 01:24:56 +0000 Subject: [PATCH 13/14] Fix a harmless compiler warning in FTS5. FossilOrigin-Name: 2ea0c8b46eefd4874f021f8dfd344be751f2034f --- ext/fts5/fts5_index.c | 1 + manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 52fdc634a5..65b92a2b99 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -3200,6 +3200,7 @@ static void fts5IterSetOutputs_Nocolset(Fts5Iter *pIter, Fts5SegIter *pSeg){ ** against no columns at all). */ static void fts5IterSetOutputs_ZeroColset(Fts5Iter *pIter, Fts5SegIter *pSeg){ + UNUSED_PARAM(pSeg); pIter->base.nData = 0; } diff --git a/manifest b/manifest index 842f885dfd..4c405c8749 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Optimization\sto\ssqlite3WhereExprUsage(). -D 2016-08-10T20:02:21.519 +C Fix\sa\sharmless\scompiler\swarning\sin\sFTS5. +D 2016-08-11T01:24:56.314 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -104,7 +104,7 @@ F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 F ext/fts5/fts5_expr.c df0004b5bffcbe34c329f2992669c6352443f415 F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 -F ext/fts5/fts5_index.c e25ac419fc66f412e6044595b20b4bf8f7cea284 +F ext/fts5/fts5_index.c 05386732609221d066d204b22c4a5275a0225ed4 F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 F ext/fts5/fts5_storage.c de0ed8a06738bde433afe11e92295ceaffbc4e58 F ext/fts5/fts5_tcl.c 4a901f00c8553740dba63511603f5527d741c26a @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7319d676aaf95ba7391379f4cdf193b6aa898893 -R 35b146f4e31088e5d413861ddde93f74 +P 95493058fcf40306727a281f21c5a2a0011b7d02 +R 62963055338ff8dad6eebc29c29c9140 U drh -Z 2c745f38c120984510a4f6c92123cc21 +Z e11e1549fddd90a07d1f00ccb39e8b50 diff --git a/manifest.uuid b/manifest.uuid index 99c25a4923..88d3f117ad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -95493058fcf40306727a281f21c5a2a0011b7d02 \ No newline at end of file +2ea0c8b46eefd4874f021f8dfd344be751f2034f \ No newline at end of file From 6ff4627d5ddbaa2fc96945f2a1e042313de1097a Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 11 Aug 2016 09:55:55 +0000 Subject: [PATCH 14/14] Fix a 1 byte buffer overwrite in the "sqldiff --rbu" command. FossilOrigin-Name: ab83d7077da80ddbcf399d0797d79e964dc64f0e --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/sqldiff.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4c405c8749..7c618d61d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\scompiler\swarning\sin\sFTS5. -D 2016-08-11T01:24:56.314 +C Fix\sa\s1\sbyte\sbuffer\soverwrite\sin\sthe\s"sqldiff\s--rbu"\scommand. +D 2016-08-11T09:55:55.485 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1477,7 +1477,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/sqldiff.c 4478f0d30230de6adde90bdb0bfe60f68c5ab782 +F tool/sqldiff.c c965d49bf2677db06103854b47e105484b5b1b84 F tool/srcck1.c 371de5363b70154012955544f86fdee8f6e5326f F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 95493058fcf40306727a281f21c5a2a0011b7d02 -R 62963055338ff8dad6eebc29c29c9140 -U drh -Z e11e1549fddd90a07d1f00ccb39e8b50 +P 2ea0c8b46eefd4874f021f8dfd344be751f2034f +R 26e854b22e510a9651c111418b0d5f03 +U dan +Z 78ea492cf13c3fac64589b27f22aa44b diff --git a/manifest.uuid b/manifest.uuid index 88d3f117ad..22f2d26d97 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2ea0c8b46eefd4874f021f8dfd344be751f2034f \ No newline at end of file +ab83d7077da80ddbcf399d0797d79e964dc64f0e \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index e92e8aab25..b1363bb341 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -1302,7 +1302,7 @@ static void rbudiff_one_table(const char *zTab, FILE *out){ char *zOtaControl; int nOtaControl = sqlite3_column_bytes(pStmt, nCol); - zOtaControl = (char*)sqlite3_malloc(nOtaControl); + zOtaControl = (char*)sqlite3_malloc(nOtaControl+1); memcpy(zOtaControl, sqlite3_column_text(pStmt, nCol), nOtaControl+1); for(i=0; i