mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-15 11:41:13 +03:00
Suppress unnecessary OP_Noop instructions on when the right table of a
LEFT JOIN uses the index-only optimization. FossilOrigin-Name: e8aec08bee1c8d593474561898037aed571e64ce
This commit is contained in:
12
src/where.c
12
src/where.c
@@ -3944,7 +3944,11 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
if( pLevel->iLeftJoin ){
|
||||
int addr;
|
||||
addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin);
|
||||
sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);
|
||||
assert( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0
|
||||
|| (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 );
|
||||
if( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0 ){
|
||||
sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);
|
||||
}
|
||||
if( pLevel->iIdxCur>=0 ){
|
||||
sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
|
||||
}
|
||||
@@ -3995,7 +3999,6 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
int k, j, last;
|
||||
VdbeOp *pOp;
|
||||
Index *pIdx = pLevel->plan.u.pIdx;
|
||||
int useIndexOnly = pLevel->plan.wsFlags & WHERE_IDX_ONLY;
|
||||
|
||||
assert( pIdx!=0 );
|
||||
pOp = sqlite3VdbeGetOp(v, pWInfo->iTop);
|
||||
@@ -4010,12 +4013,11 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(!useIndexOnly || j<pIdx->nColumn);
|
||||
assert( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0
|
||||
|| j<pIdx->nColumn );
|
||||
}else if( pOp->opcode==OP_Rowid ){
|
||||
pOp->p1 = pLevel->iIdxCur;
|
||||
pOp->opcode = OP_IdxRowid;
|
||||
}else if( pOp->opcode==OP_NullRow && useIndexOnly ){
|
||||
pOp->opcode = OP_Noop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user