1
0
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:
dan
2010-03-31 15:02:56 +00:00
parent d3d986d329
commit 67a6a40cf9
4 changed files with 65 additions and 19 deletions

View File

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