]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a problem involving a 3-way NEAR query.
authordan <dan@noemail.net>
Fri, 4 Dec 2009 19:07:24 +0000 (19:07 +0000)
committerdan <dan@noemail.net>
Fri, 4 Dec 2009 19:07:24 +0000 (19:07 +0000)
FossilOrigin-Name: 507890a9139875b1b594225c432c714f67312c0e

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

index e1a84cfdc071f4c0a2d8a851ab9408f0a79b5953..0ca6d41503cf86b19e8456832e38ee163e91d138 100644 (file)
@@ -1051,6 +1051,8 @@ static void fts3PoslistCopy(char **pp, char **ppPoslist){
 static void fts3ColumnlistCopy(char **pp, char **ppPoslist){
   char *pEnd = *ppPoslist;
   char c = 0;
+
+  /* A column-list is terminated by either a 0x01 or 0x00. */
   while( 0xFE & (*pEnd | c) ) c = *pEnd++ & 0x80;
   if( pp ){
     int n = (int)(pEnd - *ppPoslist);
@@ -1106,8 +1108,20 @@ static void fts3PoslistMerge(
         if( 0==(*p2&0xFE) ) i2 = 0x7FFFFFFF;
       }
     }else if( iCol1<iCol2 ){
+      if( iCol1 ){
+        int n = sqlite3Fts3PutVarint(&p[1], iCol1);
+        *p = 0x01;
+        p += n+1;
+        p1 += n+1;
+      }
       fts3ColumnlistCopy(&p, &p1);
     }else{
+      if( iCol2 ){
+        int n = sqlite3Fts3PutVarint(&p[1], iCol2);
+        *p = 0x01;
+        p += n+1;
+        p2 += n+1;
+      }
       fts3ColumnlistCopy(&p, &p2);
     }
   }
index debfdb26081f272ff22cc44cf8d3a966581648e8..2cfc938d0cd7e3245ec68250e6d40a89dd6009e7 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,5 @@
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C In\sthe\sOSTRACE\sdebugging\smacros\sin\sos_unix.c,\sidentify\sthe\sVFS\scurrently\nin\suse.
-D 2009-12-04T14:25:19
+C Fix\sa\sproblem\sinvolving\sa\s3-way\sNEAR\squery.
+D 2009-12-04T19:07:25
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -59,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 da95f0191c2a016a78d12334ccfed76769043952
+F ext/fts3/fts3.c 54ad3e8f0374148768ad65724cff89a8a5a241a7
 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
 F ext/fts3/fts3Int.h cc716c74afa7da8e0f8ef39404f33ea62a823eb3
 F ext/fts3/fts3_expr.c c18794a62c257d3456d3314c5a18e348ae0d84bd
@@ -405,7 +402,7 @@ F test/fts3expr.test 05dab77387801e4900009917bb18f556037d82da
 F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a
 F test/fts3malloc.test d02ee86b21edd2b43044e0d6dfdcd26cb6efddcb
 F test/fts3near.test dc196dd17b4606f440c580d45b3d23aa975fd077
-F test/fts3rnd.test 65f534898c5f7cce3f51b2c2dfc179e2287346b2
+F test/fts3rnd.test 071ff7ed7bf60f8f7502a3e09cbc680dbd795da1
 F test/func.test af106ed834001738246d276659406823e35cde7b
 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
 F test/fuzz.test a4174c3009a3e2c2e14b31b364ebf7ddb49de2c9
@@ -779,14 +776,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 69c21ee46aeeb624fd8638b17ff7259a3e5f9a46
-R 400f092ce88a5a339c0b27b8a8415aa3
-U drh
-Z ed4cd334a82b89245ccfc3ad9b838d68
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFLGRvSoxKgR168RlERApe7AJ9uIN22ikW++Uqhi70+FZLKfs2R8gCfUGfY
-GTEEJa/7cpPCyUSqfXB/ROE=
-=u43h
------END PGP SIGNATURE-----
+P 082b8da005128f47f63e95b6b702bf4517221b2a
+R 8882a051c5ec0b862c5bc60eb34d651e
+U dan
+Z 1493d6f5f2ac30a6a5cc018ff1d6ae85
index c168f820ead7f4b7ed6513bd7eac3af925830770..6b312d77d3db04251b79e57ae19d6b9516ae4ed1 100644 (file)
@@ -1 +1 @@
-082b8da005128f47f63e95b6b702bf4517221b2a
\ No newline at end of file
+507890a9139875b1b594225c432c714f67312c0e
\ No newline at end of file
index 85141e62b4bab0f1b10fc65deb783abcbf2e5487..057fd5fa27230af18d869308594acc8403ab8126 100644 (file)
@@ -91,6 +91,37 @@ proc simple_prefix {zPrefix} {
 }
 
 proc simple_near {termlist nNear} {
+  set ret [list]
+
+  # List of nNear+1 elements that contains no terms.
+  #
+  set dummyfields "[string repeat "X " $nNear]X"
+
+  foreach {key value} [array get ::t1] {
+    foreach v $value {
+      set v [concat $dummyfields $v $dummyfields]
+
+      set l [lsearch -exact -all $v [lindex $termlist 0]]
+      foreach T [lrange $termlist 1 end] {
+        set l2 [list]
+        foreach i $l {
+          set iStart [expr $i - $nNear - 1]
+          set iEnd [expr $i + $nNear + 1]
+          foreach i2 [lsearch -exact -all [lrange $v $iStart $iEnd] $T] {
+            incr i2 $iStart
+            if {$i2 != $i} { lappend l2 $i2 } 
+          }
+        }
+        set l $l2
+      }
+
+      if {[llength $l]} {
+        lappend ret $key
+      } 
+    }
+  }
+
+  lsort -unique -integer $ret
 }
 
 foreach nodesize {50 500 1000 2000} {
@@ -171,11 +202,21 @@ foreach nodesize {50 500 1000 2000} {
 
     # A NEAR query with terms as the arguments.
     #
-if 0 {
     for {set i 0} {$i < 10} {incr i} {
       set terms [list [random_term] [random_term]]
       set match [join $terms " NEAR "]
-      do_test fts3rnd-1.$nodesize.$iTest.5.$i {
+      do_test fts3rnd-1.$nodesize.$iTest.5.$i.$match {
+        execsql { SELECT docid FROM t1 WHERE t1 MATCH $match }
+      } [simple_near $terms 10]
+    }
+if 0 {
+    # A 3-way NEAR query with terms as the arguments.
+    #
+    for {set i 0} {$i < 10} {incr i} {
+      set terms [list [random_term] [random_term] [random_term]]
+      set match [join $terms " NEAR "]
+      do_test fts3rnd-1.$nodesize.$iTest.5.$i.$match {
         execsql { SELECT docid FROM t1 WHERE t1 MATCH $match }
       } [simple_near $terms 10]
     }