mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-18 10:21:03 +03:00
Make sure that a GROUP BY that also implements an ORDER BY scans the table
in the correct order. Fix for ticket [ba7cbfaedc7e6]. FossilOrigin-Name: 7a32fdfd4be2138c0ab00f3dc6f54a70e4e07be4
This commit is contained in:
11
src/where.c
11
src/where.c
@@ -5360,7 +5360,7 @@ static i8 wherePathSatisfiesOrderBy(
|
||||
isMatch = 1;
|
||||
break;
|
||||
}
|
||||
if( isMatch && (pWInfo->wctrlFlags & WHERE_GROUPBY)==0 ){
|
||||
if( isMatch && (wctrlFlags & WHERE_GROUPBY)==0 ){
|
||||
/* Make sure the sort order is compatible in an ORDER BY clause.
|
||||
** Sort order is irrelevant for a GROUP BY clause. */
|
||||
if( revSet ){
|
||||
@@ -5825,12 +5825,15 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
|
||||
if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)
|
||||
&& pWInfo->nOBSat==pWInfo->pOrderBy->nExpr
|
||||
){
|
||||
Bitmask notUsed = 0;
|
||||
Bitmask revMask = 0;
|
||||
int nOrder = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy,
|
||||
pFrom, 0, nLoop-1, pFrom->aLoop[nLoop-1], ¬Used
|
||||
pFrom, 0, nLoop-1, pFrom->aLoop[nLoop-1], &revMask
|
||||
);
|
||||
assert( pWInfo->sorted==0 );
|
||||
pWInfo->sorted = (nOrder==pWInfo->pOrderBy->nExpr);
|
||||
if( nOrder==pWInfo->pOrderBy->nExpr ){
|
||||
pWInfo->sorted = 1;
|
||||
pWInfo->revMask = revMask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user