aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-09-29 16:05:09 +0000
committerdrh <drh@noemail.net>2020-09-29 16:05:09 +0000
commitc40076a8cf32c0b54edc09a407d7d7c1c3ee9ae9 (patch)
treefaf47f14d159f8123e1cd69e66f8763626660d6f /src
parent46f0f4e56d8d818f417fa8f14ab4837133003b5d (diff)
downloadsqlite-c40076a8cf32c0b54edc09a407d7d7c1c3ee9ae9.tar.gz
sqlite-c40076a8cf32c0b54edc09a407d7d7c1c3ee9ae9.zip
Improved performance by manually in-lining the sqlite3VdbeIdxKeyCompare()
routine for the OP_IdxGT opcode and its kin. FossilOrigin-Name: 2206a2c848a122ee220c89427f9be0460cba0706f58852139d7b37184ce29a29
Diffstat (limited to 'src')
-rw-r--r--src/vdbe.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/vdbe.c b/src/vdbe.c
index ff1cf87cb..2f38a0b3a 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -6026,8 +6026,31 @@ case OP_IdxGE: { /* jump */
}
}
#endif
- res = 0; /* Not needed. Only used to silence a warning. */
- rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res);
+
+ /* Inlined version of sqlite3VdbeIdxKeyCompare() */
+ {
+ i64 nCellKey = 0;
+ BtCursor *pCur;
+ Mem m;
+
+ assert( pC->eCurType==CURTYPE_BTREE );
+ pCur = pC->uc.pCursor;
+ assert( sqlite3BtreeCursorIsValid(pCur) );
+ nCellKey = sqlite3BtreePayloadSize(pCur);
+ /* nCellKey will always be between 0 and 0xffffffff because of the way
+ ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */
+ if( nCellKey<=0 || nCellKey>0x7fffffff ){
+ rc = SQLITE_CORRUPT_BKPT;
+ goto abort_due_to_error;
+ }
+ sqlite3VdbeMemInit(&m, db, 0);
+ rc = sqlite3VdbeMemFromBtreeZeroOffset(pCur, (u32)nCellKey, &m);
+ if( rc ) goto abort_due_to_error;
+ res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, &r, 0);
+ sqlite3VdbeMemRelease(&m);
+ }
+ /* End of inlined sqlite3VdbeIdxKeyCompare() */
+
assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );
if( (pOp->opcode&1)==(OP_IdxLT&1) ){
assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxLT );
@@ -6037,7 +6060,7 @@ case OP_IdxGE: { /* jump */
res++;
}
VdbeBranchTaken(res>0,2);
- if( rc ) goto abort_due_to_error;
+ assert( rc==SQLITE_OK );
if( res>0 ) goto jump_to_p2;
break;
}