1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Bug fixes in aggregate processing. Fewer tests fail. (CVS 2663)

FossilOrigin-Name: c3ac58592f5e6305640868cdf42c129f1a25255d
This commit is contained in:
drh
2005-09-07 22:09:48 +00:00
parent 13449892ef
commit a10a34b88f
7 changed files with 55 additions and 42 deletions

View File

@@ -259,14 +259,19 @@ void *sqlite3_user_data(sqlite3_context *p){
void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
assert( p && p->pFunc && p->pFunc->xStep );
Mem *pMem = p->pMem;
if( (pMem->flags & MEM_Agg)==0 && nByte>0 ){
pMem->flags = MEM_Agg;
*(FuncDef**)&pMem->i = p->pFunc;
if( nByte<=NBFS ){
pMem->z = pMem->zShort;
memset(pMem->z, 0, nByte);
if( (pMem->flags & MEM_Agg)==0 ){
if( nByte==0 ){
assert( pMem->flags==MEM_Null );
pMem->z = 0;
}else{
pMem->z = sqliteMalloc( nByte );
pMem->flags = MEM_Agg;
*(FuncDef**)&pMem->i = p->pFunc;
if( nByte<=NBFS ){
pMem->z = pMem->zShort;
memset(pMem->z, 0, nByte);
}else{
pMem->z = sqliteMalloc( nByte );
}
}
}
return (void*)pMem->z;