diff options
author | drh <> | 2022-05-02 14:32:56 +0000 |
---|---|---|
committer | drh <> | 2022-05-02 14:32:56 +0000 |
commit | 3a45d30ea5eff2c17c5ee1561e12f0865ad75b3e (patch) | |
tree | 518e637f398b934091815aa9ddccf26b9a39cb3b /src/expr.c | |
parent | b94182bdc6235ce520322890d4b1567e6404d04f (diff) | |
download | sqlite-3a45d30ea5eff2c17c5ee1561e12f0865ad75b3e.tar.gz sqlite-3a45d30ea5eff2c17c5ee1561e12f0865ad75b3e.zip |
Improvement on check-in [a193749730d6cfba] so that the subroutine call to
the IN operator right-hand side generator from the RIGHT JOIN no-match logic
does not generate unreachable byte code.
FossilOrigin-Name: cc458317bd77046c4328715ae9e3409f3f4cd422a01162cb33405ef3a142b0a3
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/expr.c b/src/expr.c index f8ee68dc2..8e47578cc 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2743,12 +2743,17 @@ int sqlite3FindInIndex( ){ Select *p; /* SELECT to the right of IN operator */ int eType = 0; /* Type of RHS table. IN_INDEX_* */ - int iTab = pParse->nTab++; /* Cursor of the RHS table */ + int iTab; /* Cursor of the RHS table */ int mustBeUnique; /* True if RHS must be unique */ Vdbe *v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */ assert( pX->op==TK_IN ); mustBeUnique = (inFlags & IN_INDEX_LOOP)!=0; + if( pX->iTable && (inFlags & IN_INDEX_REUSE_CUR)!=0 ){ + iTab = pX->iTable; + }else{ + iTab = pParse->nTab++; + } /* If the RHS of this IN(...) operator is a SELECT, and if it matters ** whether or not the SELECT result contains NULL values, check whether @@ -3082,7 +3087,9 @@ void sqlite3CodeRhsOfIN( assert( ExprUseYSub(pExpr) ); sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn, pExpr->y.sub.iAddr); - sqlite3VdbeAddOp2(v, OP_OpenDup, iTab, pExpr->iTable); + if( iTab!=pExpr->iTable ){ + sqlite3VdbeAddOp2(v, OP_OpenDup, iTab, pExpr->iTable); + } sqlite3VdbeJumpHere(v, addrOnce); return; } |