diff options
author | drh <> | 2021-02-17 21:13:14 +0000 |
---|---|---|
committer | drh <> | 2021-02-17 21:13:14 +0000 |
commit | c54246ffdf51ae0af4d9e39c653571e6e6586cc6 (patch) | |
tree | c1af27c0e52836effb97b1afd4f80eaccb70e1e2 /src/select.c | |
parent | 4b0229ae1ff30df9cf1d33e7c1df27cb01c5ecfe (diff) | |
download | sqlite-c54246ffdf51ae0af4d9e39c653571e6e6586cc6.tar.gz sqlite-c54246ffdf51ae0af4d9e39c653571e6e6586cc6.zip |
Use the sqlite3ParserAddCleanup() mechanism to ensure that the AggInfo
structure associated with an aggregate query is deallocated, for a performance
increase and size reduction.
FossilOrigin-Name: 7a1399671fa10c64d5358cc4d364d24c643fe9dd8da923356462267ee7962f61
Diffstat (limited to 'src/select.c')
-rw-r--r-- | src/select.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/select.c b/src/select.c index 49a36875f..4a969caf2 100644 --- a/src/select.c +++ b/src/select.c @@ -5793,6 +5793,15 @@ static struct SrcList_item *isSelfJoinView( return 0; } +/* +** Deallocate a single AggInfo object +*/ +static void agginfoFree(sqlite3 *db, AggInfo *p){ + sqlite3DbFree(db, p->aCol); + sqlite3DbFree(db, p->aFunc); + sqlite3DbFreeNN(db, p); +} + #ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION /* ** Attempt to transform a query of the form @@ -6537,11 +6546,13 @@ int sqlite3Select( ** SELECT statement. */ pAggInfo = sqlite3DbMallocZero(db, sizeof(*pAggInfo) ); - if( pAggInfo==0 ){ + if( pAggInfo ){ + sqlite3ParserAddCleanup(pParse, + (void(*)(sqlite3*,void*))agginfoFree, pAggInfo); + } + if( db->mallocFailed ){ goto select_end; } - pAggInfo->pNext = pParse->pAggList; - pParse->pAggList = pAggInfo; pAggInfo->selId = p->selId; memset(&sNC, 0, sizeof(sNC)); sNC.pParse = pParse; |