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

@@ -1,5 +1,5 @@
C Enhance\sthe\ssqlite3ExprCompare()\sroutine\sso\sthat\sit\sknows\sto\scompare\sthe\nOVER\sclause\sof\swindow\sfunctions.
D 2018-07-10T06:47:07.491
C Assert\sthat\sif\stwo\sfunctions\scompare\sequal\sin\severy\sother\sway,\sthen\sthey\nmust\sboth\shave\sOVER\sclauses,\sor\sneither\shas\san\sOVER\sclause.\s\sUse\sthis\sfact\nto\ssimplify\sexpression\scomparison.
D 2018-07-10T07:25:42.133
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in 0a3a6c81e6fcb969ff9106e882f0a08547014ba463cb6beca4c4efaecc924ee6
@@ -447,7 +447,7 @@ F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957
F src/dbpage.c 4aa7f26198934dbd002e69418220eae3dbc71b010bbac32bd78faf86b52ce6c3
F src/dbstat.c edabb82611143727511a45ca0859b8cd037851ebe756ae3db289859dd18b6f91
F src/delete.c 4c8c7604277a2041647f96b78f4b9a47858e9217e4fb333d35e7b5ab32c5b57f
F src/expr.c e5861888a30d63611f59861d9b8c7adb591f04a6924d3683484e4f47ce59e148
F src/expr.c 61ae1a229b8c0b4a44314fcbceecbd8801a4e784cd8c5d6d78da86fb5a0c3ddb
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c b1da9ef8dc834603bb0d28972378a7ce65897847f9a1e89ab800bbdf24c788ee
F src/func.c 7c288b4ce309b5a8b8473514b88e1f8e69a80134509a8c0db8e39c858e367e7f
@@ -1746,7 +1746,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P a2c0e1bec0d8a6f982572c4c5a8166319b8db0fe586057f7900f0ab72af6554e
R d511286d824e78f6045de8ea27dbb818
P 0a7649afebc9349bf44a0e3588e81ab595ea85be1c70de08859ea76a7b271f62
R b915cbd3a3a1dcccf34bbc81d9e850ba
U drh
Z 254538629d66367cc0a68844114b45e9
Z b899de7df69efd022bef2da0986ac912

View File

@@ -1 +1 @@
0a7649afebc9349bf44a0e3588e81ab595ea85be1c70de08859ea76a7b271f62
52559ad58ce412af40f1f34e80bfe9fadc6a93f3ca0cfaf69f94d615bbb99831

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
}