SQLite

Check-in [3ce7eb0265]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Revise the patch to make it easier to understand.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | desc-orderby-fix-1
Files: files | file ages | folders
SHA1: 3ce7eb0265b5be4e23264ae41332b947011ff1ad
User & Date: drh 2013-03-12 18:49:25.514
Context
2013-03-12
20:38
Fix the ORDER BY optimization with IN constraints when the RHS of the IN constraint is a descending index. (check-in: 62316ebaca user: drh tags: desc-orderby-fix-1)
18:49
Revise the patch to make it easier to understand. (check-in: 3ce7eb0265 user: drh tags: desc-orderby-fix-1)
18:44
Add test cases for [4dd95f6943]. (check-in: 723c144c76 user: dan tags: desc-orderby-fix-1)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/where.c.
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801

3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
    iReg = iTarget;
    sqlite3VdbeAddOp2(v, OP_Null, 0, iReg);
#ifndef SQLITE_OMIT_SUBQUERY
  }else{
    int eType;
    int iTab;
    struct InLoop *pIn;
    u8 bRev;

    if( (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 ){
      bRev = pLevel->plan.u.pIdx->aSortOrder[iEq];
    }else{

      bRev = 0;
    }
    if( pLevel->plan.wsFlags & WHERE_REVERSE ) bRev = 1 - bRev;
    assert( pX->op==TK_IN );
    iReg = iTarget;
    eType = sqlite3FindInIndex(pParse, pX, 0);
    iTab = pX->iTable;
    sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0);
    assert( pLevel->plan.wsFlags & WHERE_IN_ABLE );
    if( pLevel->u.in.nIn==0 ){







|

|
|
<
>
|

<







3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800

3801
3802
3803

3804
3805
3806
3807
3808
3809
3810
    iReg = iTarget;
    sqlite3VdbeAddOp2(v, OP_Null, 0, iReg);
#ifndef SQLITE_OMIT_SUBQUERY
  }else{
    int eType;
    int iTab;
    struct InLoop *pIn;
    u8 bRev = (pLevel->plan.wsFlags & WHERE_REVERSE)!=0;

    if( (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 
      && pLevel->plan.u.pIdx->aSortOrder[iEq]

    ){
      bRev = 1 - bRev;
    }

    assert( pX->op==TK_IN );
    iReg = iTarget;
    eType = sqlite3FindInIndex(pParse, pX, 0);
    iTab = pX->iTable;
    sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0);
    assert( pLevel->plan.wsFlags & WHERE_IN_ABLE );
    if( pLevel->u.in.nIn==0 ){