mirror of
https://github.com/sqlite/sqlite.git
synced 2025-10-21 11:13:54 +03:00
Fix the AVG() and TOTAL() functions (after the SUM() fix of [77d3dcd283595c52])
so that they work with infinitites. Fixes a bug introduced by check-in. [c63e26e705f5e967]. Bug reported by [forum:/forumpost/8960fb40cc|forum post 8960fb40cc]. FossilOrigin-Name: 6df6f17ccb404c648076ccff4200d0eb5437f0e3e82424bf3da5ea682b107bb4
This commit is contained in:
@@ -1907,7 +1907,8 @@ static void avgFinalize(sqlite3_context *context){
|
||||
if( p && p->cnt>0 ){
|
||||
double r;
|
||||
if( p->approx ){
|
||||
r = p->rSum+p->rErr;
|
||||
r = p->rSum;
|
||||
if( !sqlite3IsNaN(p->rErr) ) r += p->rErr;
|
||||
}else{
|
||||
r = (double)(p->iSum);
|
||||
}
|
||||
@@ -1920,7 +1921,8 @@ static void totalFinalize(sqlite3_context *context){
|
||||
p = sqlite3_aggregate_context(context, 0);
|
||||
if( p ){
|
||||
if( p->approx ){
|
||||
r = p->rSum+p->rErr;
|
||||
r = p->rSum;
|
||||
if( !sqlite3IsNaN(p->rErr) ) r += p->rErr;
|
||||
}else{
|
||||
r = (double)(p->iSum);
|
||||
}
|
||||
|
Reference in New Issue
Block a user