mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-10 01:02:56 +03:00
Fix the indexed expression resolver for generated columns so that it picks
the correct table in a self-join. FossilOrigin-Name: 54c3eb085aca92da2b819f3532ee4750b377265f7e1e914600ea3c3d535efe51
This commit is contained in:
20
src/expr.c
20
src/expr.c
@@ -4057,8 +4057,13 @@ static SQLITE_NOINLINE int sqlite3IndexedExprLookup(
|
||||
IndexedExpr *p;
|
||||
Vdbe *v;
|
||||
for(p=pParse->pIdxExpr; p; p=p->pIENext){
|
||||
if( p->iDataCur<0 ) continue;
|
||||
if( sqlite3ExprCompare(0, pExpr, p->pExpr, p->iDataCur)!=0 ) continue;
|
||||
int iDataCur = p->iDataCur;
|
||||
if( iDataCur<0 ) continue;
|
||||
if( pParse->iSelfTab ){
|
||||
if( p->iDataCur!=pParse->iSelfTab-1 ) continue;
|
||||
iDataCur = -1;
|
||||
}
|
||||
if( sqlite3ExprCompare(0, pExpr, p->pExpr, iDataCur)!=0 ) continue;
|
||||
v = pParse->pVdbe;
|
||||
assert( v!=0 );
|
||||
if( p->bMaybeNullRow ){
|
||||
@@ -4108,17 +4113,14 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||
assert( target>0 && target<=pParse->nMem );
|
||||
assert( v!=0 );
|
||||
|
||||
if( pParse->pIdxExpr!=0
|
||||
&& pExpr!=0
|
||||
expr_code_doover:
|
||||
if( pExpr==0 ){
|
||||
op = TK_NULL;
|
||||
}else if( pParse->pIdxExpr!=0
|
||||
&& !ExprHasProperty(pExpr, EP_Leaf)
|
||||
&& (r1 = sqlite3IndexedExprLookup(pParse, pExpr, target))>=0
|
||||
){
|
||||
return r1;
|
||||
}
|
||||
|
||||
expr_code_doover:
|
||||
if( pExpr==0 ){
|
||||
op = TK_NULL;
|
||||
}else{
|
||||
assert( !ExprHasVVAProperty(pExpr,EP_Immutable) );
|
||||
op = pExpr->op;
|
||||
|
Reference in New Issue
Block a user