diff options
author | drh <drh@noemail.net> | 2016-12-18 17:42:00 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-12-18 17:42:00 +0000 |
commit | f99dd359d00fd5af78d8ccb4b7c27fc82f578ddb (patch) | |
tree | 008f571f1ff819a7f2bede0443f4ec08f064b8d8 /src | |
parent | 22d709dd911129e2e657d0f6e6bd132ea5f3b0a4 (diff) | |
download | sqlite-f99dd359d00fd5af78d8ccb4b7c27fc82f578ddb.tar.gz sqlite-f99dd359d00fd5af78d8ccb4b7c27fc82f578ddb.zip |
Change the OP_IfNotZero opcode so that it decrements register P1 by 1 rather
than the value in P3, and so that it only decrements if originally positive.
This avoids decrementing the smallest 64-bit signed integer.
FossilOrigin-Name: 165c044686212fbf7182dd560ad1e57eb4cc9838
Diffstat (limited to 'src')
-rw-r--r-- | src/select.c | 2 | ||||
-rw-r--r-- | src/vdbe.c | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/select.c b/src/select.c index 18344b7d4..e5f4c7fcd 100644 --- a/src/select.c +++ b/src/select.c @@ -596,7 +596,7 @@ static void pushOntoSorter( ** register is initialized with value of LIMIT+OFFSET.) After the sorter ** fills up, delete the least entry in the sorter after each insert. ** Thus we never hold more than the LIMIT+OFFSET rows in memory at once */ - addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, 1); VdbeCoverage(v); + addr = sqlite3VdbeAddOp1(v, OP_IfNotZero, iLimit); VdbeCoverage(v); sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor); if( pSort->bOrderedInnerLoop ){ r1 = ++pParse->nMem; diff --git a/src/vdbe.c b/src/vdbe.c index 6ccd746ef..0935e8763 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6012,20 +6012,20 @@ case OP_OffsetLimit: { /* in1, out2, in3 */ break; } -/* Opcode: IfNotZero P1 P2 P3 * * -** Synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 +/* Opcode: IfNotZero P1 P2 * * * +** Synopsis: if r[P1]!=0 then r[P1]--, goto P2 ** ** Register P1 must contain an integer. If the content of register P1 is -** initially nonzero, then subtract P3 from the value in register P1 and -** jump to P2. If register P1 is initially zero, leave it unchanged -** and fall through. +** initially greater than zero, then decrement the value in register P1. +** If it is non-zero (negative or positive) and then also jump to P2. +** If register P1 is initially zero, leave it unchanged and fall through. */ case OP_IfNotZero: { /* jump, in1 */ pIn1 = &aMem[pOp->p1]; assert( pIn1->flags&MEM_Int ); VdbeBranchTaken(pIn1->u.i<0, 2); if( pIn1->u.i ){ - pIn1->u.i -= pOp->p3; + if( pIn1->u.i>0 ) pIn1->u.i--; goto jump_to_p2; } break; |