diff --git a/manifest b/manifest index 24ce068e9c..9a2d78f7e1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sthe\ssqlite3SelectDup()\sroutine\sto\savoid\srecursing\son\sSelect.pPrior. -D 2017-02-03T14:44:52.406 +C Avoid\sa\sperformance\sproblem\swhen\svery\slarge\s"VALUES(..),\s(..),\s(..)"\sterms\sare\nused\sin\squeries. +D 2017-02-03T19:16:39.919 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -393,7 +393,7 @@ F src/printf.c ff10a9b9902cd2afe5f655f3013c6307d969b1fd F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c f9bc0de45a30a450da47b3766de00be89bf9be79 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac -F src/select.c 3856db523b942062bca8722ba03b61c324ff94d6 +F src/select.c d12f3539f80db38b09015561b569e0eb1c4b6c5f F src/shell.c a84e453c213f3e0d6935a582024da4e242f85a19 F src/sqlite.h.in 751ff125eb159c8f92c182b8df980a5e4f50e966 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1552,10 +1552,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 8e03a8e95fada5c24d369672a71f6e02288051da -R c80f7dbbf5f0044354e4b463e716c13e -T *branch * recursive-selectdup -T *sym-recursive-selectdup * -T -sym-trunk * +P a7674ead5be986c66f7d61d598adc7e5728bcd30 +R 1275850dbdc882ce3db2a9a335b19414 U dan -Z f43da81961eb4c39992192293f7e5a2c +Z aab63e41186ee170ee1c431b74360517 diff --git a/manifest.uuid b/manifest.uuid index a72c232e1b..c0409900d6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a7674ead5be986c66f7d61d598adc7e5728bcd30 \ No newline at end of file +f5306ad6816cc377036685cdae227e762885229c \ No newline at end of file diff --git a/src/select.c b/src/select.c index ed6221309f..d817ebd074 100644 --- a/src/select.c +++ b/src/select.c @@ -4186,7 +4186,15 @@ static int withExpand( pCte->zCteErr = "circular reference: %s"; pSavedWith = pParse->pWith; pParse->pWith = pWith; - sqlite3WalkSelect(pWalker, bMayRecursive ? pSel->pPrior : pSel); + if( bMayRecursive ){ + Select *pPrior = pSel->pPrior; + assert( pPrior->pWith==0 ); + pPrior->pWith = pSel->pWith; + sqlite3WalkSelect(pWalker, pPrior); + pPrior->pWith = 0; + }else{ + sqlite3WalkSelect(pWalker, pSel); + } pParse->pWith = pWith; for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior); @@ -4230,10 +4238,12 @@ static int withExpand( */ static void selectPopWith(Walker *pWalker, Select *p){ Parse *pParse = pWalker->pParse; - With *pWith = findRightmost(p)->pWith; - if( pWith!=0 ){ - assert( pParse->pWith==pWith ); - pParse->pWith = pWith->pOuter; + if( pParse->pWith && p->pPrior==0 ){ + With *pWith = findRightmost(p)->pWith; + if( pWith!=0 ){ + assert( pParse->pWith==pWith ); + pParse->pWith = pWith->pOuter; + } } } #else @@ -4283,8 +4293,8 @@ static int selectExpander(Walker *pWalker, Select *p){ } pTabList = p->pSrc; pEList = p->pEList; - if( pWalker->xSelectCallback2==selectPopWith ){ - sqlite3WithPush(pParse, findRightmost(p)->pWith, 0); + if( p->pWith ){ + sqlite3WithPush(pParse, p->pWith, 0); } /* Make sure cursor numbers have been assigned to all entries in @@ -4571,9 +4581,7 @@ static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){ sqlite3WalkSelect(&w, pSelect); } w.xSelectCallback = selectExpander; - if( (pSelect->selFlags & SF_MultiValue)==0 ){ - w.xSelectCallback2 = selectPopWith; - } + w.xSelectCallback2 = selectPopWith; sqlite3WalkSelect(&w, pSelect); }