1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-18 10:21:03 +03:00

Add new interfaces to enable virtual table to process IN operator constraints

all at once, rather than one element at a time.

FossilOrigin-Name: eb84b80e1f6d8c32bf0c9e1731f0233de0160a13f714f766779ae01fdf504e7b
This commit is contained in:
drh
2022-02-01 14:58:29 +00:00
parent e66532a63b
commit 0fe7e7d924
12 changed files with 277 additions and 28 deletions

View File

@@ -1532,8 +1532,15 @@ Bitmask sqlite3WhereCodeOneLoopStart(
pTerm = pLoop->aLTerm[j];
if( NEVER(pTerm==0) ) continue;
if( pTerm->eOperator & WO_IN ){
codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);
addrNotFound = pLevel->addrNxt;
if( SMASKBIT32(j) & pLoop->u.vtab.mHandleIn ){
int iTab = pParse->nTab++;
int iCache = ++pParse->nMem;
sqlite3CodeRhsOfIN(pParse, pTerm->pExpr, iTab);
sqlite3VdbeAddOp3(v, OP_VInitIn, iTab, iTarget, iCache);
}else{
codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);
addrNotFound = pLevel->addrNxt;
}
}else{
Expr *pRight = pTerm->pExpr->pRight;
codeExprOrVector(pParse, pRight, iTarget, 1);
@@ -1568,13 +1575,19 @@ Bitmask sqlite3WhereCodeOneLoopStart(
iIn = 0;
}
for(j=nConstraint-1; j>=0; j--){
int bIn; /* True to generate byte code to loop over RHS IN values */
pTerm = pLoop->aLTerm[j];
if( (pTerm->eOperator & WO_IN)!=0 ) iIn--;
if( (pTerm->eOperator & WO_IN)!=0
&& (SMASKBIT32(j) & pLoop->u.vtab.mHandleIn)==0
){
bIn = 1;
}else{
bIn = 0;
}
if( bIn ) iIn--;
if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
disableTerm(pLevel, pTerm);
}else if( (pTerm->eOperator & WO_IN)!=0
&& sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1
){
}else if( bIn && sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1 ){
Expr *pCompare; /* The comparison operator */
Expr *pRight; /* RHS of the comparison */
VdbeOp *pOp; /* Opcode to access the value of the IN constraint */