1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Fix handling of window frames containing negative number of rows. e.g. "ROWS x

PRECEDING AND y PRECEDING" where (x<y).

FossilOrigin-Name: b6d9c7eda853420ae46a05bd432711e8bf9ebaa448c7d90ccfc0bcc338a87706
This commit is contained in:
dan
2018-06-11 18:16:51 +00:00
parent 72a9f0233b
commit 26522d1c45
7 changed files with 146 additions and 21 deletions

View File

@@ -756,11 +756,24 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
NC_IdxExpr|NC_PartIdx);
}
}
if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
|| (pExpr->pWin && (pNC->ncFlags & NC_AllowWin)==0)
if( is_agg==0 && pExpr->pWin ){
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->pWin)
|| (is_agg && pExpr->pWin && (pNC->ncFlags & NC_AllowWin)==0)
){
const char *zType = pExpr->pWin ? "window" : "aggregate";
sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
const char *zType;
if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->pWin ){
zType = "window";
}else{
zType = "aggregate";
}
sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()", zType, nId,zId);
pNC->nErr++;
is_agg = 0;
}else if( no_such_func && pParse->db->init.busy==0