]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix another variant of the "IN (...)" b-tree problem. (CVS 3988)
authordanielk1977 <danielk1977@noemail.net>
Sat, 12 May 2007 10:41:47 +0000 (10:41 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Sat, 12 May 2007 10:41:47 +0000 (10:41 +0000)
FossilOrigin-Name: 260338c4b2b18c9f4da8bc7fe3eda306dcaa4e38

manifest
manifest.uuid
src/btree.c
test/in2.test

index 2815e02f61d67379e0131fe4d6274c77a58adafd..ff604676e87587865934b79228dd5d3f22fe36a7 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\san\sobscure\sb-tree\sbug\sthat\sapplied\sto\stransient\strees\sused\sfor\sIN(...)\sexpressions.\s(CVS\s3987)
-D 2007-05-12T09:30:47
+C Fix\sanother\svariant\sof\sthe\s"IN\s(...)"\sb-tree\sproblem.\s(CVS\s3988)
+D 2007-05-12T10:41:48
 F Makefile.in 87b200ad9970907f76df734d29dff3d294c10935
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -61,7 +61,7 @@ F src/alter.c ca8fc4a3c7359379598dc12589b65c32eb88defd
 F src/analyze.c 4bbf5ddf9680587c6d4917e02e378b6037be3651
 F src/attach.c ba628db0c2b6a362f036d017bf1196cdfe4ebb37
 F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f
-F src/btree.c f24b394e5f5b46fced3464c19ac623d0d92ccaa6
+F src/btree.c 0c2f9b06c90d7c59925c03153c9d47fd739c8ca5
 F src/btree.h 1d527bf61ed176f980c34999d5793a0fd45dcf8c
 F src/btreeInt.h cb3c0e9eb842d06079a62cdf3492c90c5db7ba75
 F src/build.c 5789303291d40a1d37bfede83c1c769be22c88ab
@@ -253,7 +253,7 @@ F test/fuzz2.test fdbea571808441c12c91e9cd038eb77b4692d42b
 F test/hook.test 7e7645fd9a033f79cce8fdff151e32715e7ec50a
 F test/icu.test e6bfae7f625c88fd14df6f540fe835bdfc1e4329
 F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d
-F test/in2.test d76a13877d9c445308f48a26db9ea25a6d77032f
+F test/in2.test b1f447f4f0f67e9f83ff931e7e2e30873f9ea055
 F test/incrblob.test 7f82ae497364612aa17a37f77f12e01e2bee9f20
 F test/incrblob_err.test 9dae0762ba4d73b516d176d091c6b2b16f625953
 F test/incrvacuum.test f490c8ae86f2ecca622425d02e27d3119058cb21
@@ -489,7 +489,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 2e80736d57fde55b112864d8b198a9a2fe0eaa38
-R c03758dd4b5f8ad6c12d156193f78eb7
+P 96c7232f8b208cd1c50063f7946bb6dbc386abd6
+R e2d831528bd9b1aa18f85c2d481b3b12
 U danielk1977
-Z d455335e1335c1a2040ee8b7528b51b1
+Z 0924774789a8e6d243ad58907ec918b8
index a5702e213cb823401e852ccf06c67dc260414b37..e5a06b08204860fd3bff6575511e76b31d275298 100644 (file)
@@ -1 +1 @@
-96c7232f8b208cd1c50063f7946bb6dbc386abd6
\ No newline at end of file
+260338c4b2b18c9f4da8bc7fe3eda306dcaa4e38
\ No newline at end of file
index 2c0f0dfc3c0311a5fe6e1725d13a16a84c98488d..5efdcc1dacd1179ae9fac2ad0e6535b519919f21 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.380 2007/05/12 09:30:47 danielk1977 Exp $
+** $Id: btree.c,v 1.381 2007/05/12 10:41:48 danielk1977 Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** See the header comment on "btreeInt.h" for additional information.
@@ -4510,6 +4510,10 @@ static int balance_nonroot(MemPage *pPage){
           memcpy(apCell[nCell], &pOld->aData[pOld->hdrOffset+8], 4);
         }else{
           assert( leafCorrection==4 );
+          if( szCell[nCell]<4 ){
+            /* Do not allow any cells smaller than 4 bytes. */
+            szCell[nCell] = 4;
+          }
         }
         nCell++;
       }
index 9fd7be6ff9d4d79eda3f2441153da5b4a02326a3..77092bf5455cabba41680e400b557470b0537670 100644 (file)
@@ -11,7 +11,7 @@
 # This file tests a special case in the b-tree code that can be
 # hit by the "IN" operator (or EXISTS, NOT IN, etc.).
 #
-# $Id: in2.test,v 1.1 2007/05/12 09:30:47 danielk1977 Exp $
+# $Id: in2.test,v 1.2 2007/05/12 10:41:48 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -22,15 +22,18 @@ do_test in2-1 {
   }
 } {}
 
+set ::N 2000
+
 do_test in2-2 {
   db transaction {
-    for {set ::ii 0} {$::ii < 1000} {incr ::ii} {
+    for {set ::ii 0} {$::ii < $::N} {incr ::ii} {
       execsql {INSERT INTO a VALUES($::ii, $::ii)}
     }
-    execsql {INSERT INTO a VALUES(1000, '')}
+    execsql {INSERT INTO a VALUES(4000, '')}
 
-    for {set ::ii 0} {$::ii < 1000} {incr ::ii} {
-      execsql {INSERT INTO a VALUES(NULL, 'x' || $::ii)}
+    for {set ::ii 0} {$::ii < $::N} {incr ::ii} {
+      set ::t [format "x%04d" $ii]
+      execsql {INSERT INTO a VALUES(NULL, $::t)}
     }
   }
 } {}
@@ -41,7 +44,7 @@ do_test in2-2 {
 #
 #     $::ii integers.
 #     a string of zero length.
-#     1000 short strings.
+#     $::N short strings.
 #
 # Records are inserted in sorted order.
 #
@@ -53,10 +56,10 @@ do_test in2-2 {
 # clauses, as it is impossible for persistent b-trees (SQL tables + 
 # indices) to contain cells smaller than 4 bytes.
 #
-for {set ::ii 3} {$::ii < 1000} {incr ::ii} {
+for {set ::ii 3} {$::ii < $::N} {incr ::ii} {
   do_test in2-$::ii {
     execsql {
-      SELECT 1 IN (SELECT a FROM a WHERE (i < $::ii) OR (i >= 1000))
+      SELECT 1 IN (SELECT a FROM a WHERE (i < $::ii) OR (i >= $::N))
     }
   } {1}
 }