mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Clear the column cache before populating aggregate accumulator registers. Fix fo
r [883034dcb5]. FossilOrigin-Name: ffc23409c7fb45dc5a8722fad26e26d207bb3213
This commit is contained in:
12
src/select.c
12
src/select.c
@@ -3498,6 +3498,18 @@ static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
|
||||
sqlite3ExprCacheClear(pParse);
|
||||
}
|
||||
}
|
||||
|
||||
/* Before populating the accumulator registers, clear the column cache.
|
||||
** Otherwise, if any of the required column values are already present
|
||||
** in registers, sqlite3ExprCode() may use OP_SCopy to copy the value
|
||||
** to pC->iMem. But by the time the value is used, the original register
|
||||
** may have been used, invalidating the underlying buffer holding the
|
||||
** text or blob value. See ticket [883034dcb5].
|
||||
**
|
||||
** Another solution would be to change the OP_SCopy used to copy cached
|
||||
** values to an OP_Copy.
|
||||
*/
|
||||
sqlite3ExprCacheClear(pParse);
|
||||
for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){
|
||||
sqlite3ExprCode(pParse, pC->pExpr, pC->iMem);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user