aboutsummaryrefslogtreecommitdiff
path: root/src/wherecode.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2018-06-07 20:35:28 +0000
committerdan <dan@noemail.net>2018-06-07 20:35:28 +0000
commit07509f8c1edce1378cb71e16b605ece614bd198d (patch)
treef4120ffe956aaac84d31faa7f5d3211eb08467aa /src/wherecode.c
parentfe4e25a0f6b9bdb7f8cd165497fd7341fa3e8691 (diff)
parent83193d0133328a28dbd4d4bbd1f9747158d253a2 (diff)
downloadsqlite-07509f8c1edce1378cb71e16b605ece614bd198d.tar.gz
sqlite-07509f8c1edce1378cb71e16b605ece614bd198d.zip
Merge latest trunk changes with this branch.
FossilOrigin-Name: 251022034219819a1dc356542770ff46e3147a080f072eb20af6106771dadd92
Diffstat (limited to 'src/wherecode.c')
-rw-r--r--src/wherecode.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/wherecode.c b/src/wherecode.c
index c9edab7b0..67f5e3073 100644
--- a/src/wherecode.c
+++ b/src/wherecode.c
@@ -591,7 +591,14 @@ static int codeEqualityTerm(
sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v);
if( i==iEq ){
pIn->iCur = iTab;
- pIn->eEndLoopOp = bRev ? OP_PrevIfOpen : OP_NextIfOpen;
+ pIn->eEndLoopOp = bRev ? OP_Prev : OP_Next;
+ if( iEq>0 && (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){
+ pIn->iBase = iReg - i;
+ pIn->nPrefix = i;
+ pLoop->wsFlags |= WHERE_IN_EARLYOUT;
+ }else{
+ pIn->nPrefix = 0;
+ }
}else{
pIn->eEndLoopOp = OP_Noop;
}
@@ -1658,6 +1665,9 @@ 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_EARLYOUT ){
+ sqlite3VdbeAddOp1(v, OP_SeekHit, iIdxCur);
+ }
op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
assert( op!=0 );
sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
@@ -1721,6 +1731,10 @@ Bitmask sqlite3WhereCodeOneLoopStart(
testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
}
+ if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){
+ sqlite3VdbeAddOp2(v, OP_SeekHit, iIdxCur, 1);
+ }
+
/* Seek the table cursor, if required */
if( omitTable ){
/* pIdx is a covering index. No need to access the main table. */