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

Unified Diff: third_party/sqlite/patches/0020-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: Fixed typo in readme. 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/0020-fts2-Interpret-foo-as-a-prefix-search.patch
diff --git a/third_party/sqlite/patches/0020-fts2-Interpret-foo-as-a-prefix-search.patch b/third_party/sqlite/patches/0020-fts2-Interpret-foo-as-a-prefix-search.patch
new file mode 100644
index 0000000000000000000000000000000000000000..f613655143ea75e6e8ba5286b8e61066cb8f03b0
--- /dev/null
+++ b/third_party/sqlite/patches/0020-fts2-Interpret-foo-as-a-prefix-search.patch
@@ -0,0 +1,48 @@
+From 07efd3db8276f343fa9762a11ca3114ba8ffe532 Mon Sep 17 00:00:00 2001
+From: Matt Perry <mpcomplete@google.com>
+Date: Wed, 17 Dec 2008 00:50:50 +0000
+Subject: [PATCH 20/23] [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