From: drh <> Date: Tue, 22 Nov 2022 20:58:18 +0000 (+0000) Subject: Merge enhancements and fixes from trunk. X-Git-Tag: version-3.41.0~372^2~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58c065292388787c4845a1c7b60eacd664ac1fff;p=thirdparty%2Fsqlite.git Merge enhancements and fixes from trunk. FossilOrigin-Name: f8932e04d4d18eb9d71edda15aa08af2eb139ff14d77ca147ea6e9b173e0f5e0 --- 58c065292388787c4845a1c7b60eacd664ac1fff diff --cc manifest index e809fe26ab,ee115293de..768c50fa57 --- a/manifest +++ b/manifest @@@ -1,5 -1,5 +1,5 @@@ - C Add\sthe\sstub\sfunction:\soptimizeAggregateUsingIndexedExpr().\s\sThe\shope\sis\sthat\nwe\scan\sfill\sthis\sin\swith\sa\sroutine\sthat\sdoes\suseful\soptimizations. - D 2022-11-22T20:37:41.721 -C Avoid\snaming\scollision\sbetween\sthe\ssha1\sand\sshathree\sextensions. -D 2022-11-22T20:04:00.704 ++C Merge\senhancements\sand\sfixes\sfrom\strunk. ++D 2022-11-22T20:58:18.661 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@@ -641,12 -641,12 +641,12 @@@ F src/printf.c e99ee9741e79ae3873458146 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c efea4e5fbecfd6d0a9071b0be0d952620991673391b6ffaaf4c277b0bb674633 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 - F src/select.c dfc504356e15bb8585d8535a927a72512d1d7a01f9074824964f1781e286231b -F src/select.c 4c48373abb4e67129c36bc15d1f5a99a0dfd9534afeb539a2169a09ae91ccec9 ++F src/select.c 6f5403b8f1849d2a8ba152dd790ec189bba18242157904ddca77707e209265d4 F src/shell.c.in 7d1705f139e6762e8c0fe254a8ebf3ab77aec6d8366f033cdd5f5ebadefbbb20 F src/sqlite.h.in 100fc660c2f19961b8ed8437b9d53d687de2f8eb2b96437ec6da216adcb643ca F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c4b9fa7a7e2bcdf850cfeb4b8a91d5ec47b7a00033bc996fd2ee96cbf2741f5f - F src/sqliteInt.h 35db0abe8e960dd0396bedcb4489faeabccfbb2d1172568eab029fd72fba40ed -F src/sqliteInt.h 6a24230f2928b3d1d9b0fdbedb98c862b828a4b1a9170306108e74cd6277f476 ++F src/sqliteInt.h 894f7d98b1104fecb2ca2f457a4c598944250d9462eb433f12bd42b1080d525f F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657 F src/status.c 160c445d7d28c984a0eae38c144f6419311ed3eace59b44ac6dafc20db4af749 F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@@ -2059,8 -2059,8 +2059,8 @@@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a9 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 - P 070634781a5eb41f96b001e48b064e3cd8c82314f576335eb1fcd43792179291 - R 5bcfbb263a340b6c57659d80015cbb33 -P db07471c531766a8eec1d5b41c9fd0283b5e64ee13166dc3391f70a1e1946121 -R 028f4214066f285c3501b4fa202e9f4b -U mistachkin -Z 9f8febbd78f0b476308550c8b424fd90 ++P d85bb724fdd6fbad2b88ed7f60e4174e3f65182356f404d04620c5cf6b17f77e 9ec923b5dc24d6082da8d42bc0ee8ab1c418912625c0c56de9627be2c818ef98 ++R 55f08c65335ec615b6caa516a7697c9d +U drh - Z 28092ed1d737fad311ecc59737148e5d ++Z dbc39758acc6c225892e0cac1e391b2a # Remove this line to create a well-formed Fossil manifest. diff --cc manifest.uuid index 0a7b42af87,7b2a4dc5e4..9c7d27e3fe --- a/manifest.uuid +++ b/manifest.uuid @@@ -1,1 -1,1 +1,1 @@@ - d85bb724fdd6fbad2b88ed7f60e4174e3f65182356f404d04620c5cf6b17f77e -9ec923b5dc24d6082da8d42bc0ee8ab1c418912625c0c56de9627be2c818ef98 ++f8932e04d4d18eb9d71edda15aa08af2eb139ff14d77ca147ea6e9b173e0f5e0 diff --cc src/select.c index ecd1791060,4d5bde9a31..f71fa3197e --- a/src/select.c +++ b/src/select.c @@@ -6640,10 -6639,10 +6640,11 @@@ static void printAggInfo(AggInfo *pAggI struct AggInfo_col *pCol = &pAggInfo->aCol[ii]; sqlite3DebugPrintf( "agg-column[%d] pTab=%s iTable=%d iColumn=%d iMem=%d" -- " iSorterColumn=%d\n", ++ " iSorterColumn=%d %s\n", ii, pCol->pTab ? pCol->pTab->zName : "NULL", - pCol->iTable, pCol->iColumn, pCol->iMem, - pCol->iSorterColumn); + pCol->iTable, pCol->iColumn, AggInfoColumnReg(pAggInfo,ii), - pCol->iSorterColumn); ++ pCol->iSorterColumn, ++ ii>=pAggInfo->nAccumulator ? "" : " Accumulator"); sqlite3TreeViewExpr(0, pAggInfo->aCol[ii].pCExpr, 0); } for(ii=0; iinFunc; ii++){ @@@ -6654,34 -6653,6 +6655,35 @@@ } #endif /* TREETRACE_ENABLED */ +/* +** An index on expressions is being used in the inner loop of an +** aggregate query with a GROUP BY clause. This routine attempts +** to adjust the AggInfo object to take advantage of index and to +** perhaps use the index as a covering index. +** +*/ +static int optimizeAggregateUsingIndexedExpr( + Parse *pParse, /* Parsing context */ + Select *pSelect, /* The SELECT being coded */ + AggInfo *pAggInfo /* The aggregate info */ +){ +#if TREETRACE_ENABLED - if( sqlite3TreeTrace & 0x100000 ){ ++ if( sqlite3TreeTrace & 0x80000 ){ + IndexedExpr *pIEpr; - TREETRACE(0x1000000, pParse, pSelect, ++ TREETRACE(0x80000, pParse, pSelect, + ("Attempting to optimize AggInfo for Indexed Exprs\n")); + for(pIEpr=pParse->pIdxEpr; pIEpr; pIEpr=pIEpr->pIENext){ - printf("cur=%d\n", pIEpr->iDataCur); ++ printf("data-cursor=%d index={%d,%d}\n", ++ pIEpr->iDataCur, pIEpr->iIdxCur, pIEpr->iIdxCol); + sqlite3TreeViewExpr(0, pIEpr->pExpr, 0); + } + printAggInfo(pAggInfo); + } +#endif + return 0; +} + + /* ** Generate code for the SELECT statement given in the p argument. ** diff --cc src/sqliteInt.h index bc154de78e,86f33dec9e..74c997c6dd --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@@ -1038,6 -1038,29 +1038,30 @@@ extern u32 sqlite3TreeTrace # define TREETRACE_ENABLED 0 #endif + /* TREETRACE flag meanings: + ** + ** 0x00000001 Beginning and end of SELECT processing + ** 0x00000002 WHERE clause processing + ** 0x00000004 Query flattener + ** 0x00000008 Result-set wildcard expansion + ** 0x00000010 Query name resolution + ** 0x00000020 Aggregate analysis + ** 0x00000040 Window functions + ** 0x00000080 Generated column names + ** 0x00000100 Move HAVING terms into WHERE + ** 0x00000200 Count-of-view optimization + ** 0x00000400 Compound SELECT processing + ** 0x00000800 Drop superfluous ORDER BY + ** 0x00001000 LEFT JOIN simplifies to JOIN + ** 0x00002000 Constant propagation + ** 0x00004000 Push-down optimization + ** 0x00008000 After all FROM-clause analysis + ** 0x00010000 Beginning of DELETE/INSERT/UPDATE processing + ** 0x00020000 Transform DISTINCT into GROUP BY + ** 0x00040000 SELECT tree dump after all code has been generated ++** 0x00080000 Optimize Aggregates using indexed expressions + */ + /* ** Macros for "wheretrace" */