mirror of
https://github.com/sqlite/sqlite.git
synced 2026-01-06 08:01:16 +03:00
Minor update to the way fts5 column filters are parsed.
FossilOrigin-Name: 14864f2b8470fe98dbd17f59963bf1be8d4962f9
This commit is contained in:
@@ -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*);
|
||||
|
||||
|
||||
@@ -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; i<nCol; i++){
|
||||
pRet->aiCol[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0; i<pRet->nCol; 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,
|
||||
|
||||
@@ -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($$); }
|
||||
|
||||
@@ -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}
|
||||
|
||||
18
manifest
18
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
|
||||
|
||||
@@ -1 +1 @@
|
||||
e517545650631d1e8a7ee63c6646a8b183a0a894
|
||||
14864f2b8470fe98dbd17f59963bf1be8d4962f9
|
||||
Reference in New Issue
Block a user