aboutsummaryrefslogtreecommitdiff
path: root/src/select.c
diff options
context:
space:
mode:
authordan <Dan Kennedy>2021-04-03 19:23:59 +0000
committerdan <Dan Kennedy>2021-04-03 19:23:59 +0000
commitf330d53ff32f33ebe77d40dd70ad7712f317e8a8 (patch)
tree23beb04e46e7c3c7a815c9a776843db418485cee /src/select.c
parent9af69ff547d76f1f8c7c4513fdb6c0ca1a32f9fc (diff)
downloadsqlite-f330d53ff32f33ebe77d40dd70ad7712f317e8a8.tar.gz
sqlite-f330d53ff32f33ebe77d40dd70ad7712f317e8a8.zip
Fix a crash in handling queries of the form "SELECT aggregate(DISTINCT tbl.col) FROM ... LEFT JOIN tbl ...". Fixes a problem introduced by [ef4ac0ddd297bbd3].
FossilOrigin-Name: 0dcf808ddf23da834da724d88b1715ed06565f1f1290713ff42a3fcf6ffb802e
Diffstat (limited to 'src/select.c')
-rw-r--r--src/select.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/select.c b/src/select.c
index c6b36b683..7c84bd7d6 100644
--- a/src/select.c
+++ b/src/select.c
@@ -6856,7 +6856,7 @@ int sqlite3Select(
pExpr = sqlite3ExprDup(db, pExpr, 0);
pDistinct = sqlite3ExprListDup(db, pGroupBy, 0);
pDistinct = sqlite3ExprListAppend(pParse, pDistinct, pExpr);
- distFlag = pDistinct ? WHERE_WANT_DISTINCT : 0;
+ distFlag = pDistinct ? (WHERE_WANT_DISTINCT|WHERE_AGG_DISTINCT) : 0;
}
/* If there is a GROUP BY clause we might need a sorting index to
@@ -7169,7 +7169,7 @@ int sqlite3Select(
}
}else if( pAggInfo->nFunc==1 && pAggInfo->aFunc[0].iDistinct>=0 ){
pDistinct = pAggInfo->aFunc[0].pFExpr->x.pList;
- distFlag = pDistinct ? WHERE_WANT_DISTINCT : 0;
+ distFlag = pDistinct ? (WHERE_WANT_DISTINCT|WHERE_AGG_DISTINCT) : 0;
}
/* This case runs if the aggregate has no GROUP BY clause. The