mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
Consider the affinity of "b" when using an "a IN (SELECT b ...)" expression with an index on "a". Fix for [199df416].
FossilOrigin-Name: f5e49855412e389a8a410db5d7ffb2e3634c5fa3
This commit is contained in:
@ -649,13 +649,21 @@ static int codeAllEqualityTerms(
|
||||
}
|
||||
testcase( pTerm->eOperator & WO_ISNULL );
|
||||
testcase( pTerm->eOperator & WO_IN );
|
||||
if( (pTerm->eOperator & (WO_ISNULL|WO_IN))==0 ){
|
||||
Expr *pRight = pTerm->pExpr->pRight;
|
||||
if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
|
||||
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
|
||||
VdbeCoverage(v);
|
||||
if( (pTerm->eOperator & WO_ISNULL)==0 ){
|
||||
Expr *pRight = 0;
|
||||
if( pTerm->eOperator & WO_IN ){
|
||||
if( pTerm->pExpr->flags & EP_xIsSelect ){
|
||||
int iField = pTerm->iField ? pTerm->iField-1 : 0;
|
||||
pRight = pTerm->pExpr->x.pSelect->pEList->a[iField].pExpr;
|
||||
}
|
||||
}else{
|
||||
pRight = pTerm->pExpr->pRight;
|
||||
if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
|
||||
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
|
||||
VdbeCoverage(v);
|
||||
}
|
||||
}
|
||||
if( zAff ){
|
||||
if( pRight && zAff ){
|
||||
if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){
|
||||
zAff[j] = SQLITE_AFF_BLOB;
|
||||
}
|
||||
|
Reference in New Issue
Block a user