mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-18 10:21:03 +03:00
Do not assume that "col IS ?" matches at most a single row of a UNIQUE column unless the column is also NOT NULL.
FossilOrigin-Name: e038ce8955e785afcc07bb22499955bbd22a7af4
This commit is contained in:
@@ -6330,15 +6330,17 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){
|
||||
pLoop->rRun = 33; /* 33==sqlite3LogEst(10) */
|
||||
}else{
|
||||
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
|
||||
int opmask;
|
||||
assert( pLoop->aLTermSpace==pLoop->aLTerm );
|
||||
if( !IsUniqueIndex(pIdx)
|
||||
|| pIdx->pPartIdxWhere!=0
|
||||
|| pIdx->nKeyCol>ArraySize(pLoop->aLTermSpace)
|
||||
) continue;
|
||||
opmask = pIdx->uniqNotNull ? (WO_EQ|WO_IS) : WO_EQ;
|
||||
for(j=0; j<pIdx->nKeyCol; j++){
|
||||
pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ|WO_IS, pIdx);
|
||||
pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, opmask, pIdx);
|
||||
if( pTerm==0 ) break;
|
||||
testcase( pTerm->eOperator & WO_IS );
|
||||
testcase( pTerm->eOperator & WO_IS );
|
||||
pLoop->aLTerm[j] = pTerm;
|
||||
}
|
||||
if( j!=pIdx->nKeyCol ) continue;
|
||||
|
||||
Reference in New Issue
Block a user