Skip to content

Commit

Permalink
A cleanup for MDEV-19468 Hybrid type expressions return wrong format …
Browse files Browse the repository at this point in the history
…for FLOAT

Fixing problems revealed by buildbot:

- Fixing compilation failure on Windows
- Recoding correct engines/iuds/r/insert_decimal.result
  • Loading branch information
abarkov committed May 15, 2019
1 parent 462d689 commit 6434e49
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mysql-test/suite/engines/iuds/r/insert_decimal.result
Expand Up @@ -1151,7 +1151,7 @@ total_rows min_value max_value sum avg
7 -100000.00000 100000.00000 -99.15000 -16.525000509
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;
total_rows min_value max_value sum avg
7 -0.10000000149011612 111111112 111211212.95000306 18535202.15833384
7 -0.1 111111000 111211212.95000306 18535202.15833384
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;
total_rows min_value max_value sum avg
30 -10000000000 10000000000 31322222339 1044074077.9667
Expand All @@ -1160,7 +1160,7 @@ total_rows min_value max_value sum avg
30 0 10000000000 43444444564 1448148152.1333
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;
total_rows min_value max_value sum avg
30 -3.4028234663852886e38 3.4028234663852886e38 1.0208470399155866e39 3.4028234663852886e37
30 -3.40282e38 3.40282e38 1.0208470399155866e39 3.4028234663852886e37
SELECT * FROM t1;
c1 c2 c3 c4
0.00000 -0.10000 -0.1 13
Expand Down
2 changes: 1 addition & 1 deletion sql/item.cc
Expand Up @@ -10168,7 +10168,7 @@ String* Item_cache_float::val_str(String *str)
DBUG_ASSERT(fixed == 1);
if (!has_value())
return NULL;
Float((float) value).to_string(str, decimals);
Float(value).to_string(str, decimals);
return str;
}

Expand Down
13 changes: 12 additions & 1 deletion sql/sql_type_real.h
Expand Up @@ -23,7 +23,18 @@ class Float
public:
Float(float nr)
:m_value(nr)
{ }
{
DBUG_ASSERT(!std::isnan(nr));
DBUG_ASSERT(!std::isinf(nr));
}
Float(double nr)
:m_value((float) nr)
{
DBUG_ASSERT(!std::isnan(nr));
DBUG_ASSERT(!std::isinf(nr));
DBUG_ASSERT(nr <= FLT_MAX);
DBUG_ASSERT(nr >= -FLT_MAX);
}
Float(const uchar *ptr)
{
float4get(m_value, ptr);
Expand Down

0 comments on commit 6434e49

Please sign in to comment.