1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

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
This commit is contained in:
drh
2021-02-17 21:13:14 +00:00
parent 4b0229ae1f
commit c54246ffdf
5 changed files with 24 additions and 30 deletions

View File

@@ -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;