Skip to content

Commit 6434e49

Browse files
committed
A cleanup for MDEV-19468 Hybrid type expressions return wrong format for FLOAT
Fixing problems revealed by buildbot: - Fixing compilation failure on Windows - Recoding correct engines/iuds/r/insert_decimal.result
1 parent 462d689 commit 6434e49

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

mysql-test/suite/engines/iuds/r/insert_decimal.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ total_rows min_value max_value sum avg
11511151
7 -100000.00000 100000.00000 -99.15000 -16.525000509
11521152
SELECT count(*) as total_rows, min(c3) as min_value, max(c3) as max_value, sum(c3) as sum, avg(c3) as avg FROM t1;
11531153
total_rows min_value max_value sum avg
1154-
7 -0.10000000149011612 111111112111211212.95000306 18535202.15833384
1154+
7 -0.1 111111000111211212.95000306 18535202.15833384
11551155
SELECT count(*) as total_rows, min(c1) as min_value, max(c1) as max_value, sum(c1) as sum, avg(c1) as avg FROM t2;
11561156
total_rows min_value max_value sum avg
11571157
30 -10000000000 10000000000 31322222339 1044074077.9667
@@ -1160,7 +1160,7 @@ total_rows min_value max_value sum avg
11601160
30 0 10000000000 43444444564 1448148152.1333
11611161
SELECT count(*) as total_rows, min(c3) as min_value, max(c3) as max_value, sum(c3) as sum, avg(c3) as avg FROM t2;
11621162
total_rows min_value max_value sum avg
1163-
30 -3.4028234663852886e383.4028234663852886e381.0208470399155866e39 3.4028234663852886e37
1163+
30 -3.40282e383.40282e381.0208470399155866e39 3.4028234663852886e37
11641164
SELECT * FROM t1;
11651165
c1 c2 c3 c4
11661166
0.00000 -0.10000 -0.1 13

sql/item.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10168,7 +10168,7 @@ String* Item_cache_float::val_str(String *str)
1016810168
DBUG_ASSERT(fixed == 1);
1016910169
if (!has_value())
1017010170
return NULL;
10171-
Float((float) value).to_string(str, decimals);
10171+
Float(value).to_string(str, decimals);
1017210172
return str;
1017310173
}
1017410174

sql/sql_type_real.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ class Float
2323
public:
2424
Float(float nr)
2525
:m_value(nr)
26-
{ }
26+
{
27+
DBUG_ASSERT(!std::isnan(nr));
28+
DBUG_ASSERT(!std::isinf(nr));
29+
}
30+
Float(double nr)
31+
:m_value((float) nr)
32+
{
33+
DBUG_ASSERT(!std::isnan(nr));
34+
DBUG_ASSERT(!std::isinf(nr));
35+
DBUG_ASSERT(nr <= FLT_MAX);
36+
DBUG_ASSERT(nr >= -FLT_MAX);
37+
}
2738
Float(const uchar *ptr)
2839
{
2940
float4get(m_value, ptr);

0 commit comments

Comments
 (0)