diff options
author | drh <> | 2023-10-25 14:54:16 +0000 |
---|---|---|
committer | drh <> | 2023-10-25 14:54:16 +0000 |
commit | 8f99cb9ad69c8d423c4760fe67b78a0c01a1cff6 (patch) | |
tree | 2a52282347aaefc9991a4b2252f2ba780006a77d /src/expr.c | |
parent | a9a7d118f68d0209f99b03a5f6754f0218ea6019 (diff) | |
download | sqlite-8f99cb9ad69c8d423c4760fe67b78a0c01a1cff6.tar.gz sqlite-8f99cb9ad69c8d423c4760fe67b78a0c01a1cff6.zip |
When doing a DISTINCT aggregate that contains an ORDER BY, only the
arguments to the aggregate need to be distinct, not the ORDER BY terms.
FossilOrigin-Name: d2dbbdf7194bab4e5e3b74d3dbffb012a335829824c775c72dd7347c013d2125
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/expr.c b/src/expr.c index 010c8ce6a..e071c9690 100644 --- a/src/expr.c +++ b/src/expr.c @@ -6806,16 +6806,17 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ pItem->iOBTab = pParse->nTab++; pOBList = pExpr->pLeft->x.pList; assert( pOBList->nExpr>0 ); + assert( pItem->bOBUnique==0 ); if( pOBList->nExpr==1 && nArg==1 && sqlite3ExprCompare(0,pOBList->a[0].pExpr, pExpr->x.pList->a[0].pExpr,0)==0 ){ pItem->bOBPayload = 0; + pItem->bOBUnique = ExprHasProperty(pExpr, EP_Distinct); }else{ pItem->bOBPayload = 1; } - pItem->bOBUnique = ExprHasProperty(pExpr, EP_Distinct); }else{ pItem->iOBTab = -1; } |