aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest18
-rw-r--r--manifest.uuid2
-rw-r--r--src/expr.c8
-rw-r--r--src/window.c20
-rw-r--r--test/window1.test17
5 files changed, 46 insertions, 19 deletions
diff --git a/manifest b/manifest
index f4dd7639e..50e9f57dc 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C When\sdoing\sa\stest-to-double\sconversion\son\sa\sBLOB\swith\san\sodd\snumber\sof\sbytes\nand\sassuming\sa\sUTF16\sencoding,\signore\sthe\slast\sbyte.\nTicket\s[9eda2697f5cc1aba].
-D 2020-01-08T12:17:46.451
+C Fix\san\sassert()\sin\swindow.c\sthat\scould\sfail\swith\ssome\sobscure\sSELECT\sstatements\sthat\suse\swindow\sfunctions.
+D 2020-01-09T20:11:29.695
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -480,7 +480,7 @@ F src/date.c e1d8ac7102f3f283e63e13867acb0efa33861cf34f0faf4cdbaf9fa7a1eb7041
F src/dbpage.c 135eb3b5e74f9ef74bde5cec2571192c90c86984fa534c88bf4a055076fa19b7
F src/dbstat.c 5125f559b33787a29f7ded750f2a69080f50a85bced98fe8ad02a99e543c4b44
F src/delete.c a5c59b9c0251cf7682bc52af0d64f09b1aefc6781a63592c8f1136f7b73c66e4
-F src/expr.c 631b1f24d07114066c756984b8bc7be64529afb2ea3a5da4e3e262792f320dfa
+F src/expr.c d8854187a79c7798184c15982a25f457badf35eb3942d40e13ac292670fe996d
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 92a248ec0fa4ed8ab60c98d9b188ce173aaf218f32e7737ba77deb2a684f9847
F src/func.c 259496e4856bd0a3215d16804992f3339f3e8db29f129a5a7285c341488bbe9c
@@ -618,7 +618,7 @@ F src/where.c df2bea0e0122e853d9f1a8ec68920744166d2a524e338eba92e5470538ecd1f9
F src/whereInt.h e1d1db6bbec0ba4f345acc338f956c8237a6f06413afa68c6414e82fb5b06745
F src/wherecode.c 75ad6cbb8dfe585ffe0fc71008750b5158fc4811c3a498327033920b18f0a4be
F src/whereexpr.c 4b34be1434183e7bb8a05d4bf42bd53ea53021b0b060936fbd12062b4ff6b396
-F src/window.c 659d613248f8bb8630f51409dc08235e4494c3c84162a535d9f88b38515f390a
+F src/window.c f8ba2ee12a19b51d3ba42c16277c74185ee9215306bc0d5a03974ade8b5bc98f
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627
F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d
@@ -1714,7 +1714,7 @@ F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2
F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972
F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d
F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc
-F test/window1.test b61afc46bad183e19dcd46119d908ee79aecfd5929e61d332dba4ce9c2c0b7b9
+F test/window1.test cec56b9a0a2e7ca4bd63b30590c7b049dce9acfd87478e2597e13b67152bd821
F test/window2.tcl 492c125fa550cda1dd3555768a2303b3effbeceee215293adf8871efc25f1476
F test/window2.test e466a88bd626d66edc3d352d7d7e1d5531e0079b549ba44efb029d1fbff9fd3c
F test/window3.tcl acea6e86a4324a210fd608d06741010ca83ded9fde438341cb978c49928faf03
@@ -1853,7 +1853,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 295442887a3cd5868df26c5be244649ffb3bae8367f5cf02fe513424a1c9f6a7
-R 9275f44076e39841a96fb22faa964c5a
-U drh
-Z ac500ac229baf04846641aa2e74b4140
+P 1c76f1d8ec0937a2d2e4ce75f98494c953e9621db31945d7e44f45d90d1c3892
+R ffac5b4965945b4f5228b33ed0d4412f
+U dan
+Z 15dde77566cf35e66ee6ee4f50dfa225
diff --git a/manifest.uuid b/manifest.uuid
index a31a5968e..75197a84e 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-1c76f1d8ec0937a2d2e4ce75f98494c953e9621db31945d7e44f45d90d1c3892 \ No newline at end of file
+83dc55679a91bf5d1d13706088ce58eed02b9aad1ad0ae237966e78e0d769663 \ No newline at end of file
diff --git a/src/expr.c b/src/expr.c
index 4e8703e55..67b5ce7dc 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -5183,8 +5183,9 @@ int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){
}
/*
-** Compare two ExprList objects. Return 0 if they are identical and
-** non-zero if they differ in any way.
+** Compare two ExprList objects. Return 0 if they are identical, 1
+** if they are certainly different, or 2 if it is not possible to
+** determine if they are identical or not.
**
** If any subelement of pB has Expr.iTable==(-1) then it is allowed
** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
@@ -5203,10 +5204,11 @@ int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){
if( pA==0 || pB==0 ) return 1;
if( pA->nExpr!=pB->nExpr ) return 1;
for(i=0; i<pA->nExpr; i++){
+ int res;
Expr *pExprA = pA->a[i].pExpr;
Expr *pExprB = pB->a[i].pExpr;
if( pA->a[i].sortFlags!=pB->a[i].sortFlags ) return 1;
- if( sqlite3ExprCompare(0, pExprA, pExprB, iTab) ) return 1;
+ if( (res = sqlite3ExprCompare(0, pExprA, pExprB, iTab)) ) return res;
}
return 0;
}
diff --git a/src/window.c b/src/window.c
index 5fb78ce35..a72ec0d2d 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1279,10 +1279,12 @@ void sqlite3WindowLink(Select *pSel, Window *pWin){
}
/*
-** Return 0 if the two window objects are identical, or non-zero otherwise.
-** Identical window objects can be processed in a single scan.
+** Return 0 if the two window objects are identical, 1 if they are
+** different, or 2 if it cannot be determined if the objects are identical
+** or not. Identical window objects can be processed in a single scan.
*/
int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2, int bFilter){
+ int res;
if( NEVER(p1==0) || NEVER(p2==0) ) return 1;
if( p1->eFrmType!=p2->eFrmType ) return 1;
if( p1->eStart!=p2->eStart ) return 1;
@@ -1290,10 +1292,16 @@ int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2, int bFilter){
if( p1->eExclude!=p2->eExclude ) return 1;
if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;
if( sqlite3ExprCompare(pParse, p1->pEnd, p2->pEnd, -1) ) return 1;
- if( sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1) ) return 1;
- if( sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1) ) return 1;
+ if( (res = sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1)) ){
+ return res;
+ }
+ if( (res = sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1)) ){
+ return res;
+ }
if( bFilter ){
- if( sqlite3ExprCompare(pParse, p1->pFilter, p2->pFilter, -1) ) return 1;
+ if( (res = sqlite3ExprCompare(pParse, p1->pFilter, p2->pFilter, -1)) ){
+ return res;
+ }
}
return 0;
}
@@ -1580,7 +1588,7 @@ static void windowAggStep(
/* All OVER clauses in the same window function aggregate step must
** be the same. */
- assert( pWin==pMWin || sqlite3WindowCompare(pParse,pWin,pMWin,0)==0 );
+ assert( pWin==pMWin || sqlite3WindowCompare(pParse,pWin,pMWin,0)!=1 );
for(i=0; i<nArg; i++){
if( i!=1 || pFunc->zName!=nth_valueName ){
diff --git a/test/window1.test b/test/window1.test
index bc5796f87..833e211fb 100644
--- a/test/window1.test
+++ b/test/window1.test
@@ -1577,4 +1577,21 @@ do_catchsql_test 47.2 {
OR (SELECT k FROM t2 WHERE (SELECT sum(a) OVER() FROM t1 GROUP BY 1));
} {1 {misuse of window function sum()}}
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 48.0 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ SELECT (SELECT max(x)OVER(ORDER BY x) + min(x)OVER(ORDER BY x))
+ FROM (SELECT (SELECT sum(a) FROM t1) AS x FROM t1);
+} {12 12 12}
+
+do_execsql_test 48.1 {
+ SELECT (SELECT max(x)OVER(ORDER BY x) + min(x)OVER(ORDER BY x))
+ FROM (SELECT (SELECT sum(a) FROM t1 GROUP BY a) AS x FROM t1);
+} {2 2 2}
+
+
finish_test