mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Do not allow aggregates in a RETURNING clause. Fix a memory leak that
occurs when window functions are used in a RETURNING clause. FossilOrigin-Name: 2e9bd94b9ad37c7e4123b7324f2fe42d3609a65af449eb8a0064057647709a73
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user