mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-10 01:02:56 +03:00
Make sure all terms of the ORDER BY within an aggregate go through aggregate
analysis. Do not attach an aggregate ORDER BY to a window function. FossilOrigin-Name: 16f3805514a741405f70e0ee3b5a6b67720bc75719372e82daa4136fe411ea2b
This commit is contained in:
16
src/expr.c
16
src/expr.c
@@ -1181,6 +1181,16 @@ Expr *sqlite3ExprFunction(
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/*
|
||||
** Report an error when attempting to use an ORDER BY clause within
|
||||
** the arguments of a non-aggregate function.
|
||||
*/
|
||||
void sqlite3ExprOrderByAggregateError(Parse *pParse, Expr *p){
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"ORDER BY may not be used with non-aggregate %#T()", p
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
** Attach an ORDER BY clause to a function call.
|
||||
**
|
||||
@@ -1215,6 +1225,12 @@ void sqlite3ExprAddFunctionOrderBy(
|
||||
sqlite3ExprListDelete(db, pOrderBy);
|
||||
return;
|
||||
}
|
||||
if( IsWindowFunc(pExpr) ){
|
||||
sqlite3ExprOrderByAggregateError(pParse, pExpr);
|
||||
sqlite3ExprListDelete(db, pOrderBy);
|
||||
return;
|
||||
}
|
||||
|
||||
pOB = sqlite3ExprAlloc(db, TK_ORDER, 0, 0);
|
||||
if( pOB==0 ){
|
||||
sqlite3ExprListDelete(db, pOrderBy);
|
||||
|
Reference in New Issue
Block a user