aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2013-03-12 20:38:51 +0000
committerdrh <drh@noemail.net>2013-03-12 20:38:51 +0000
commit1ccce44937732f9aa7717fe25702a4c30ddf6315 (patch)
tree54ea249b6a1ca5958c9401991e4f69a0919af631 /src/expr.c
parentd383216383fdea13fbeb972859bce9622897f88d (diff)
downloadsqlite-1ccce44937732f9aa7717fe25702a4c30ddf6315.tar.gz
sqlite-1ccce44937732f9aa7717fe25702a4c30ddf6315.zip
Fix the ORDER BY optimization with IN constraints when the RHS of the
IN constraint is a descending index. FossilOrigin-Name: 62316ebaca933f7e5df2018e8360a2b74234f30a
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/expr.c b/src/expr.c
index 4f38ab0a4..ed5451b1c 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -1456,10 +1456,11 @@ int sqlite3CodeOnce(Parse *pParse){
**
** The returned value of this function indicates the b-tree type, as follows:
**
-** IN_INDEX_ROWID - The cursor was opened on a database table.
-** IN_INDEX_INDEX - The cursor was opened on a database index.
-** IN_INDEX_EPH - The cursor was opened on a specially created and
-** populated epheremal table.
+** IN_INDEX_ROWID - The cursor was opened on a database table.
+** IN_INDEX_INDEX_ASC - The cursor was opened on an ascending index.
+** IN_INDEX_INDEX_DESC - The cursor was opened on a descending index.
+** IN_INDEX_EPH - The cursor was opened on a specially created and
+** populated epheremal table.
**
** An existing b-tree might be used if the RHS expression pX is a simple
** subquery such as:
@@ -1582,7 +1583,8 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){
sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx->tnum, iDb,
pKey,P4_KEYINFO_HANDOFF);
VdbeComment((v, "%s", pIdx->zName));
- eType = IN_INDEX_INDEX;
+ assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
+ eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
sqlite3VdbeJumpHere(v, iAddr);
if( prNotFound && !pTab->aCol[iCol].notNull ){