1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-16 23:02:26 +03:00

Do not apply the optimization that omits DISTINCT if all result terms are

part of a UNIQUE index if the index is also a partial index.
Fix for the bug reported by
[forum:/forumpost/66954e9ece|forum post 66954e9ece].

FossilOrigin-Name: c2f940b02883e165172a4ca21c7095ffbef84ddc5367853dfeca93fda20d6056
This commit is contained in:
drh
2021-04-06 23:29:41 +00:00
parent a74364ae13
commit 204b634222
4 changed files with 18 additions and 8 deletions

View File

@@ -576,6 +576,7 @@ static int isDistinctRedundant(
*/
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
if( !IsUniqueIndex(pIdx) ) continue;
if( pIdx->pPartIdxWhere ) continue;
for(i=0; i<pIdx->nKeyCol; i++){
if( 0==sqlite3WhereFindTerm(pWC, iBase, i, ~(Bitmask)0, WO_EQ, pIdx) ){
if( findIndexCol(pParse, pDistinct, iBase, pIdx, i)<0 ) break;