diff options
author | drh <drh@noemail.net> | 2019-08-23 13:32:03 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-08-23 13:32:03 +0000 |
commit | ec3dda5b11f527c69f1007fa60ba2765e0a5628b (patch) | |
tree | 855f6a265650aa711e4de216877b1e15a397f042 /src | |
parent | 74e1b861ad749a00966583c29f0e2d8dfb510c82 (diff) | |
download | sqlite-ec3dda5b11f527c69f1007fa60ba2765e0a5628b.tar.gz sqlite-ec3dda5b11f527c69f1007fa60ba2765e0a5628b.zip |
Invert the meaning of the regBignull flag so that it is 1 when doing the
normal scan and 1 when scanning nulls. This enables the re-do jump at the
bottom of the loop to be coded with a single OP_IfNotZero opcode, rather
than a sequence of OP_If, OP_Integer, OP_Goto.
FossilOrigin-Name: bf875e1a259a4167694e06349458452dc36c1d38aa6843518d9ae46ce74e5559
Diffstat (limited to 'src')
-rw-r--r-- | src/where.c | 8 | ||||
-rw-r--r-- | src/whereInt.h | 2 | ||||
-rw-r--r-- | src/wherecode.c | 12 |
3 files changed, 8 insertions, 14 deletions
diff --git a/src/where.c b/src/where.c index 00aa5f366..1dbeb0e06 100644 --- a/src/where.c +++ b/src/where.c @@ -5218,13 +5218,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ VdbeCoverageIf(v, pLevel->op==OP_VNext); if( pLevel->regBignull ){ sqlite3VdbeResolveLabel(v, pLevel->addrBignull); - addr = sqlite3VdbeAddOp1(v, OP_If, pLevel->regBignull); - VdbeComment((v, "If NULL-scan done")); - VdbeCoverage(v); - sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->regBignull); - sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->p2-1); - VdbeComment((v, "Do the NULL-scan")); - sqlite3VdbeJumpHere(v, addr); + sqlite3VdbeAddOp2(v, OP_IfNotZero, pLevel->regBignull, pLevel->p2-1); } #ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT if( addrSeek ) sqlite3VdbeJumpHere(v, addrSeek); diff --git a/src/whereInt.h b/src/whereInt.h index d1fc3515a..e63ca46d5 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -71,7 +71,7 @@ struct WhereLevel { int addrCont; /* Jump here to continue with the next loop cycle */ int addrFirst; /* First instruction of interior of the loop */ int addrBody; /* Beginning of the body of this loop */ - int regBignull; /* big-null flag reg. True if NULLs not yet scanned */ + int regBignull; /* big-null flag reg. True if a NULL-scan is needed */ int addrBignull; /* Jump here for next part of big-null scan */ #ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */ diff --git a/src/wherecode.c b/src/wherecode.c index 12ed0d7af..2aff70554 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1690,8 +1690,8 @@ Bitmask sqlite3WhereCodeOneLoopStart( sqlite3VdbeAddOp1(v, OP_SeekHit, iIdxCur); } if( regBignull ){ - sqlite3VdbeAddOp2(v, OP_Integer, 0, regBignull); - VdbeComment((v, "NULL-scan flag")); + sqlite3VdbeAddOp2(v, OP_Integer, 1, regBignull); + VdbeComment((v, "NULL-scan needed flag")); } op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev]; @@ -1776,8 +1776,8 @@ Bitmask sqlite3WhereCodeOneLoopStart( /* Check if the index cursor is past the end of the range. */ if( nConstraint ){ if( regBignull ){ - sqlite3VdbeAddOp2(v, OP_If, regBignull, sqlite3VdbeCurrentAddr(v)+3); - VdbeComment((v, "If in NULL-scan")); + sqlite3VdbeAddOp2(v, OP_IfNot, regBignull, sqlite3VdbeCurrentAddr(v)+3); + VdbeComment((v, "If NULL-scan active")); VdbeCoverage(v); } op = aEndOp[bRev*2 + endEq]; @@ -1788,8 +1788,8 @@ Bitmask sqlite3WhereCodeOneLoopStart( testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE ); } if( regBignull ){ - sqlite3VdbeAddOp2(v, OP_IfNot, regBignull, sqlite3VdbeCurrentAddr(v)+2); - VdbeComment((v, "If not in NULL-scan")); + sqlite3VdbeAddOp2(v, OP_If, regBignull, sqlite3VdbeCurrentAddr(v)+2); + VdbeComment((v, "If NULL-scan pending")); VdbeCoverage(v); if( bStopAtNull ){ op = aEndOp[bRev*2 + 0]; |