Avoid having OP_SeekScan jump over an OP_IdxGT or OP_IdxGE that follows the OP_SeekGE opcode. Fix for [b50528af4468237c].
FossilOrigin-Name: c9c4f287652933eb6262a3419efe7e7288f55d3db7e2ac032eeae025f665d306
This commit is contained in:
+2
-11
@@ -1927,7 +1927,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
|
||||
** guess. */
|
||||
addrSeekScan = sqlite3VdbeAddOp1(v, OP_SeekScan,
|
||||
(pIdx->aiRowLogEst[0]+9)/10);
|
||||
if( pRangeStart ){
|
||||
if( pRangeStart || pRangeEnd ){
|
||||
sqlite3VdbeChangeP5(v, 1);
|
||||
sqlite3VdbeChangeP2(v, addrSeekScan, sqlite3VdbeCurrentAddr(v)+1);
|
||||
addrSeekScan = 0;
|
||||
@@ -1968,16 +1968,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
|
||||
assert( pLevel->p2==0 );
|
||||
if( pRangeEnd ){
|
||||
Expr *pRight = pRangeEnd->pExpr->pRight;
|
||||
if( addrSeekScan ){
|
||||
/* For a seek-scan that has a range on the lowest term of the index,
|
||||
** we have to make the top of the loop be code that sets the end
|
||||
** condition of the range. Otherwise, the OP_SeekScan might jump
|
||||
** over that initialization, leaving the range-end value set to the
|
||||
** range-start value, resulting in a wrong answer.
|
||||
** See ticket 5981a8c041a3c2f3 (2021-11-02).
|
||||
*/
|
||||
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
|
||||
}
|
||||
assert( addrSeekScan==0 );
|
||||
codeExprOrVector(pParse, pRight, regBase+nEq, nTop);
|
||||
whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
|
||||
if( (pRangeEnd->wtFlags & TERM_VNULL)==0
|
||||
|
||||
Reference in New Issue
Block a user