Fix a segfault caused by invoking a regular aggregate as a window-function.
And some problems with count(*) when used as a window-function.
FossilOrigin-Name: 4f3c8a82fd1c5b14d84f2301e34cfc8d52fe4b3a60840c39e895c11f2da529d9
diff --git a/src/resolve.c b/src/resolve.c
index b6389eb..7c1d4b1 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -758,7 +758,11 @@
}
#ifndef SQLITE_OMIT_WINDOWFUNC
- if( is_agg==0 && pExpr->pWin ){
+ 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 && pExpr->pWin ){
sqlite3ErrorMsg(pParse,
"%.*s() may not be used as a window function", nId, zId
);