aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parse.y2
-rw-r--r--src/window.c9
2 files changed, 8 insertions, 3 deletions
diff --git a/src/parse.y b/src/parse.y
index 42efe6fb6..5c736c66e 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -1028,10 +1028,10 @@ expr(A) ::= id(X) LP distinct(D) exprlist(Y) RP
sqlite3ErrorMsg(pParse, "too many arguments on function %T", &X);
}
A = sqlite3ExprFunction(pParse, Y, &X);
- sqlite3WindowAttach(pParse, A, Z);
if( D==SF_Distinct && A ){
A->flags |= EP_Distinct;
}
+ sqlite3WindowAttach(pParse, A, Z);
}
expr(A) ::= id(X) LP STAR RP
%ifndef SQLITE_OMIT_WINDOWFUNC
diff --git a/src/window.c b/src/window.c
index 751e17d2a..b31ed156d 100644
--- a/src/window.c
+++ b/src/window.c
@@ -867,8 +867,13 @@ Window *sqlite3WindowAlloc(
*/
void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
if( p ){
- p->pWin = pWin;
- if( pWin ) pWin->pOwner = p;
+ if( pWin ){
+ p->pWin = pWin;
+ pWin->pOwner = p;
+ if( p->flags & EP_Distinct ){
+ sqlite3ErrorMsg(pParse,"DISTINCT is not supported for window functions");
+ }
+ }
}else{
sqlite3WindowDelete(pParse->db, pWin);
}