aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-06-30 11:57:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-06-30 11:57:53 +0200
commitd0fae7d13d0484977a56cbdcb85e42b9854dfba5 (patch)
treecddd21a94b6f512d9017a4e67b76358b19fa86fe
parent2bc006daa59995085626b3e9c0754823bf9d95a5 (diff)
Take into account precision in MySQL FLOAT type parsing
-rw-r--r--odb/relational/mysql/context.cxx17
1 files changed, 16 insertions, 1 deletions
diff --git a/odb/relational/mysql/context.cxx b/odb/relational/mysql/context.cxx
index aa47b78..80a2695 100644
--- a/odb/relational/mysql/context.cxx
+++ b/odb/relational/mysql/context.cxx
@@ -347,6 +347,7 @@ namespace relational
state s (parse_prefix);
string prefix;
+ bool flt (false);
for (sql_token t (l.next ());
s != parse_done && t.type () != sql_token::t_eos;
@@ -423,7 +424,14 @@ namespace relational
r.type = sql_type::BIGINT;
r.unsign = true;
}
- else if (id == "FLOAT" || id == "FLOAT4")
+ else if (id == "FLOAT")
+ {
+ // Assign a type only once we know the precision of the
+ // float; it can be either 4 or 8 byte.
+ //
+ flt = true;
+ }
+ else if (id == "FLOAT4")
{
r.type = sql_type::FLOAT;
}
@@ -683,6 +691,13 @@ namespace relational
}
}
+ if (flt)
+ {
+ r.type = !r.range || r.range_value < 24
+ ? sql_type::FLOAT
+ : sql_type::DOUBLE;
+ }
+
if (r.type == sql_type::invalid)
{
cerr << m.file () << ":" << m.line () << ":" << m.column ()