diff options
author | drh <drh@noemail.net> | 2018-06-07 14:59:22 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-06-07 14:59:22 +0000 |
commit | f7b0a5f3c369d2e2d3d3c51a1f45203fe7841eb6 (patch) | |
tree | 5b80550d25ba7c9d7fdb92dbf4a4ef0803cef505 /src | |
parent | bd573c459b7170b979d73655c50e0e946f388169 (diff) | |
download | sqlite-f7b0a5f3c369d2e2d3d3c51a1f45203fe7841eb6.tar.gz sqlite-f7b0a5f3c369d2e2d3d3c51a1f45203fe7841eb6.zip |
Add the WHERE_IN_EARLYOUT flag and use it to clarify the logic of this
optimization.
FossilOrigin-Name: 522f1eacc20f11002cad58232a7c2610f369568653510e54f46088f579f778dc
Diffstat (limited to 'src')
-rw-r--r-- | src/where.c | 1 | ||||
-rw-r--r-- | src/whereInt.h | 1 | ||||
-rw-r--r-- | src/wherecode.c | 5 |
3 files changed, 5 insertions, 2 deletions
diff --git a/src/where.c b/src/where.c index bfb848f42..8499d16e7 100644 --- a/src/where.c +++ b/src/where.c @@ -5084,6 +5084,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ sqlite3VdbeJumpHere(v, pIn->addrInTop+1); if( pIn->eEndLoopOp!=OP_Noop ){ if( pIn->nPrefix ){ + assert( pLoop->wsFlags & WHERE_IN_EARLYOUT ); sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur, sqlite3VdbeCurrentAddr(v)+2, pIn->iBase, pIn->nPrefix); diff --git a/src/whereInt.h b/src/whereInt.h index 08159fe28..5028793bb 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -557,3 +557,4 @@ void sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*); #define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */ #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/ #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */ +#define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */ diff --git a/src/wherecode.c b/src/wherecode.c index a20a9808e..03c3b78ae 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -595,6 +595,7 @@ static int codeEqualityTerm( if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){ pIn->iBase = iReg - i; pIn->nPrefix = i; + pLoop->wsFlags |= WHERE_IN_EARLYOUT; }else{ pIn->nPrefix = 0; } @@ -1664,7 +1665,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( ** above has already left the cursor sitting on the correct row, ** so no further seeking is needed */ }else{ - if( pLoop->wsFlags & WHERE_IN_ABLE ){ + if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){ sqlite3VdbeAddOp1(v, OP_SeekHit, iIdxCur); } op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev]; @@ -1730,7 +1731,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE ); } - if( pLoop->wsFlags & WHERE_IN_ABLE ){ + if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){ sqlite3VdbeAddOp2(v, OP_SeekHit, iIdxCur, 1); } |