mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
Update the omit-left-join optimization so that it works in some cases when the
RHS is subject to a UNIQUE but not NOT NULL constraint. FossilOrigin-Name: 88411a402b29f19d69e0d06d9099eabb98c238ddb7c07ce110236316f008753e
This commit is contained in:
10
src/where.c
10
src/where.c
@@ -2481,10 +2481,13 @@ static int whereLoopAddBtreeIndex(
|
||||
if( iCol==XN_ROWID
|
||||
|| (iCol>=0 && nInMul==0 && saved_nEq==pProbe->nKeyCol-1)
|
||||
){
|
||||
if( iCol>=0 && pProbe->uniqNotNull==0 ){
|
||||
pNew->wsFlags |= WHERE_UNQ_WANTED;
|
||||
}else{
|
||||
assert( iCol!=XN_ROWID || pProbe->uniqNotNull );
|
||||
if( pProbe->uniqNotNull
|
||||
|| (pProbe->nKeyCol==1 && pProbe->onError && eOp==WO_EQ)
|
||||
){
|
||||
pNew->wsFlags |= WHERE_ONEROW;
|
||||
}else{
|
||||
pNew->wsFlags |= WHERE_UNQ_WANTED;
|
||||
}
|
||||
}
|
||||
}else if( eOp & WO_ISNULL ){
|
||||
@@ -2825,6 +2828,7 @@ static int whereLoopAddBtree(
|
||||
sPk.onError = OE_Replace;
|
||||
sPk.pTable = pTab;
|
||||
sPk.szIdxRow = pTab->szTabRow;
|
||||
sPk.uniqNotNull = 1;
|
||||
aiRowEstPk[0] = pTab->nRowLogEst;
|
||||
aiRowEstPk[1] = 0;
|
||||
pFirst = pSrc->pTab->pIndex;
|
||||
|
||||
Reference in New Issue
Block a user