]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix handling of "WHERE col MATCH ? AND docid = ?" clauses in fts3.
authordan <dan@noemail.net>
Thu, 10 Dec 2009 18:29:04 +0000 (18:29 +0000)
committerdan <dan@noemail.net>
Thu, 10 Dec 2009 18:29:04 +0000 (18:29 +0000)
FossilOrigin-Name: 6cbbae849990d99b7ffe252b642d6be49d0c7235

ext/fts3/fts3.c
manifest
manifest.uuid
test/e_fts3.test

index 9de30dff35f25c81d762ffcba55c9e75fe192fd4..2649c4101ebc9a3c1c6d0390e4dcd2a84eb27fe6 100644 (file)
@@ -803,31 +803,31 @@ static int fts3BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
     struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i];
     if( pCons->usable==0 ) continue;
 
-    /* A direct lookup on the rowid or docid column. This is the best
-    ** strategy in all cases. Assign a cost of 1.0 and return early.
-    */
+    /* A direct lookup on the rowid or docid column. Assign a cost of 1.0. */
     if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ 
      && (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1 )
     ){
       pInfo->idxNum = FTS3_DOCID_SEARCH;
       pInfo->estimatedCost = 1.0;
       iCons = i;
-      break;
     }
 
     /* A MATCH constraint. Use a full-text search.
     **
     ** If there is more than one MATCH constraint available, use the first
     ** one encountered. If there is both a MATCH constraint and a direct
-    ** rowid/docid lookup, prefer the rowid/docid strategy.
+    ** rowid/docid lookup, prefer the MATCH strategy. This is done even 
+    ** though the rowid/docid lookup is faster than a MATCH query, selecting
+    ** it would lead to an "unable to use function MATCH in the requested 
+    ** context" error.
     */
-    if( iCons<0 
-     && pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH 
+    if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH 
      && pCons->iColumn>=0 && pCons->iColumn<=p->nColumn
     ){
       pInfo->idxNum = FTS3_FULLTEXT_SEARCH + pCons->iColumn;
       pInfo->estimatedCost = 2.0;
       iCons = i;
+      break;
     }
   }
 
index 0e309362022cea9375d1fb63d8df09f28d7c585a..2a4097d664415a4673a020a8d0a3cc10b8b97ca1 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\san\sOOM\srelated\sproblem\sin\sthe\ssnippet()\sand\soffsets()\sfunctions\sof\sfts3.
-D 2009-12-10T18:20:32
+C Fix\shandling\sof\s"WHERE\scol\sMATCH\s?\sAND\sdocid\s=\s?"\sclauses\sin\sfts3.
+D 2009-12-10T18:29:05
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -56,7 +56,7 @@ 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 a52050eb59dd190cacfce49e82dd11e66885aef9
+F ext/fts3/fts3.c 2542d222475c97e0b73ed3323a2905e81fef648a
 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
 F ext/fts3/fts3Int.h 1419e2973b44ee78f0ae8f7e03abfa2bdaf14f54
 F ext/fts3/fts3_expr.c fcf6812dbfd9cb9a2cabaf50e741411794f83e7e
@@ -326,7 +326,7 @@ F test/descidx3.test 3394ad4d089335cac743c36a14129d6d931c316f
 F test/diskfull.test 0cede7ef9d8f415d9d3944005c76be7589bb5ebb
 F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376
 F test/e_fkey.test fd1fcf89badd5f2773d7ac04775b5ff3488eda17
-F test/e_fts3.test 3acfdc1c363f245e6e251e067a5c375dd5e34731
+F test/e_fts3.test 3f3f70a0105d03d631b0db1408aa17bebd487d7f
 F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea
 F test/enc2.test 6d91a5286f59add0cfcbb2d0da913b76f2242398
 F test/enc3.test 5c550d59ff31dccdba5d1a02ae11c7047d77c041
@@ -778,7 +778,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 48c0db0eb2d134bb302bb5eca6beb0ec46736257
-R 4df67170c38eb456078008bc38ed8026
+P 61efff414254f209f1c69728ae2da3b3888b7290
+R 317e4960d3972e5703628a8e2153357f
 U dan
-Z bd1d5b1e641b924be3a08e7b99336f40
+Z def62a3a7397449ccead2b257ddb1820
index 4bd5b24b9549d8b13c4c047b964b9d2f67acbc1d..58afce12b7a713700819caa4ce6b078f4fd9c28e 100644 (file)
@@ -1 +1 @@
-61efff414254f209f1c69728ae2da3b3888b7290
\ No newline at end of file
+6cbbae849990d99b7ffe252b642d6be49d0c7235
\ No newline at end of file
index 1ec0aa30e5e545c681e28a996e09f3265ab368a8..146d7acc6703ad8b75b607570f46109bb1066e2d 100644 (file)
@@ -38,8 +38,6 @@ proc error_test {tn sql result} {
 }
 
 
-if 1 {
-
 #-------------------------------------------------------------------------
 # The body of the following [foreach] block contains test cases to verify
 # that the example code in fts3.html works as expected. The tests run three
@@ -547,7 +545,6 @@ read_test  6.7 { SELECT * FROM t6 WHERE t6 MATCH NULL } {}
 read_test  6.8 { SELECT * FROM t6 WHERE x MATCH NULL } {}
 #-------------------------------------------------------------------------
 
-
 #-------------------------------------------------------------------------
 # Test a few facets of the FTS3 xFilter() callback implementation:
 #
@@ -560,6 +557,7 @@ read_test  6.8 { SELECT * FROM t6 WHERE x MATCH NULL } {}
 #      that refer to a single FTS3 table in a WHERE clause.
 #
 #
+set DO_MALLOC_TEST 0
 ddl_test   7.1.1 { CREATE VIRTUAL TABLE t7 USING fts3(a) }
 ddl_test   7.1.2 { CREATE VIRTUAL TABLE t8 USING fts3(b) }
 write_test 7.1.3 t7_content { INSERT INTO t7(docid, a) VALUES(4,'number four') }
@@ -589,8 +587,9 @@ error_test 7.3.3 {
 read_test 7.3.4 {
   SELECT * FROM t7, t8 WHERE a MATCH 'number' AND b MATCH 'letter'
 } {{number four} {letter D} {number four} {letter E} {number five} {letter D} {number five} {letter E}}
-
-}
+read_test 7.3.5 {
+  SELECT * FROM t7 WHERE a MATCH 'number' AND docid = 4
+} {{number four}}
 
 #-------------------------------------------------------------------------
 # Test the quoting of FTS3 table column names. Names may be quoted using