Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: third_party/sqlite/patches/0021-fts2-Interpret-foo-as-a-prefix-search.patch

Issue 885473002: [sql] Rewrite sqlite patching "system". (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/sqlite/patches/0021-fts2-Interpret-foo-as-a-prefix-search.patch
diff --git a/third_party/sqlite/patches/0021-fts2-Interpret-foo-as-a-prefix-search.patch b/third_party/sqlite/patches/0021-fts2-Interpret-foo-as-a-prefix-search.patch
new file mode 100644
index 0000000000000000000000000000000000000000..4e5ebe8acbc000cfe463b816327013a53cb09cd5
--- /dev/null
+++ b/third_party/sqlite/patches/0021-fts2-Interpret-foo-as-a-prefix-search.patch
@@ -0,0 +1,48 @@
+From d45f3084c66d5cf96fd972b880109dac9ae927fc Mon Sep 17 00:00:00 2001
+From: Scott Hess <shess@chromium.org>
+Date: Fri, 19 Dec 2014 11:29:49 -0800
+Subject: [PATCH 21/24] [fts2] Interpret "foo*" as a prefix search.
+
+By default it interpreted it as "foo *" (two tokens).
+
+Original review URL: http://codereview.chromium.org/14176
+---
+ third_party/sqlite/src/ext/fts2/fts2.c | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/third_party/sqlite/src/ext/fts2/fts2.c b/third_party/sqlite/src/ext/fts2/fts2.c
+index 4945cd9..7d07137 100644
+--- a/third_party/sqlite/src/ext/fts2/fts2.c
++++ b/third_party/sqlite/src/ext/fts2/fts2.c
+@@ -3558,6 +3558,7 @@ static int tokenizeSegment(
+ int firstIndex = pQuery->nTerms;
+ int iCol;
+ int nTerm = 1;
++ int iEndLast = -1;
+
+ int rc = pModule->xOpen(pTokenizer, pSegment, nSegment, &pCursor);
+ if( rc!=SQLITE_OK ) return rc;
+@@ -3582,6 +3583,20 @@ static int tokenizeSegment(
+ pQuery->nextIsOr = 1;
+ continue;
+ }
++
++ /*
++ * The ICU tokenizer considers '*' a break character, so the code below
++ * sets isPrefix correctly, but since that code doesn't eat the '*', the
++ * ICU tokenizer returns it as the next token. So eat it here until a
++ * better solution presents itself.
++ */
++ if( pQuery->nTerms>0 && nToken==1 && pSegment[iBegin]=='*' &&
++ iEndLast==iBegin){
++ pQuery->pTerms[pQuery->nTerms-1].isPrefix = 1;
++ continue;
++ }
++ iEndLast = iEnd;
++
+ queryAdd(pQuery, pToken, nToken);
+ if( !inPhrase && iBegin>0 && pSegment[iBegin-1]=='-' ){
+ pQuery->pTerms[pQuery->nTerms-1].isNot = 1;
+--
+2.2.1
+

Powered by Google App Engine
This is Rietveld 408576698