1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-09-09 21:09:38 +03:00

Add tests for the FILTER clause. And a bugfix.

FossilOrigin-Name: 28aa1702f7f0334abd1b30e7aa48ea3679539b11bfbba32bc9f0d6049cf18a7b
This commit is contained in:
dan
2019-07-03 18:31:20 +00:00
parent 6ba7ab0d25
commit 16e12c573d
6 changed files with 150 additions and 19 deletions

View File

@@ -826,22 +826,23 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
if( 0==IN_RENAME_OBJECT ){
#ifndef SQLITE_OMIT_WINDOWFUNC
int is_win = ExprHasProperty(pExpr, EP_WinFunc);
assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
|| (pDef->xValue==0 && pDef->xInverse==0)
|| (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
);
if( pDef && pDef->xValue==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
if( pDef && pDef->xValue==0 && is_win ){
sqlite3ErrorMsg(pParse,
"%.*s() may not be used as a window function", nId, zId
);
pNC->nErr++;
}else if(
(is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
|| (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pExpr->y.pWin)
|| (is_agg && pExpr->y.pWin && (pNC->ncFlags & NC_AllowWin)==0)
|| (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !is_win)
|| (is_agg && is_win && (pNC->ncFlags & NC_AllowWin)==0)
){
const char *zType;
if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->y.pWin ){
if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || is_win ){
zType = "window";
}else{
zType = "aggregate";
@@ -880,7 +881,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
** Or arguments of other window functions. But aggregate functions
** may be arguments for window functions. */
#ifndef SQLITE_OMIT_WINDOWFUNC
pNC->ncFlags &= ~(NC_AllowWin | (!pExpr->y.pWin ? NC_AllowAgg : 0));
pNC->ncFlags &= ~(NC_AllowWin | (!is_win ? NC_AllowAgg : 0));
#else
pNC->ncFlags &= ~NC_AllowAgg;
#endif