mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Get the min/max optimization working with descending indices. Ticket #2514. (CVS 4161)
FossilOrigin-Name: a80a3c9d0a5e0a8a3d67bd841e2076893fd5e9aa
This commit is contained in:
12
src/select.c
12
src/select.c
@@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** to handle SELECT statements in SQLite.
|
||||
**
|
||||
** $Id: select.c,v 1.353 2007/06/26 10:38:55 danielk1977 Exp $
|
||||
** $Id: select.c,v 1.354 2007/07/18 18:17:12 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -2514,6 +2514,16 @@ static int simpleMinMaxQuery(Parse *pParse, Select *p, int eDest, int iParm){
|
||||
sqlite3VdbeAddOp(v, OP_MakeRecord, 1, 0);
|
||||
seekOp = OP_MoveGt;
|
||||
}
|
||||
if( pIdx->aSortOrder[0]==SQLITE_SO_DESC ){
|
||||
/* Ticket #2514: invert the seek operator if we are using
|
||||
** a descending index. */
|
||||
if( seekOp==OP_Last ){
|
||||
seekOp = OP_Rewind;
|
||||
}else{
|
||||
assert( seekOp==OP_MoveGt );
|
||||
seekOp = OP_MoveLt;
|
||||
}
|
||||
}
|
||||
sqlite3VdbeAddOp(v, seekOp, iIdx, 0);
|
||||
sqlite3VdbeAddOp(v, OP_IdxRowid, iIdx, 0);
|
||||
sqlite3VdbeAddOp(v, OP_Close, iIdx, 0);
|
||||
|
||||
Reference in New Issue
Block a user