1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-08 14:22:09 +03:00

Fix another 0 count error in dropValue

This commit is contained in:
mariadb-AndreyPiskunov
2022-09-09 21:34:20 +03:00
committed by Leonid Fedorov
parent e7cab8445c
commit 680633a350
9 changed files with 160 additions and 87 deletions

View File

@@ -157,11 +157,18 @@ mcsv1_UDAF::ReturnCode regr_sxx::dropValue(mcsv1Context* context, ColumnDatum* v
long double cxPrev = data->cx;
--data->cnt;
uint64_t cnt = data->cnt;
long double dx = valx - avgxPrev;
avgxPrev -= dx / cnt;
cxPrev -= dx * (valx - avgxPrev);
data->avgx = avgxPrev;
data->cx = cxPrev;
if (cnt == 0)
{
data->avgx = 0;
data->cx = 0;
}
else
{
long double dx = valx - avgxPrev;
avgxPrev -= dx / cnt;
cxPrev -= dx * (valx - avgxPrev);
data->avgx = avgxPrev;
data->cx = cxPrev;
}
return mcsv1_UDAF::SUCCESS;
}