1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Experimental implementation of FILTER clause for aggregate functions.

FossilOrigin-Name: 1f1ae2d6ac8dcbb62e5aa3dc17bc67d559cb565fc0d0a8c00a596075d35f8130
This commit is contained in:
dan
2019-07-02 11:56:47 +00:00
parent 00a6153faf
commit 6ba7ab0d25
12 changed files with 342 additions and 45 deletions

View File

@@ -1178,13 +1178,10 @@ void sqlite3WindowChain(Parse *pParse, Window *pWin, Window *pList){
/*
** Attach window object pWin to expression p.
*/
void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
void sqlite3WindowAttach(Parse *pParse, Expr *p, Expr *pFilter, Window *pWin){
if( p ){
assert( p->op==TK_FUNCTION );
/* This routine is only called for the parser. If pWin was not
** allocated due to an OOM, then the parser would fail before ever
** invoking this routine */
if( ALWAYS(pWin) ){
if( pWin ){
p->y.pWin = pWin;
ExprSetProperty(p, EP_WinFunc);
pWin->pOwner = p;
@@ -1192,9 +1189,14 @@ void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
sqlite3ErrorMsg(pParse,
"DISTINCT is not supported for window functions");
}
pWin->pFilter = pFilter;
}else if( pFilter ){
p->y.pFilter = pFilter;
ExprSetProperty(p, EP_Filter);
}
}else{
sqlite3WindowDelete(pParse->db, pWin);
sqlite3ExprDelete(pParse->db, pFilter);
}
}