Do not display matches against
the right-hand side of a NOT operator in the output of the FTS snippet() or offsets() functions. (CVS 6097) FossilOrigin-Name: d44c84c0f77bd0fc4a9942177b6cae6d109b89b7
This commit is contained in:
parent
c81806f3ed
commit
be90df0b3e
@ -3136,8 +3136,13 @@ static void snippetAppendMatch(
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** Function to iterate through the tokens of a compiled expression.
|
** Function to iterate through the tokens of a compiled expression.
|
||||||
|
**
|
||||||
|
** Except, skip all tokens on the right-hand side of a NOT operator.
|
||||||
|
** This function is used to find tokens as part of snippet and offset
|
||||||
|
** generation and we do nt want snippets and offsets to report matches
|
||||||
|
** for tokens on the RHS of a NOT.
|
||||||
*/
|
*/
|
||||||
static int nextExprToken(Fts3Expr **ppExpr, int *piToken){
|
static int fts3NextExprToken(Fts3Expr **ppExpr, int *piToken){
|
||||||
Fts3Expr *p = *ppExpr;
|
Fts3Expr *p = *ppExpr;
|
||||||
int iToken = *piToken;
|
int iToken = *piToken;
|
||||||
if( iToken<0 ){
|
if( iToken<0 ){
|
||||||
@ -3160,6 +3165,7 @@ static int nextExprToken(Fts3Expr **ppExpr, int *piToken){
|
|||||||
}
|
}
|
||||||
p = p->pParent;
|
p = p->pParent;
|
||||||
if( p ){
|
if( p ){
|
||||||
|
assert( p->pRight!=0 );
|
||||||
p = p->pRight;
|
p = p->pRight;
|
||||||
while( p->pLeft ){
|
while( p->pLeft ){
|
||||||
p = p->pLeft;
|
p = p->pLeft;
|
||||||
@ -3173,16 +3179,32 @@ static int nextExprToken(Fts3Expr **ppExpr, int *piToken){
|
|||||||
return p?1:0;
|
return p?1:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Return TRUE if the expression node pExpr is located beneath the
|
||||||
|
** RHS of a NOT operator.
|
||||||
|
*/
|
||||||
|
static int fts3ExprBeneathNot(Fts3Expr *p){
|
||||||
|
Fts3Expr *pParent;
|
||||||
|
while( p ){
|
||||||
|
pParent = p->pParent;
|
||||||
|
if( pParent && pParent->eType==FTSQUERY_NOT && pParent->pRight==p ){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
p = pParent;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Add entries to pSnippet->aMatch[] for every match that occurs against
|
** Add entries to pSnippet->aMatch[] for every match that occurs against
|
||||||
** document zDoc[0..nDoc-1] which is stored in column iColumn.
|
** document zDoc[0..nDoc-1] which is stored in column iColumn.
|
||||||
*/
|
*/
|
||||||
static void snippetOffsetsOfColumn(
|
static void snippetOffsetsOfColumn(
|
||||||
fulltext_cursor *pCur,
|
fulltext_cursor *pCur, /* The fulltest search cursor */
|
||||||
Snippet *pSnippet,
|
Snippet *pSnippet, /* The Snippet object to be filled in */
|
||||||
int iColumn,
|
int iColumn, /* Index of fulltext table column */
|
||||||
const char *zDoc,
|
const char *zDoc, /* Text of the fulltext table column */
|
||||||
int nDoc
|
int nDoc /* Length of zDoc in bytes */
|
||||||
){
|
){
|
||||||
const sqlite3_tokenizer_module *pTModule; /* The tokenizer module */
|
const sqlite3_tokenizer_module *pTModule; /* The tokenizer module */
|
||||||
sqlite3_tokenizer *pTokenizer; /* The specific tokenizer */
|
sqlite3_tokenizer *pTokenizer; /* The specific tokenizer */
|
||||||
@ -3217,10 +3239,15 @@ static void snippetOffsetsOfColumn(
|
|||||||
iRotorBegin[iRotor&FTS3_ROTOR_MASK] = iBegin;
|
iRotorBegin[iRotor&FTS3_ROTOR_MASK] = iBegin;
|
||||||
iRotorLen[iRotor&FTS3_ROTOR_MASK] = iEnd-iBegin;
|
iRotorLen[iRotor&FTS3_ROTOR_MASK] = iEnd-iBegin;
|
||||||
match = 0;
|
match = 0;
|
||||||
for(i=0; i<(FTS3_ROTOR_SZ-1) && nextExprToken(&pIter, &iIter); i++){
|
for(i=0; i<(FTS3_ROTOR_SZ-1) && fts3NextExprToken(&pIter, &iIter); i++){
|
||||||
int nPhrase = pIter->pPhrase->nToken; /* Tokens in current phrase */
|
int nPhrase; /* Number of tokens in current phrase */
|
||||||
struct PhraseToken *pToken = &pIter->pPhrase->aToken[iIter];
|
struct PhraseToken *pToken; /* Current token */
|
||||||
int iCol = pIter->pPhrase->iColumn;
|
int iCol; /* Column index */
|
||||||
|
|
||||||
|
if( fts3ExprBeneathNot(pIter) ) continue;
|
||||||
|
nPhrase = pIter->pPhrase->nToken;
|
||||||
|
pToken = &pIter->pPhrase->aToken[iIter];
|
||||||
|
iCol = pIter->pPhrase->iColumn;
|
||||||
if( iCol>=0 && iCol<nColumn && iCol!=iColumn ) continue;
|
if( iCol>=0 && iCol<nColumn && iCol!=iColumn ) continue;
|
||||||
if( pToken->n>nToken ) continue;
|
if( pToken->n>nToken ) continue;
|
||||||
if( !pToken->isPrefix && pToken->n<nToken ) continue;
|
if( !pToken->isPrefix && pToken->n<nToken ) continue;
|
||||||
@ -3264,11 +3291,13 @@ static void snippetOffsetsOfColumn(
|
|||||||
** the integer id of the left-most token in the expression tree headed by
|
** the integer id of the left-most token in the expression tree headed by
|
||||||
** pExpr. This function increments *piLeft by the total number of tokens
|
** pExpr. This function increments *piLeft by the total number of tokens
|
||||||
** in the expression tree headed by pExpr.
|
** in the expression tree headed by pExpr.
|
||||||
|
**
|
||||||
|
** Return 1 if any trimming occurs. Return 0 if no trimming is required.
|
||||||
*/
|
*/
|
||||||
static int trimSnippetOffsets(
|
static int trimSnippetOffsets(
|
||||||
Fts3Expr *pExpr,
|
Fts3Expr *pExpr, /* The search expression */
|
||||||
Snippet *pSnippet,
|
Snippet *pSnippet, /* The set of snippet offsets to be trimmed */
|
||||||
int *piLeft
|
int *piLeft /* Index of left-most token in pExpr */
|
||||||
){
|
){
|
||||||
if( pExpr ){
|
if( pExpr ){
|
||||||
if( trimSnippetOffsets(pExpr->pLeft, pSnippet, piLeft) ){
|
if( trimSnippetOffsets(pExpr->pLeft, pSnippet, piLeft) ){
|
||||||
@ -3385,9 +3414,11 @@ static void snippetAllOffsets(fulltext_cursor *p){
|
|||||||
nColumn = pFts->nColumn;
|
nColumn = pFts->nColumn;
|
||||||
iColumn = (p->iCursorType - QUERY_FULLTEXT);
|
iColumn = (p->iCursorType - QUERY_FULLTEXT);
|
||||||
if( iColumn<0 || iColumn>=nColumn ){
|
if( iColumn<0 || iColumn>=nColumn ){
|
||||||
|
/* Look for matches over all columns of the full-text index */
|
||||||
iFirst = 0;
|
iFirst = 0;
|
||||||
iLast = nColumn-1;
|
iLast = nColumn-1;
|
||||||
}else{
|
}else{
|
||||||
|
/* Look for matches in the iColumn-th column of the index only */
|
||||||
iFirst = iColumn;
|
iFirst = iColumn;
|
||||||
iLast = iColumn;
|
iLast = iColumn;
|
||||||
}
|
}
|
||||||
|
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
|||||||
C Fix\sa\s(benign)\svalgrind\serror\sthat\scan\soccur\sfollowing\smalloc\sfailure\swhile\sexecuting\sa\s'ROLLBACK\sTO\ssavepoint'\scommand.\s(CVS\s6096)
|
C Do\snot\sdisplay\smatches\sagainst\r\nthe\sright-hand\sside\sof\sa\sNOT\soperator\sin\sthe\soutput\r\nof\sthe\sFTS\ssnippet()\sor\soffsets()\sfunctions.\s(CVS\s6097)
|
||||||
D 2009-01-01T15:20:37
|
D 2009-01-02T01:10:42
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in 77635d0909c2067cee03889a1e04ce910d8fb809
|
F Makefile.in 77635d0909c2067cee03889a1e04ce910d8fb809
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@ -53,7 +53,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0
|
|||||||
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
|
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
|
||||||
F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9
|
F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9
|
||||||
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
|
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
|
||||||
F ext/fts3/fts3.c 3aa6aef1eadc44606f6ed3c841062735a5210077
|
F ext/fts3/fts3.c 4e0d3b1b8ad133e0cd641e9eaa56015ad0466cd6
|
||||||
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
|
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
|
||||||
F ext/fts3/fts3_expr.c 98fe92f6888c306734ed9332a24383dde77c25aa
|
F ext/fts3/fts3_expr.c 98fe92f6888c306734ed9332a24383dde77c25aa
|
||||||
F ext/fts3/fts3_expr.h b5412dcf565c6d90d6a8c22090ceb9ed8c745634
|
F ext/fts3/fts3_expr.h b5412dcf565c6d90d6a8c22090ceb9ed8c745634
|
||||||
@ -690,7 +690,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
|||||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
P ccfe4580ac7ba9add0e69c786a9a3a43d69b7753
|
P 9ff8598f3be123a244f71b45e77af913b836504a
|
||||||
R 55e5da6452ac7bf13b968c8f36ed538b
|
R 2cdfa5be7870dcec4ac66bcd1ad84dbe
|
||||||
U danielk1977
|
U drh
|
||||||
Z fe12888ee4a3f9d606558994dc2f8d82
|
Z a59547509372bc8abd2b95e6b7d6a629
|
||||||
|
@ -1 +1 @@
|
|||||||
9ff8598f3be123a244f71b45e77af913b836504a
|
d44c84c0f77bd0fc4a9942177b6cae6d109b89b7
|
Loading…
Reference in New Issue
Block a user