]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Bug fixes and additional testing of descending indices. (CVS 2841)
authordrh <drh@noemail.net>
Wed, 21 Dec 2005 18:36:45 +0000 (18:36 +0000)
committerdrh <drh@noemail.net>
Wed, 21 Dec 2005 18:36:45 +0000 (18:36 +0000)
FossilOrigin-Name: 5638a11ed5618dd833d3daffc1715951091d72b2

manifest
manifest.uuid
src/btree.c
src/build.c
src/vdbe.c
src/vdbeaux.c
src/where.c
test/descidx1.test
test/descidx2.test [new file with mode: 0644]

index 18924fb9903b4e86e63e52debae6fc83f30c0740..18304a111d135656b2e67e6e4cd7de82065c3522 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Basic\sfunctionality\sfor\sdescending\sindices\sis\sin\splace.\s\sLots\smore\stesting\nneeded.\s(CVS\s2840)
-D 2005-12-21T14:43:12
+C Bug\sfixes\sand\sadditional\stesting\sof\sdescending\sindices.\s(CVS\s2841)
+D 2005-12-21T18:36:46
 F Makefile.in e3c6b3a38d734d41574c04f2fc90d18de2b87102
 F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -34,9 +34,9 @@ F src/alter.c 5905a3372379daa4f860199452b4de5a836e53f3
 F src/analyze.c ea42005eed52c382fcc7ef66969e7f1858597633
 F src/attach.c ee70131f128d31a9c6dcb8824e8471c91b18601a
 F src/auth.c 31e2304bef67f44d635655f44234387ea7d21454
-F src/btree.c 300fd8342f4d9f75829a8a96d60578592f3dee79
+F src/btree.c 2b2651e0f6f9f8c5976b662fbfab7fc8f54f02c9
 F src/btree.h 8ff86378bb5af0cde282614c16bf0c0190b6d216
-F src/build.c fd4417648d8e06d7a67ecfc2128752e8dad8909a
+F src/build.c 51f3f46801f68f49be8a1887f6a88e7fa3a16956
 F src/callback.c 62066afd516f220575e81b1a1239ab92a2eae252
 F src/complete.c df1681cef40dec33a286006981845f87b194e7a4
 F src/date.c bb079317bff6a2b78aba5c0d2ddae5f6f03acfb7
@@ -84,14 +84,14 @@ F src/update.c ec8e540617b116725b5a55c8d6b4db8bc67fdd7d
 F src/utf.c b7bffac4260177ae7f83c01d025fe0f5ed70ce71
 F src/util.c 8e0e3b1ad4f7c70706a9e76881882a409ccdb2e8
 F src/vacuum.c fbfdd3967fd34e2f260fafed88dcbf3c10856b94
-F src/vdbe.c ac5789b1d90538a578c0898e53bcc78876ed5a99
+F src/vdbe.c c04d2e517e7b515993164f51a3a8fb0958b7f4ce
 F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
 F src/vdbeInt.h 7b8b8c5dcb203243e4a9a4414c9e488473f67741
 F src/vdbeapi.c b270b680cbc5d20b5a1abfdb08339667985df94e
-F src/vdbeaux.c c38276e0c95d9ed9c35bab195faea3d57e787aea
+F src/vdbeaux.c 8fd4f36dba8729fabe7ed6b2a2c1b05b7bf96ebe
 F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
 F src/vdbemem.c deba8d6e3727643924b210a8c531a496c2b8d386
-F src/where.c 4db62a60cda1c267947b975daf177b3c99e90d2b
+F src/where.c 0296a20c2e2a39c0cb785efe471fd1958a5259f3
 F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
 F test/all.test 55706917a12cd616440d50c35323747b4a9f03c3
 F test/alter.test 9d6837a3d946b73df692b7cef2a7644d2e2f6bc6
@@ -145,7 +145,8 @@ F test/default.test 252298e42a680146b1dd64f563b95bdf088d94fb
 F test/delete.test e08ffb452f581d58703d0294242c9e2b8d091916
 F test/delete2.test e382b6a97787197eb8b93dd4ccd37797c3725ea3
 F test/delete3.test 555e84a00a99230b7d049d477a324a631126a6ab
-F test/descidx1.test c1e71467faea9757136c5e6189c86c08cdbd61e8
+F test/descidx1.test 8e9c3b91fd70d7a781d4081d8a62e24b7fd88aef
+F test/descidx2.test c68734d4068b7f7039deb9586cf0117b86c0d850
 F test/diskfull.test d828d72adfc9e2d1a194d25996718c1989152cf9
 F test/distinctagg.test 2b89d1c5220d966a30ba4b40430338669301188b
 F test/enc.test 7a03417a1051fe8bc6c7641cf4c8c3f7e0066d52
@@ -330,7 +331,7 @@ F www/tclsqlite.tcl ddcf912ea48695603c8ed7efb29f0812ef8d1b49
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 112a34b8dcceb39540cb0cd629e264a867400bfb
-R f37dcce5af7edd562296885925a69bf6
+P 7064433e5b06a4f858f39ce57650fba99fd72ffd
+R 94917009e8a89e467b492554dcbf3812
 U drh
-Z 916338110e2662cd6d96522a66ddbd1b
+Z f7950fd75afb0bae2ca1ce1afe7aaa41
index 1a1d963a9125a358beeb13a70f29179d1af6eca1..5df31366a3e11016c607a3a046164487de45e7ad 100644 (file)
@@ -1 +1 @@
-7064433e5b06a4f858f39ce57650fba99fd72ffd
\ No newline at end of file
+5638a11ed5618dd833d3daffc1715951091d72b2
\ No newline at end of file
index 052f917b7d3d90b2e11f7c0ad81cb0e1bfc704a3..6b8f962bdd3f89d08fac6223af000721d3bc99ff 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.275 2005/12/16 15:24:29 danielk1977 Exp $
+** $Id: btree.c,v 1.276 2005/12/21 18:36:46 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** For a detailed discussion of BTrees, refer to
@@ -2721,7 +2721,7 @@ int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
 **
 ** For INTKEY tables, only the nKey parameter is used.  pKey is
 ** ignored.  For other tables, nKey is the number of bytes of data
-** in nKey.  The comparison function specified when the cursor was
+** in pKey.  The comparison function specified when the cursor was
 ** created is used to compare keys.
 **
 ** If an exact match is not found, then the cursor is always
@@ -5817,4 +5817,3 @@ int sqlite3BtreeSync(Btree *pBt, const char *zMaster){
   }
   return SQLITE_OK;
 }
-
index 297478197654d53ce771729b9d736c313dc429c5..38f58028d491f0533d894763e2c79ec7e77b1f0d 100644 (file)
@@ -22,7 +22,7 @@
 **     COMMIT
 **     ROLLBACK
 **
-** $Id: build.c,v 1.360 2005/12/21 14:43:12 drh Exp $
+** $Id: build.c,v 1.361 2005/12/21 18:36:46 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
index 111c8ee15c4e43ca07d5efe7e24df941373ea1be..ed8f392b81729ecd9c1d5e2548f16099d5d66451 100644 (file)
@@ -43,7 +43,7 @@
 ** in this file for details.  If in doubt, do not deviate from existing
 ** commenting and indentation practices when changing or adding code.
 **
-** $Id: vdbe.c,v 1.507 2005/12/21 14:43:12 drh Exp $
+** $Id: vdbe.c,v 1.508 2005/12/21 18:36:46 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -2763,7 +2763,8 @@ case OP_MoveGt: {       /* no-push */
       pC->lastRowid = pTos->i;
       pC->rowidIsValid = res==0;
     }else{
-      Stringify(pTos, db->enc);
+      assert( pTos->flags & MEM_Blob );
+      /* Stringify(pTos, db->enc); */
       rc = sqlite3BtreeMoveto(pC->pCursor, pTos->z, pTos->n, &res);
       if( rc!=SQLITE_OK ){
         goto abort_due_to_error;
index 82977e8810c309cda1ae1b12cc1847c235b4eef8..4f291e385efac22e21904c3a417202e9803f36a2 100644 (file)
@@ -1738,9 +1738,8 @@ int sqlite3VdbeRecordCompare(
     }else if( d2<nKey2 ){
       rc = -1;
     }
-  }
-
-  if( pKeyInfo->aSortOrder && i<pKeyInfo->nField && pKeyInfo->aSortOrder[i] ){
+  }else if( pKeyInfo->aSortOrder && i<pKeyInfo->nField
+               && pKeyInfo->aSortOrder[i] ){
     rc = -rc;
   }
 
index 71ad86ef16bd8b9c24799c626b89d518334dc14d..e3dc7aca6a98e60d081ef36b6111ca91f03edcda 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.188 2005/12/21 03:16:43 drh Exp $
+** $Id: where.c,v 1.189 2005/12/21 18:36:46 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -1719,6 +1719,7 @@ WhereInfo *sqlite3WhereBegin(
       int btmEq=0;        /* True if btm limit uses ==. False if strictly > */
       int topOp, btmOp;   /* Operators for the top and bottom search bounds */
       int testOp;
+      int nNotNull;       /* Number of rows of index that must be non-NULL */
       int topLimit = (pLevel->flags & WHERE_TOP_LIMIT)!=0;
       int btmLimit = (pLevel->flags & WHERE_BTM_LIMIT)!=0;
 
@@ -1740,6 +1741,7 @@ WhereInfo *sqlite3WhereBegin(
       ** operator and the top bound is a < or <= operator.  For a descending
       ** index the operators are reversed.
       */
+      nNotNull = nEq + topLimit;
       if( pIdx->keyInfo.aSortOrder[nEq]==SQLITE_SO_ASC ){
         topOp = WO_LT|WO_LE;
         btmOp = WO_GT|WO_GE;
@@ -1837,7 +1839,7 @@ WhereInfo *sqlite3WhereBegin(
         }
       }
       sqlite3VdbeAddOp(v, OP_RowKey, iIdxCur, 0);
-      sqlite3VdbeAddOp(v, OP_IdxIsNull, nEq + topLimit, cont);
+      sqlite3VdbeAddOp(v, OP_IdxIsNull, nNotNull, cont);
       if( !omitTable ){
         sqlite3VdbeAddOp(v, OP_IdxRowid, iIdxCur, 0);
         sqlite3VdbeAddOp(v, OP_MoveGe, iCur, 0);
index 32ca81599eb45c2e28dc0420266ecc67652f596a..03b28d64807d8cba142dc28d98d23f1d94d6f05d 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script is descending indices.
 #
-# $Id: descidx1.test,v 1.1 2005/12/21 14:43:12 drh Exp $
+# $Id: descidx1.test,v 1.2 2005/12/21 18:36:46 drh Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -168,4 +168,124 @@ do_test descidx1-3.26 {
   cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a DESC}
 } {7 6 5 4 nosort}
 
+# Create a table with indices that are descending on some terms and
+# ascending on others.
+#
+do_test descidx1-4.1 {
+  execsql {
+    CREATE TABLE t2(a INT, b TEXT, c BLOB, d REAL);
+    CREATE INDEX i3 ON t2(a ASC, b DESC, c ASC);
+    CREATE INDEX i4 ON t2(b DESC, a ASC, d DESC);
+    INSERT INTO t2 VALUES(1,'one',x'31',1.0);
+    INSERT INTO t2 VALUES(2,'two',x'3232',2.0);
+    INSERT INTO t2 VALUES(3,'three',x'333333',3.0);
+    INSERT INTO t2 VALUES(4,'four',x'34343434',4.0);
+    INSERT INTO t2 VALUES(5,'five',x'3535353535',5.0);
+    INSERT INTO t2 VALUES(6,'six',x'363636363636',6.0);
+    INSERT INTO t2 VALUES(2,'two',x'323232',2.1);
+    INSERT INTO t2 VALUES(2,'zwei',x'3232',2.2);
+    INSERT INTO t2 VALUES(2,NULL,NULL,2.3);
+    SELECT count(*) FROM t2;
+  }
+} {9}
+do_test descidx1-4.2 {
+  execsql {
+    SELECT d FROM t2 ORDER BY a;
+  }
+} {1.0 2.2 2.0 2.1 2.3 3.0 4.0 5.0 6.0}
+do_test descidx1-4.3 {
+  execsql {
+    SELECT d FROM t2 WHERE a>=2;
+  }
+} {2.2 2.0 2.1 2.3 3.0 4.0 5.0 6.0}
+do_test descidx1-4.4 {
+  execsql {
+    SELECT d FROM t2 WHERE a>2;
+  }
+} {3.0 4.0 5.0 6.0}
+do_test descidx1-4.5 {
+  execsql {
+    SELECT d FROM t2 WHERE a=2 AND b>'two';
+  }
+} {2.2}
+do_test descidx1-4.6 {
+  execsql {
+    SELECT d FROM t2 WHERE a=2 AND b>='two';
+  }
+} {2.2 2.0 2.1}
+do_test descidx1-4.7 {
+  execsql {
+    SELECT d FROM t2 WHERE a=2 AND b<'two';
+  }
+} {}
+do_test descidx1-4.8 {
+  execsql {
+    SELECT d FROM t2 WHERE a=2 AND b<='two';
+  }
+} {2.0 2.1}
+
+do_test descidx1-5.1 {
+  execsql {
+    CREATE TABLE t3(a,b,c,d);
+    CREATE INDEX t3i1 ON t3(a DESC, b ASC, c DESC, d ASC);
+    INSERT INTO t3 VALUES(0,0,0,0);
+    INSERT INTO t3 VALUES(0,0,0,1);
+    INSERT INTO t3 VALUES(0,0,1,0);
+    INSERT INTO t3 VALUES(0,0,1,1);
+    INSERT INTO t3 VALUES(0,1,0,0);
+    INSERT INTO t3 VALUES(0,1,0,1);
+    INSERT INTO t3 VALUES(0,1,1,0);
+    INSERT INTO t3 VALUES(0,1,1,1);
+    INSERT INTO t3 VALUES(1,0,0,0);
+    INSERT INTO t3 VALUES(1,0,0,1);
+    INSERT INTO t3 VALUES(1,0,1,0);
+    INSERT INTO t3 VALUES(1,0,1,1);
+    INSERT INTO t3 VALUES(1,1,0,0);
+    INSERT INTO t3 VALUES(1,1,0,1);
+    INSERT INTO t3 VALUES(1,1,1,0);
+    INSERT INTO t3 VALUES(1,1,1,1);
+    SELECT count(*) FROM t3;
+  }
+} {16}
+do_test descidx1-5.2 {
+  cksort {
+    SELECT a||b||c||d FROM t3 ORDER BY a,b,c,d;
+  }
+} {0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 sort}
+do_test descidx1-5.3 {
+  cksort {
+    SELECT a||b||c||d FROM t3 ORDER BY a DESC, b ASC, c DESC, d ASC;
+  }
+} {1010 1011 1000 1001 1110 1111 1100 1101 0010 0011 0000 0001 0110 0111 0100 0101 nosort}
+do_test descidx1-5.4 {
+  cksort {
+    SELECT a||b||c||d FROM t3 ORDER BY a ASC, b DESC, c ASC, d DESC;
+  }
+} {0101 0100 0111 0110 0001 0000 0011 0010 1101 1100 1111 1110 1001 1000 1011 1010 nosort}
+do_test descidx1-5.5 {
+  cksort {
+    SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a DESC, b ASC, c DESC
+  }
+} {101 100 111 110 001 000 011 010 nosort}
+do_test descidx1-5.6 {
+  cksort {
+    SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a ASC, b DESC, c ASC
+  }
+} {010 011 000 001 110 111 100 101 nosort}
+do_test descidx1-5.7 {
+  cksort {
+    SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a ASC, b DESC, c DESC
+  }
+} {011 010 001 000 111 110 101 100 sort}
+do_test descidx1-5.8 {
+  cksort {
+    SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a ASC, b ASC, c ASC
+  }
+} {000 001 010 011 100 101 110 111 sort}
+do_test descidx1-5.9 {
+  cksort {
+    SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a DESC, b DESC, c ASC
+  }
+} {110 111 100 101 010 011 000 001 sort}
+
 finish_test
diff --git a/test/descidx2.test b/test/descidx2.test
new file mode 100644 (file)
index 0000000..224e893
--- /dev/null
@@ -0,0 +1,183 @@
+# 2005 December 21
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library.  The
+# focus of this script is descending indices.
+#
+# $Id: descidx2.test,v 1.1 2005/12/21 18:36:46 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# This procedure sets the value of the file-format in file 'test.db'
+# to $newval. Also, the schema cookie is incremented.
+# 
+proc set_file_format {newval} {
+  set bt [btree_open test.db 10 0]
+  btree_begin_transaction $bt
+  set meta [btree_get_meta $bt]
+  lset meta 2 $newval                    ;# File format
+  lset meta 1 [expr [lindex $meta 1]+1]  ;# Schema cookie
+  eval "btree_update_meta $bt $meta"
+  btree_commit $bt
+  btree_close $bt
+}
+
+# This procedure returns the value of the file-format in file 'test.db'.
+# 
+proc get_file_format {{fname test.db}} {
+  set bt [btree_open $fname 10 0]
+  set meta [btree_get_meta $bt]
+  btree_close $bt
+  lindex $meta 2
+}
+
+# Verify that the file format jumps to (at least) 4 as soon as a
+# descending index is created.
+#
+do_test descidx2-1.1 {
+  execsql {
+    CREATE TABLE t1(a,b);
+    CREATE INDEX i1 ON t1(b ASC);
+  }
+  get_file_format
+} {1}
+do_test descidx2-1.2 {
+  execsql {
+    CREATE INDEX i2 ON t1(a DESC);
+  }
+  get_file_format
+} {4}
+
+# Before adding any information to the database, set the file format
+# back to three.  Then close and reopen the database.  With the file
+# format set to three, SQLite should ignore the DESC argument on the
+# index.
+#
+do_test descidx2-2.0 {
+  set_file_format 3
+  db close
+  sqlite3 db test.db
+  get_file_format
+} {3}
+
+# Put some information in the table and verify that the DESC
+# on the index is ignored.
+#
+do_test descidx2-2.1 {
+  execsql {
+    INSERT INTO t1 VALUES(1,1);
+    INSERT INTO t1 VALUES(2,2);
+    INSERT INTO t1 SELECT a+2, a+2 FROM t1;
+    INSERT INTO t1 SELECT a+4, a+4 FROM t1;
+    SELECT b FROM t1 WHERE a>3 AND a<7;
+  }
+} {4 5 6}
+do_test descidx2-2.2 {
+  execsql {
+    SELECT a FROM t1 WHERE b>3 AND b<7;
+  }
+} {4 5 6}
+do_test descidx2-2.3 {
+  execsql {
+    SELECT b FROM t1 WHERE a>=3 AND a<7;
+  }
+} {3 4 5 6}
+do_test descidx2-2.4 {
+  execsql {
+    SELECT b FROM t1 WHERE a>3 AND a<=7;
+  }
+} {4 5 6 7}
+do_test descidx2-2.5 {
+  execsql {
+    SELECT b FROM t1 WHERE a>=3 AND a<=7;
+  }
+} {3 4 5 6 7}
+do_test descidx2-2.6 {
+  execsql {
+    SELECT a FROM t1 WHERE b>=3 AND b<=7;
+  }
+} {3 4 5 6 7}
+
+# This procedure executes the SQL.  Then it checks to see if the OP_Sort
+# opcode was executed.  If an OP_Sort did occur, then "sort" is appended
+# to the result.  If no OP_Sort happened, then "nosort" is appended.
+#
+# This procedure is used to check to make sure sorting is or is not
+# occurring as expected.
+#
+proc cksort {sql} {
+  set ::sqlite_sort_count 0
+  set data [execsql $sql]
+  if {$::sqlite_sort_count} {set x sort} {set x nosort}
+  lappend data $x
+  return $data
+}
+
+# Test sorting using a descending index.
+#
+do_test descidx2-3.1 {
+  cksort {SELECT a FROM t1 ORDER BY a}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.2 {
+  cksort {SELECT a FROM t1 ORDER BY a ASC}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.3 {
+  cksort {SELECT a FROM t1 ORDER BY a DESC}
+} {8 7 6 5 4 3 2 1 nosort}
+do_test descidx2-3.4 {
+  cksort {SELECT b FROM t1 ORDER BY a}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.5 {
+  cksort {SELECT b FROM t1 ORDER BY a ASC}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.6 {
+  cksort {SELECT b FROM t1 ORDER BY a DESC}
+} {8 7 6 5 4 3 2 1 nosort}
+do_test descidx2-3.7 {
+  cksort {SELECT a FROM t1 ORDER BY b}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.8 {
+  cksort {SELECT a FROM t1 ORDER BY b ASC}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.9 {
+  cksort {SELECT a FROM t1 ORDER BY b DESC}
+} {8 7 6 5 4 3 2 1 nosort}
+do_test descidx2-3.10 {
+  cksort {SELECT b FROM t1 ORDER BY b}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.11 {
+  cksort {SELECT b FROM t1 ORDER BY b ASC}
+} {1 2 3 4 5 6 7 8 nosort}
+do_test descidx2-3.12 {
+  cksort {SELECT b FROM t1 ORDER BY b DESC}
+} {8 7 6 5 4 3 2 1 nosort}
+
+do_test descidx2-3.21 {
+  cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a}
+} {4 5 6 7 nosort}
+do_test descidx2-3.22 {
+  cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a ASC}
+} {4 5 6 7 nosort}
+do_test descidx2-3.23 {
+  cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a DESC}
+} {7 6 5 4 nosort}
+do_test descidx2-3.24 {
+  cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a}
+} {4 5 6 7 nosort}
+do_test descidx2-3.25 {
+  cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a ASC}
+} {4 5 6 7 nosort}
+do_test descidx2-3.26 {
+  cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a DESC}
+} {7 6 5 4 nosort}
+
+finish_test