mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-18 10:21:03 +03:00
Fix the IN-early-out optimization so that it works even for the corner case
where the NULL bypass fires before the affinity of the LHS operator has been set. Fix for the problem described in [forum:/forumpost/6a3ec138e9|forum post 6a3ec138e9]. FossilOrigin-Name: eb40248ce606b792a02e4e0b7dd826a82891c5f4c9793f3ca5d332e593109525
This commit is contained in:
@@ -5435,6 +5435,8 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
int j;
|
||||
sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
|
||||
for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
|
||||
assert( sqlite3VdbeGetOp(v, pIn->addrInTop+1)->opcode==OP_IsNull
|
||||
|| pParse->db->mallocFailed );
|
||||
sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
|
||||
if( pIn->eEndLoopOp!=OP_Noop ){
|
||||
if( pIn->nPrefix ){
|
||||
@@ -5459,6 +5461,11 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
sqlite3VdbeCurrentAddr(v)+2,
|
||||
pIn->iBase, pIn->nPrefix);
|
||||
VdbeCoverage(v);
|
||||
/* Retarget the OP_IsNull against the left operand of IN so
|
||||
** it jumps past the OP_IfNoHope. This is because the
|
||||
** OP_IsNull also bypasses the OP_Affinity opcode that is
|
||||
** required by OP_IfNoHope. */
|
||||
sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
|
||||
}
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
|
||||
|
||||
Reference in New Issue
Block a user