aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2018-07-10 07:25:42 +0000
committerdrh <drh@noemail.net>2018-07-10 07:25:42 +0000
commit38630ae1de36db73c4610348592bf616ac116529 (patch)
tree04f96989387101d5865258cafa3814540327c9f5 /src/expr.c
parent6cbb4c936c39acceb7a2181037f2d6e33badc32e (diff)
downloadsqlite-38630ae1de36db73c4610348592bf616ac116529.tar.gz
sqlite-38630ae1de36db73c4610348592bf616ac116529.zip
Assert that if two functions compare equal in every other way, then they
must both have OVER clauses, or neither has an OVER clause. Use this fact to simplify expression comparison. FossilOrigin-Name: 52559ad58ce412af40f1f34e80bfe9fadc6a93f3ca0cfaf69f94d615bbb99831
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/expr.c b/src/expr.c
index 10a1dc67f..a329ef413 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -4952,11 +4952,18 @@ int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){
&& (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
}
#ifndef SQLITE_OMIT_WINDOWFUNC
+ /* Justification for the assert():
+ /* window functions have p->op==TK_FUNCTION but aggregate functions
+ ** have p->op==TK_AGG_FUNCTION. So any comparison between an aggregate
+ ** function and a window function should have failed before reaching
+ ** this point. And, it is not possible to have a window function and
+ ** a scalar function with the same name and number of arguments. So
+ ** if we reach this point, either A and B both window functions or
+ ** neither are a window functions. */
+ assert( (pA->pWin==0)==(pB->pWin==0) );
+
if( pA->pWin!=0 ){
- if( pB->pWin==0 ) return 2;
if( sqlite3WindowCompare(pParse,pA->pWin,pB->pWin)!=0 ) return 2;
- }else if( pB->pWin!=0 ){
- return 2;
}
#endif
}