]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a problem with min() and descending indexes. (CVS 4933)
authordanielk1977 <danielk1977@noemail.net>
Fri, 28 Mar 2008 19:16:56 +0000 (19:16 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Fri, 28 Mar 2008 19:16:56 +0000 (19:16 +0000)
FossilOrigin-Name: 39705b617a775d4299e98ac88fab4525a64d8b78

manifest
manifest.uuid
src/where.c
test/minmax3.test

index b1de4c8b2d03cfa4d0aa47782733f4b0a82810ec..5f04bf6fbdaad8c8e08b900936a454f96aef301b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\smemory\sleak\sthat\scan\soccur\swhen\sthe\slibrary\sAPI\sis\smisused.\s(CVS\s4932)
-D 2008-03-28T19:16:34
+C Fix\sa\sproblem\swith\smin()\sand\sdescending\sindexes.\s(CVS\s4933)
+D 2008-03-28T19:16:57
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in cf434ce8ca902e69126ae0f94fc9f7dc7428a5fa
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -183,7 +183,7 @@ F src/vdbeblob.c cc713c142c3d4952b380c98ee035f850830ddbdb
 F src/vdbefifo.c a30c237b2a3577e1415fb6e288cbb6b8ed1e5736
 F src/vdbemem.c e7ced8846ef50502cc610ecc7b32bb0f0bba1578
 F src/vtab.c 00cd16317b29495c185ff40e4b227917d5a371b2
-F src/where.c aa7ca84521e44925a5f5afa4a0572444a61befe9
+F src/where.c dc146152cd0eb3b3568e92e7fed55cd008ebb9b5
 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/all.test d12210212bada2bde6d5aeb90969b86c1aa977d2
@@ -388,7 +388,7 @@ F test/memdb.test a67bda4ff90a38f2b19f6c7f95aa7289e051d893
 F test/memleak.test d2d2a1ff7105d32dc3fdf691458cf6cba58c7217
 F test/minmax.test 5d56f08a7765dfb5c1fb303333f7444dacb37bef
 F test/minmax2.test 33504c01a03bd99226144e4b03f7631a274d66e0
-F test/minmax3.test 05f35e79a2d7e554945fbc64c90caec736d0b99b
+F test/minmax3.test 05110398e065875b3d9315892889d3c87fccfe2b
 F test/misc1.test 1b89c02c4a33b49dee4cd1d20d161aaaba719075
 F test/misc2.test 1ee89298de9c16b61454658b24999c403e86afe4
 F test/misc3.test aea079f4c3d93e9962186f45c0ff0954310e6b11
@@ -619,7 +619,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P b99d19d651b00dcc7bdb36facfd9ecffe4fafd9f
-R e62394b42b597cc4853ef813c5823149
+P 2b6d3e015e3088531c62230c9b3bdab47ef534da
+R 7e83adaa8106ab7f1ce1a0f44d5e7926
 U danielk1977
-Z 5f5565eaa0d6e1fc9e5636f169e9e042
+Z 3821d17b602f55bf94d594c026fd1b0c
index d491417c13c28014c69255adb068398dcf64e7da..3c44a07dfc002c8d1fb39e1aad7919c13c7b1573 100644 (file)
@@ -1 +1 @@
-2b6d3e015e3088531c62230c9b3bdab47ef534da
\ No newline at end of file
+39705b617a775d4299e98ac88fab4525a64d8b78
\ No newline at end of file
index 6f8b4cad0fbe67ec7f0da8fe02e6910b8ca7028a..1d8b50c87d2c39f339115a43b0e2cc08b458f220 100644 (file)
@@ -16,7 +16,7 @@
 ** so is applicable.  Because this module is responsible for selecting
 ** indices, you might also think of this module as the "query optimizer".
 **
-** $Id: where.c,v 1.293 2008/03/28 18:11:17 danielk1977 Exp $
+** $Id: where.c,v 1.294 2008/03/28 19:16:57 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -2556,7 +2556,7 @@ WhereInfo *sqlite3WhereBegin(
       }
       if( nEq>0 || btmLimit || (isMinQuery&&!bRev) ){
         int nCol = nEq + btmLimit;
-        if( isMinQuery && !btmLimit ){
+        if( isMinQuery && !bRev && !btmLimit ){
           sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nCol);
           nCol++;
           btmEq = 0;
index 72f72adeaf9cbdf40615146ebe0ce870bc6ef580..535a4bf8508e7c416d61a9935a651ffd60117cf1 100644 (file)
@@ -8,7 +8,7 @@
 #    May you share freely, never taking more than you give.
 #
 #***********************************************************************
-# $Id: minmax3.test,v 1.3 2008/03/28 18:11:17 danielk1977 Exp $
+# $Id: minmax3.test,v 1.4 2008/03/28 19:16:57 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -174,5 +174,45 @@ do_test minmax3-2.8 {
   execsql { SELECT min(b) FROM t2 WHERE a = 3 AND b<1; }
 } {{}}
 
+do_test minmax3-2.1 {
+  execsql {
+    DROP TABLE t2;
+    CREATE TABLE t2(a, b);
+    CREATE INDEX i3 ON t2(a, b DESC);
+    INSERT INTO t2 VALUES(1, NULL);
+    INSERT INTO t2 VALUES(1, 1);
+    INSERT INTO t2 VALUES(1, 2);
+    INSERT INTO t2 VALUES(1, 3);
+    INSERT INTO t2 VALUES(2, NULL);
+    INSERT INTO t2 VALUES(2, 1);
+    INSERT INTO t2 VALUES(2, 2);
+    INSERT INTO t2 VALUES(2, 3);
+    INSERT INTO t2 VALUES(3, 1);
+    INSERT INTO t2 VALUES(3, 2);
+    INSERT INTO t2 VALUES(3, 3);
+  }
+} {}
+do_test minmax3-2.2 {
+  execsql { SELECT min(b) FROM t2 WHERE a = 1; }
+} {1}
+do_test minmax3-2.3 {
+  execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b>1; }
+} {2}
+do_test minmax3-2.4 {
+  execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b>-1; }
+} {1}
+do_test minmax3-2.5 {
+  execsql { SELECT min(b) FROM t2 WHERE a = 1; }
+} {1}
+do_test minmax3-2.6 {
+  execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b<2; }
+} {1}
+do_test minmax3-2.7 {
+  execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b<1; }
+} {{}}
+do_test minmax3-2.8 {
+  execsql { SELECT min(b) FROM t2 WHERE a = 3 AND b<1; }
+} {{}}
+
 finish_test