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

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
This commit is contained in:
drh
2018-07-10 07:25:42 +00:00
parent 6cbb4c936c
commit 38630ae1de
3 changed files with 17 additions and 10 deletions

View File

@@ -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
}