mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-24 22:22:08 +03:00
Change the way TK_SELECT_COLUMN is handled so that the subquery is only
generated once even if part of the vector comparison is used for indexing and the other part is now. This change also is a pathway to vector assignment in UPDATE statements. FossilOrigin-Name: d8feea7dcde83179bff303072426561cfe825e58
This commit is contained in:
@ -377,34 +377,7 @@ static int codeEqualityTerm(
|
||||
assert( pLevel->pWLoop->aLTerm[iEq]==pTerm );
|
||||
assert( iTarget>0 );
|
||||
if( pX->op==TK_EQ || pX->op==TK_IS ){
|
||||
Expr *pRight = pX->pRight;
|
||||
#ifndef SQLITE_OMIT_SUBQUERY
|
||||
if( pRight->op==TK_SELECT_COLUMN ){
|
||||
/* This case occurs for expressions like "(a, b) == (SELECT ...)". */
|
||||
WhereLoop *pLoop = pLevel->pWLoop;
|
||||
int i;
|
||||
Expr *pSub = pRight->pLeft;
|
||||
assert( pSub->op==TK_SELECT );
|
||||
for(i=pLoop->nSkip; i<iEq; i++){
|
||||
Expr *pExpr = pLoop->aLTerm[i]->pExpr->pRight;
|
||||
if( pExpr && pExpr->op==TK_SELECT_COLUMN && pExpr->pLeft==pSub ) break;
|
||||
}
|
||||
|
||||
if( i==iEq ){
|
||||
iReg = sqlite3CodeSubselect(pParse, pSub, 0, 0);
|
||||
for(/*no-op*/; i<pLoop->nLTerm; i++){
|
||||
Expr *pExpr = pLoop->aLTerm[i]->pExpr->pRight;
|
||||
if( pExpr && pExpr->op==TK_SELECT_COLUMN && pExpr->pLeft==pSub ){
|
||||
sqlite3VdbeAddOp2(v, OP_Copy, iReg+pExpr->iColumn, iTarget-iEq+i);
|
||||
}
|
||||
}
|
||||
}
|
||||
iReg = iTarget;
|
||||
}else
|
||||
#endif
|
||||
{
|
||||
iReg = sqlite3ExprCodeTarget(pParse, pRight, iTarget);
|
||||
}
|
||||
iReg = sqlite3ExprCodeTarget(pParse, pX->pRight, iTarget);
|
||||
}else if( pX->op==TK_ISNULL ){
|
||||
iReg = iTarget;
|
||||
sqlite3VdbeAddOp2(v, OP_Null, 0, iReg);
|
||||
@ -1101,11 +1074,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
|
||||
addrNotFound = pLevel->addrNxt;
|
||||
}else{
|
||||
Expr *pRight = pTerm->pExpr->pRight;
|
||||
if( pRight->op==TK_SELECT_COLUMN ){
|
||||
codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);
|
||||
}else{
|
||||
codeExprOrVector(pParse, pRight, iTarget, 1);
|
||||
}
|
||||
codeExprOrVector(pParse, pRight, iTarget, 1);
|
||||
}
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);
|
||||
|
Reference in New Issue
Block a user