1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

The OPFLAG_SEEKEQ optimization is only applicable to equality comparisons

against an index, not against a rowid table.

FossilOrigin-Name: 0f5b147d1fe83c34d0fbeacc7422be94d8441bc1
This commit is contained in:
drh
2015-11-07 01:19:00 +00:00
parent 3901692ede
commit d6b7946c32
3 changed files with 26 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
C Fix\sa\sharmless\ssanitizer\swarning\sin\sthe\sieee754\sextension. C The\sOPFLAG_SEEKEQ\soptimization\sis\sonly\sapplicable\sto\sequality\scomparisons\nagainst\san\sindex,\snot\sagainst\sa\srowid\stable.
D 2015-11-07T00:51:15.328 D 2015-11-07T01:19:00.997
F Makefile.in 3a705bb4bd12e194212ddbdbf068310d17153cdb F Makefile.in 3a705bb4bd12e194212ddbdbf068310d17153cdb
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4 F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4
@@ -403,7 +403,7 @@ F src/update.c 40e51cd0883cb5bfd6abb7d8a7cd8aa47fab2945
F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c
F src/util.c fc612367108b74573c5fd13a85d0a23027f438bd F src/util.c fc612367108b74573c5fd13a85d0a23027f438bd
F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701
F src/vdbe.c a9b0ec9f8df86a805d593b625d1f21a8e71dcda5 F src/vdbe.c 7a9b18027414368d800716e6319e2acd699c70db
F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637
F src/vdbeInt.h 33403622c6a8feaaac5f0f3f17f5d1bf6df42286 F src/vdbeInt.h 33403622c6a8feaaac5f0f3f17f5d1bf6df42286
F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca
@@ -1400,7 +1400,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P d741e1ccdce96e6142e294fbdd20a0282296dcea P dd9a26ecdeaef7b0b9cbf4ff70448ab13a276b4e
R 09ac306f39fb272ed95e60baefe78a45 R 37fd8f25666e5cc61c467cdb94b7bb71
U drh U drh
Z d2d47fc2f78320b8e866fa5d7ad2519b Z b3bf4f06c783a2156de71d3cb1963976

View File

@@ -1 +1 @@
dd9a26ecdeaef7b0b9cbf4ff70448ab13a276b4e 0f5b147d1fe83c34d0fbeacc7422be94d8441bc1

View File

@@ -3681,7 +3681,7 @@ case OP_SeekGT: { /* jump, in3 */
UnpackedRecord r; /* The key to seek for */ UnpackedRecord r; /* The key to seek for */
int nField; /* Number of columns or fields in the key */ int nField; /* Number of columns or fields in the key */
i64 iKey; /* The rowid we are to seek to */ i64 iKey; /* The rowid we are to seek to */
int eqOnly = 0; /* Only interested in == results */ int eqOnly; /* Only interested in == results */
assert( pOp->p1>=0 && pOp->p1<p->nCursor ); assert( pOp->p1>=0 && pOp->p1<p->nCursor );
assert( pOp->p2!=0 ); assert( pOp->p2!=0 );
@@ -3694,26 +3694,16 @@ case OP_SeekGT: { /* jump, in3 */
assert( pC->isOrdered ); assert( pC->isOrdered );
assert( pC->pCursor!=0 ); assert( pC->pCursor!=0 );
oc = pOp->opcode; oc = pOp->opcode;
eqOnly = 0;
pC->nullRow = 0; pC->nullRow = 0;
#ifdef SQLITE_DEBUG #ifdef SQLITE_DEBUG
pC->seekOp = pOp->opcode; pC->seekOp = pOp->opcode;
#endif #endif
/* For a cursor with the BTREE_SEEK_EQ hint, only the OP_SeekGE and
** OP_SeekLE opcodes are allowed, and these must be immediately followed
** by an OP_IdxGT or OP_IdxLT opcode, respectively, with the same key.
*/
if( sqlite3BtreeCursorHasHint(pC->pCursor, BTREE_SEEK_EQ) ){
eqOnly = 1;
assert( pOp->opcode==OP_SeekGE || pOp->opcode==OP_SeekLE );
assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
assert( pOp[1].p1==pOp[0].p1 );
assert( pOp[1].p2==pOp[0].p2 );
assert( pOp[1].p3==pOp[0].p3 );
assert( pOp[1].p4.i==pOp[0].p4.i );
}
if( pC->isTable ){ if( pC->isTable ){
/* The BTREE_SEEK_EQ flag is only set on index cursors */
assert( sqlite3BtreeCursorHasHint(pC->pCursor, BTREE_SEEK_EQ)==0 );
/* The input value in P3 might be of any type: integer, real, string, /* The input value in P3 might be of any type: integer, real, string,
** blob, or NULL. But it needs to be an integer before we can do ** blob, or NULL. But it needs to be an integer before we can do
** the seek, so convert it. */ ** the seek, so convert it. */
@@ -3761,8 +3751,21 @@ case OP_SeekGT: { /* jump, in3 */
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){
goto abort_due_to_error; goto abort_due_to_error;
} }
if( eqOnly && res ) goto seek_not_found;
}else{ }else{
/* For a cursor with the BTREE_SEEK_EQ hint, only the OP_SeekGE and
** OP_SeekLE opcodes are allowed, and these must be immediately followed
** by an OP_IdxGT or OP_IdxLT opcode, respectively, with the same key.
*/
if( sqlite3BtreeCursorHasHint(pC->pCursor, BTREE_SEEK_EQ) ){
eqOnly = 1;
assert( pOp->opcode==OP_SeekGE || pOp->opcode==OP_SeekLE );
assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
assert( pOp[1].p1==pOp[0].p1 );
assert( pOp[1].p2==pOp[0].p2 );
assert( pOp[1].p3==pOp[0].p3 );
assert( pOp[1].p4.i==pOp[0].p4.i );
}
nField = pOp->p4.i; nField = pOp->p4.i;
assert( pOp->p4type==P4_INT32 ); assert( pOp->p4type==P4_INT32 );
assert( nField>0 ); assert( nField>0 );