← Back to team overview

maria-developers team mailing list archive

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!

diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index ac076ec..ae16eb7 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -2270,3 +2270,15 @@ t2_id	GROUP_CONCAT(IF (t6.b, t6.f, t5.f) ORDER BY 1)
 EXECUTE stmt;
 t2_id	GROUP_CONCAT(IF (t6.b, t6.f, t5.f) ORDER BY 1)
 DROP TABLE t1,t2,t3,t4,t5,t6;
+#
+# MDEV-10468 Assertion `nr >= 0.0' failed in Item_sum_std::val_real()
+#
+SELECT STDDEV_POP(f) FROM (SELECT "1e+309" AS f UNION SELECT "-1e+309" AS f) tbl;
+STDDEV_POP(f)
+0
+Warnings:
+Warning	1292	Truncated incorrect DOUBLE value: '1e+309'
+Warning	1292	Truncated incorrect DOUBLE value: '-1e+309'
+SELECT STDDEV(f) FROM (SELECT 1.7976931348623157e+308 AS f UNION SELECT -1.7976931348623157e+308 AS f) tbl;
+STDDEV(f)
+0
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index bd3ed4a..c895f81 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -1565,3 +1565,9 @@ EXECUTE stmt;
 EXECUTE stmt;
 
 DROP TABLE t1,t2,t3,t4,t5,t6;
+
+--echo #
+--echo # MDEV-10468 Assertion `nr >= 0.0' failed in Item_sum_std::val_real()
+--echo #
+SELECT STDDEV_POP(f) FROM (SELECT "1e+309" AS f UNION SELECT "-1e+309" AS f) tbl;
+SELECT STDDEV(f) FROM (SELECT 1.7976931348623157e+308 AS f UNION SELECT -1.7976931348623157e+308 AS f) tbl;
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);
 }
 

Follow ups