/ Check-in [3c1ae447]
Login

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

Overview
Comment:Reduce the number of cases where it is necessary to check for NULL after the loop terminating condition.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:3c1ae447dec8fc2af1c5105134061717594ac0e0
User & Date: drh 2014-02-14 20:59:53
Context
2014-02-14
23:49
Seek past NULLs in a top-constrained search. Avoid checking for NULLs in the body of the search. check-in: e07a32f3 user: drh tags: trunk
23:35
Better support for MinGW 4.x. check-in: e1472307 user: mistachkin tags: mingw4x
20:59
Reduce the number of cases where it is necessary to check for NULL after the loop terminating condition. check-in: 3c1ae447 user: drh tags: trunk
15:13
Add OP_IdxGT and OP_IdxLE as distinct opcodes. Formerly these operations where done using OP_IdxGE and OP_IdxLT with the P5 flag set. But VDBE code is easier to read with distinct opcode names. Also change OP_SeekGe to OP_SeekGE, and so forth, so that the capitalization is consistent. The whole point of this change is to improve the readability of VDBE listings. check-in: b6bea903 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/where.c.

3130
3131
3132
3133
3134
3135
3136
3137

3138
3139

3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
      testcase( op==OP_IdxGT );
      testcase( op==OP_IdxGE );
      testcase( op==OP_IdxLT );
      testcase( op==OP_IdxLE );
      sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
    }

    /* If there are inequality constraints, check that the value

    ** of the table column that the inequality contrains is not NULL.
    ** If it is, jump to the next iteration of the loop.

    */
    r1 = sqlite3GetTempReg(pParse);
    testcase( pLoop->wsFlags & WHERE_BTM_LIMIT );
    testcase( pLoop->wsFlags & WHERE_TOP_LIMIT );
    if( (pLoop->wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0 
     && (j = pIdx->aiColumn[nEq])>=0 
     && pIdx->pTable->aCol[j].notNull==0 
     && (nEq || (pLoop->wsFlags & WHERE_BTM_LIMIT)==0)
    ){
      sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1);
      VdbeComment((v, "%s", pIdx->pTable->aCol[j].zName));
      sqlite3VdbeAddOp2(v, OP_IsNull, r1, addrCont);
    }
    sqlite3ReleaseTempReg(pParse, r1);








|
>
|
<
>


<
<
|


<







3130
3131
3132
3133
3134
3135
3136
3137
3138
3139

3140
3141
3142


3143
3144
3145

3146
3147
3148
3149
3150
3151
3152
      testcase( op==OP_IdxGT );
      testcase( op==OP_IdxGE );
      testcase( op==OP_IdxLT );
      testcase( op==OP_IdxLE );
      sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
    }

    /* If there are inequality constraint upper bound but not a lower
    ** bound, then check that the value of the table column that the
    ** inequality contrains is not NULL since there is alway an implied

    ** lower bound of "column>NULL".
    */
    r1 = sqlite3GetTempReg(pParse);


    if( (pLoop->wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))==WHERE_TOP_LIMIT 
     && (j = pIdx->aiColumn[nEq])>=0 
     && pIdx->pTable->aCol[j].notNull==0 

    ){
      sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1);
      VdbeComment((v, "%s", pIdx->pTable->aCol[j].zName));
      sqlite3VdbeAddOp2(v, OP_IsNull, r1, addrCont);
    }
    sqlite3ReleaseTempReg(pParse, r1);