Fix a case where combining row-value UPDATE FROM syntax with window functions over aggregates can cause an error.

FossilOrigin-Name: 4a587c3492faa99490fd67ca1de9fceafcdc12d220f42817791923be258b73f1
This commit is contained in:
dan 2021-06-03 18:56:42 +00:00
parent a6df0e693f
commit 19e4eefbca
4 changed files with 41 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C Fix\sthe\struncate\soptimization\sso\sthat\sPRAGMA\scount_changes\sand\schanges()\nreturn\scorrect\svalues\seven\sfor\sa\sWITHOUT\sROWID\stable.\n[forum:/forumpost/07dedbf9a1|Forum\spost\s07dedbf9a1].
D 2021-06-03T18:51:51.135
C Fix\sa\scase\swhere\scombining\srow-value\sUPDATE\sFROM\ssyntax\swith\swindow\sfunctions\sover\saggregates\scan\scause\san\serror.
D 2021-06-03T18:56:42.861
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -496,7 +496,7 @@ F src/date.c e0632f335952b32401482d099321bbf12716b29d6e72836b53ae49683ebae4bf
F src/dbpage.c 8a01e865bf8bc6d7b1844b4314443a6436c07c3efe1d488ed89e81719047833a
F src/dbstat.c 3aa79fc3aed7ce906e4ea6c10e85d657299e304f6049861fe300053ac57de36c
F src/delete.c 930e63df768dcb197242b1efa0ed9fcdcc9a7b7556c236ee01a9959b61cf527b
F src/expr.c 09f8ae1421d09802b4ac4b05c507761ecd142fa32cc0b1e33b9bd07fba10d34a
F src/expr.c f175b34cc0da572f899bb6591fd3510b17200702dce7d80226cd4e454f7cd83a
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c e9063648396c58778f77583a678342fe4a9bc82436bf23c5f9f444f2df0fdaa4
F src/func.c 88fd711754a7241cb9f8eb1391370fd0c0cea756b3358efa274c5d1efd59af93
@ -1307,7 +1307,7 @@ F test/round1.test 768018b04522ca420b1aba8a24bd76091d269f3bce3902af3ec6ebcee41ab
F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc
F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81
F test/rowid.test bfbd7b97d9267660be3c8f28507c4ed7f205196b8877c0db42df347c2e8845e3
F test/rowvalue.test 466efbb7bb93ca9f95d89f69c7c140aa52cc57ac6dfa7efba09ea4a9ab3cd9f0
F test/rowvalue.test 37effea4dd83555ea969a9461dfcffb25e6731a5db7c388e232410999c100853
F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b
F test/rowvalue3.test 3068f508753af69884b12125995f023da0dbb256
F test/rowvalue4.test 441e7e366ac6d939a3a95a574031c56ec2a854077a91d66eee5ff1d86cb5be58
@ -1918,7 +1918,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 5d4535bfb603d7c8229ef60f99666459f2997e02e186bc1e52b7ec1320251d67
R 44321a6657926f9575a85818259f7e27
U drh
Z 587f0cd29c08ce7be2dd885b5d005a8e
P 820ae3b117c2d8c117c0c5a4e440a7d06886772516c7fc0a84606388f91be195
R 3fd4ec14904b0e03c6d406344d944d84
U dan
Z f80d5b48e051c51974d8a351a0138ba6

View File

@ -1 +1 @@
820ae3b117c2d8c117c0c5a4e440a7d06886772516c7fc0a84606388f91be195
4a587c3492faa99490fd67ca1de9fceafcdc12d220f42817791923be258b73f1

View File

@ -6005,6 +6005,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
*/
struct AggInfo_func *pItem = pAggInfo->aFunc;
for(i=0; i<pAggInfo->nFunc; i++, pItem++){
if( pItem->pFExpr==pExpr ) break;
if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){
break;
}

View File

@ -663,4 +663,35 @@ do_catchsql_test 29.1 {
SELECT (SELECT 1 WHERE ((SELECT 1 WHERE (2,(2,0)) IS (2,(20))),(2,0)) IS (2,(20))) WHERE (2,(2,0)) IS (2 IN(SELECT 1 WHERE (2,(2,2,0)) IS (2,(20))),(20));
} {1 {row value misused}}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 30.0 {
CREATE TABLE t1(x, y, z);
CREATE TABLE t2(a, b);
INSERT INTO t1 VALUES(1000, 2000, 3000);
INSERT INTO t2 VALUES(NULL, NULL);
}
do_execsql_test 30.1 {
UPDATE t2 SET (a,b)=(
SELECT max( t1.x ) OVER( PARTITION BY sum( (SELECT t1.y) ) ), 2
)
FROM t1;
} {}
do_execsql_test 30.2 {
SELECT * FROM t2
} {1000 2}
reset_db
do_execsql_test 30.3 {
CREATE TABLE t1(x INT PRIMARY KEY, y, z);
CREATE TABLE t2(a,b,c,d,e,PRIMARY KEY(a,b))WITHOUT ROWID;
UPDATE t2 SET (d,d,a)=(SELECT EXISTS(SELECT 1 IN(SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(PARTITION BY sum((SELECT y FROM t1 UNION SELECT x ORDER BY 1)))INTERSECT SELECT EXISTS(SELECT 1 FROM t1 UNION SELECT x ORDER BY 1) ORDER BY 1) ORDERa)|9 AS blob, 2, 3) FROM t1 WHERE x<a;
}
finish_test