mirror of
https://github.com/sqlite/sqlite.git
synced 2026-01-06 08:01:16 +03:00
Have FTS3 ignore ^ prefixes. The ^ syntax is only supported on FTS4 tables.
FossilOrigin-Name: df36ac948179f37b432a88701b6c79299e073ce8
This commit is contained in:
@@ -2894,8 +2894,8 @@ static int fts3FilterMethod(
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
|
||||
rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->nColumn,
|
||||
iCol, zQuery, -1, &pCsr->pExpr
|
||||
rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->bHasStat,
|
||||
p->nColumn, iCol, zQuery, -1, &pCsr->pExpr
|
||||
);
|
||||
if( rc!=SQLITE_OK ){
|
||||
if( rc==SQLITE_ERROR ){
|
||||
|
||||
@@ -489,7 +489,7 @@ void sqlite3Fts3Matchinfo(sqlite3_context *, Fts3Cursor *, const char *);
|
||||
|
||||
/* fts3_expr.c */
|
||||
int sqlite3Fts3ExprParse(sqlite3_tokenizer *,
|
||||
char **, int, int, const char *, int, Fts3Expr **
|
||||
char **, int, int, int, const char *, int, Fts3Expr **
|
||||
);
|
||||
void sqlite3Fts3ExprFree(Fts3Expr *);
|
||||
#ifdef SQLITE_TEST
|
||||
|
||||
@@ -93,6 +93,7 @@ typedef struct ParseContext ParseContext;
|
||||
struct ParseContext {
|
||||
sqlite3_tokenizer *pTokenizer; /* Tokenizer module */
|
||||
const char **azCol; /* Array of column names for fts3 table */
|
||||
int bFts4; /* True to allow FTS4-only syntax */
|
||||
int nCol; /* Number of entries in azCol[] */
|
||||
int iDefaultCol; /* Default column to query */
|
||||
int isNot; /* True if getNextNode() sees a unary - */
|
||||
@@ -187,7 +188,7 @@ static int getNextToken(
|
||||
){
|
||||
pParse->isNot = 1;
|
||||
iStart--;
|
||||
}else if( iStart>0 && z[iStart-1]=='^' ){
|
||||
}else if( pParse->bFts4 && iStart>0 && z[iStart-1]=='^' ){
|
||||
pRet->pPhrase->aToken[0].bFirst = 1;
|
||||
iStart--;
|
||||
}else{
|
||||
@@ -741,6 +742,7 @@ exprparse_out:
|
||||
int sqlite3Fts3ExprParse(
|
||||
sqlite3_tokenizer *pTokenizer, /* Tokenizer module */
|
||||
char **azCol, /* Array of column names for fts3 table */
|
||||
int bFts4, /* True to allow FTS4-only syntax */
|
||||
int nCol, /* Number of entries in azCol[] */
|
||||
int iDefaultCol, /* Default column to query */
|
||||
const char *z, int n, /* Text of MATCH query */
|
||||
@@ -754,6 +756,7 @@ int sqlite3Fts3ExprParse(
|
||||
sParse.nCol = nCol;
|
||||
sParse.iDefaultCol = iDefaultCol;
|
||||
sParse.nNest = 0;
|
||||
sParse.bFts4 = bFts4;
|
||||
if( z==0 ){
|
||||
*ppExpr = 0;
|
||||
return SQLITE_OK;
|
||||
@@ -943,7 +946,7 @@ static void fts3ExprTest(
|
||||
}
|
||||
|
||||
rc = sqlite3Fts3ExprParse(
|
||||
pTokenizer, azCol, nCol, nCol, zExpr, nExpr, &pExpr
|
||||
pTokenizer, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr
|
||||
);
|
||||
if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM ){
|
||||
sqlite3_result_error(context, "Error parsing expression", -1);
|
||||
|
||||
20
manifest
20
manifest
@@ -1,5 +1,5 @@
|
||||
C Change\sthe\sway\s^\stokens\swork\sin\sFTS\sso\sthat\sthe\sfiltering\sis\sdone\sas\spart\sof\sreading\sthe\sFTS\sindex\sinstead\sof\swaiting\suntil\san\sentire\sdoclist\shas\sbeen\sretrieved\sand\sthen\sfiltering\sit.
|
||||
D 2011-10-19T11:57:13.985
|
||||
C Have\sFTS3\signore\s^\sprefixes.\sThe\s^\ssyntax\sis\sonly\ssupported\son\sFTS4\stables.
|
||||
D 2011-10-19T15:52:48.921
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@@ -62,11 +62,11 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0
|
||||
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
|
||||
F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9
|
||||
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
|
||||
F ext/fts3/fts3.c 064b660a11ae29651b647fa7c3e9954d901ab58a
|
||||
F ext/fts3/fts3.c e8ee5c78a3c7715b597db4e5c890ec658ee0401a
|
||||
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
|
||||
F ext/fts3/fts3Int.h 7a0deb219371d29b8d385fb5e929ede2bdc7c239
|
||||
F ext/fts3/fts3Int.h 74afec80054924976b2d3a21eda17e33c6ff6b84
|
||||
F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691
|
||||
F ext/fts3/fts3_expr.c dd0facbede8fd7d1376670cc6154f1fef3a4c5bc
|
||||
F ext/fts3/fts3_expr.c 34dd0edf1e2723ce22d88039dc1ad687a95fb1bb
|
||||
F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914
|
||||
F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec
|
||||
F ext/fts3/fts3_icu.c 6c8f395cdf9e1e3afa7fadb7e523dbbf381c6dfa
|
||||
@@ -469,14 +469,14 @@ F test/fts3corrupt.test 7b0f91780ca36118d73324ec803187208ad33b32
|
||||
F test/fts3corrupt2.test 6d96efae2f8a6af3eeaf283aba437e6d0e5447ba
|
||||
F test/fts3cov.test e0fb00d8b715ddae4a94c305992dfc3ef70353d7
|
||||
F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52
|
||||
F test/fts3defer.test b7bdf79da91365b00e7c21d70e9d0c617b9306b9
|
||||
F test/fts3defer.test 2ea3fa028f8d9523f9c33dd8acc4555d567ea4ac
|
||||
F test/fts3defer2.test 35867d33ba6db03f6c73bd6f5fc333ae14f68c81
|
||||
F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851
|
||||
F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c
|
||||
F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a
|
||||
F test/fts3fault.test f83e556465bb69dc8bc676339eca408dce4ca246
|
||||
F test/fts3fault2.test b62a2bc843c20414405f80e5eeb78e39bc68fe53
|
||||
F test/fts3first.test 5aa9e82202461a82066427df4cea9188155a4cd5
|
||||
F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641
|
||||
F test/fts3malloc.test b86ea33db9e8c58c0c2f8027a9fcadaf6a1568be
|
||||
F test/fts3matchinfo.test 6507fe1c342e542300d65ea637d4110eccf894e6
|
||||
F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844
|
||||
@@ -967,7 +967,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5
|
||||
F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2
|
||||
P 92618c1463fb304cf8057d082b2c7096152dff27
|
||||
R c2d7bdd9838ac956262a194e0ae43b40
|
||||
P 9b58c59eb4efaa38ce50a3ce1b52f9ba578c71d6
|
||||
R b05473465da4d8af6fcb4e85b9ce8174
|
||||
U dan
|
||||
Z 8d1b6b02c37e3947f3ee71176bf9a674
|
||||
Z 1ed48059f0e9f692b253c99c9d63572e
|
||||
|
||||
@@ -1 +1 @@
|
||||
9b58c59eb4efaa38ce50a3ce1b52f9ba578c71d6
|
||||
df36ac948179f37b432a88701b6c79299e073ce8
|
||||
@@ -427,12 +427,17 @@ foreach {tn setup} {
|
||||
} {8 15 26 92 96}
|
||||
}
|
||||
|
||||
do_select_test 7.1 {
|
||||
SELECT rowid FROM t1 WHERE t1 MATCH '^zm mjpavjuhw'
|
||||
} {56 62}
|
||||
do_select_test 7.2 {
|
||||
SELECT rowid FROM t1 WHERE t1 MATCH '^azavwm zm'
|
||||
} {43}
|
||||
if {$tn>1} {
|
||||
# These tests will not work with $tn==1, as in this case table t1 is
|
||||
# created using FTS3. The ^ syntax is only available with FTS4 tables.
|
||||
#
|
||||
do_select_test 7.1 {
|
||||
SELECT rowid FROM t1 WHERE t1 MATCH '^zm mjpavjuhw'
|
||||
} {56 62}
|
||||
do_select_test 7.2 {
|
||||
SELECT rowid FROM t1 WHERE t1 MATCH '^azavwm zm'
|
||||
} {43}
|
||||
}
|
||||
}
|
||||
|
||||
set testprefix fts3defer
|
||||
|
||||
@@ -18,6 +18,8 @@ ifcapable !fts3 {
|
||||
return
|
||||
}
|
||||
|
||||
set testprefix fts3first
|
||||
|
||||
proc lreverse {L} {
|
||||
set res [list]
|
||||
for {set ii [expr [llength $L]-1]} {$ii>=0} {incr ii -1} {
|
||||
@@ -139,4 +141,23 @@ foreach {tn match res} {
|
||||
} $rev
|
||||
}
|
||||
|
||||
# Test that ^ is ignored for FTS3 tables.
|
||||
#
|
||||
do_execsql_test 2.1 {
|
||||
CREATE VIRTUAL TABLE x3 USING fts3;
|
||||
INSERT INTO x3 VALUES('A B C');
|
||||
INSERT INTO x3 VALUES('B A C');
|
||||
|
||||
CREATE VIRTUAL TABLE x4 USING fts4;
|
||||
INSERT INTO x4 VALUES('A B C');
|
||||
INSERT INTO x4 VALUES('B A C');
|
||||
}
|
||||
|
||||
do_execsql_test 2.2.1 {
|
||||
SELECT * FROM x3 WHERE x3 MATCH '^A';
|
||||
} {{A B C} {B A C}}
|
||||
do_execsql_test 2.2.2 {
|
||||
SELECT * FROM x4 WHERE x4 MATCH '^A';
|
||||
} {{A B C}}
|
||||
|
||||
finish_test
|
||||
|
||||
Reference in New Issue
Block a user