[Maria-developers] Please review MDEV-10468 Assertion `nr >= 0.0' failed in Item_sum_std::val_real()
Hello Alexey, Can you please review a patch for MDEV-10468? Thanks!
Hi, Alexander! On Aug 03, Alexander Barkov wrote:
diff --git a/sql/item_sum.cc b/sql/item_sum.cc index adf48f6..03600b7 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1762,7 +1762,7 @@ double Item_sum_std::val_real() { DBUG_ASSERT(fixed == 1); double nr= Item_sum_variance::val_real(); - DBUG_ASSERT(nr >= 0.0); + DBUG_ASSERT(nr >= 0.0 || my_isinf(nr)); return sqrt(nr); }
is it ok to do sqrt(inf)? what will it be? 0? inf? nan? may be this should return NULL in inf case? Regards, Sergei Chief Architect MariaDB and security@mariadb.org
Hi Sergei, On 08/08/2016 03:17 PM, Sergei Golubchik wrote:
Hi, Alexander!
On Aug 03, Alexander Barkov wrote:
diff --git a/sql/item_sum.cc b/sql/item_sum.cc index adf48f6..03600b7 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1762,7 +1762,7 @@ double Item_sum_std::val_real() { DBUG_ASSERT(fixed == 1); double nr= Item_sum_variance::val_real(); - DBUG_ASSERT(nr >= 0.0); + DBUG_ASSERT(nr >= 0.0 || my_isinf(nr)); return sqrt(nr); }
is it ok to do sqrt(inf)? what will it be? 0? inf? nan? may be this should return NULL in inf case?
sqrt(inf) returns inf. man sqrt: If x is positive infinity, positive infinity is returned. 'inf' is further replaced to '0' in Item::send(). Note, SUM in a similar situation (i.e. overflow) also returns 0: SELECT SUM(f) FROM (SELECT 1.7976931348623157e+308 AS f UNION SELECT 1e308 AS f) t2; Item_sum_sum::val_real() returns 0, which is replaced to '0' by Item::send().
Regards, Sergei Chief Architect MariaDB and security@mariadb.org
Hi Sergei, Here's a new patch, returning DBL_MAX in case of inf. Thanks! On 08/08/2016 03:17 PM, Sergei Golubchik wrote:
Hi, Alexander!
On Aug 03, Alexander Barkov wrote:
diff --git a/sql/item_sum.cc b/sql/item_sum.cc index adf48f6..03600b7 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1762,7 +1762,7 @@ double Item_sum_std::val_real() { DBUG_ASSERT(fixed == 1); double nr= Item_sum_variance::val_real(); - DBUG_ASSERT(nr >= 0.0); + DBUG_ASSERT(nr >= 0.0 || my_isinf(nr)); return sqrt(nr); }
is it ok to do sqrt(inf)? what will it be? 0? inf? nan? may be this should return NULL in inf case?
Regards, Sergei Chief Architect MariaDB and security@mariadb.org
participants (2)
-
Alexander Barkov
-
Sergei Golubchik