diff --git a/manifest b/manifest index 502b6f6d4c..81bc47332a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Report\san\serror\sif\sRETURNING\sis\sused\sfor\sDELETE\sor\sUPDATE\sof\sa\svirtual\stable. -D 2021-02-02T12:01:22.075 +C Do\snot\sallow\saggregates\sin\sa\sRETURNING\sclause.\s\sFix\sa\smemory\sleak\sthat\noccurs\swhen\swindow\sfunctions\sare\sused\sin\sa\sRETURNING\sclause. +D 2021-02-02T20:46:11.972 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -607,7 +607,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c c64c49d7c2ec4490c2fef1f24350167ba16b03b0c6cee58ad1a1d70a4325d4e9 F src/treeview.c 4b92992176fb2caefbe06ba5bd06e0e0ebcde3d5564758da672631f17aa51cda -F src/trigger.c 0e8d33e9ba2c9ce2a3ded92b6d81afd56bac39dc0faf18455b3b49f71a451195 +F src/trigger.c a9357898b5965f579c6384b6538aa7297e3d38a132e87e1fc0e1e5b276a4cf21 F src/update.c 0f5a61f0787199983530a33f6fffe4f52742f35fcdf6ccfad1078b1a8bc17723 F src/upsert.c df8f1727d62b5987c4fd302cd4d7c0c84ae57cd65683c5a34a740dfe24039235 F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0 @@ -1899,7 +1899,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 2f244ab4a2ba2bdb608cf44ef02e00738ad58c10a76d9e4222dc843a17103d92 -R a875c66b94135d7bf08c2474b75d1d9b +P bd5dee8425327fde0429043ce325b910f1b7951988d9a448a8eeeb713a46bc81 +R cd87aa40fae996ae8358e0b84594bda6 U drh -Z 7903baa82d2a34245eb14a08b0ad275c +Z 25e8d0af3fd413c8e6c9d01783338232 diff --git a/manifest.uuid b/manifest.uuid index 9fd2b15429..fec5166aaa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bd5dee8425327fde0429043ce325b910f1b7951988d9a448a8eeeb713a46bc81 \ No newline at end of file +2e9bd94b9ad37c7e4123b7324f2fe42d3609a65af449eb8a0064057647709a73 \ No newline at end of file diff --git a/src/trigger.c b/src/trigger.c index dd645324d3..52811617ee 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -923,13 +923,20 @@ static int codeTriggerProgram( Select *pSelect = pStep->pSelect; ExprList *pList = pSelect->pEList; SelectDest sDest; + Select *pNew; pSelect->pEList = sqlite3ExpandReturning(pParse, pList, pParse->pTriggerTab); sqlite3SelectDestInit(&sDest, SRT_Output, 0); - pSelect->selFlags = 0; - sqlite3Select(pParse, pSelect, &sDest); + pNew = sqlite3SelectDup(db, pSelect, 0); + if( pNew ){ + sqlite3Select(pParse, pNew, &sDest); + if( pNew->selFlags & (SF_Aggregate|SF_HasAgg|SF_WinRewrite) ){ + sqlite3ErrorMsg(pParse, "aggregates not allowed in RETURNING"); + } + sqlite3SelectDelete(db, pNew); + } sqlite3ExprListDelete(db, pSelect->pEList); - pSelect->pEList = pList; + pStep->pSelect->pEList = pList; break; } }