summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-01-07 17:44:18 +0100
committerunknown <jimw@mysql.com>2005-01-07 17:44:18 +0100
commit0c57a67ce0434fa78e2b64f569a271d166371a32 (patch)
tree9a7f02c79ea56ff312e753cadcecc4efe3a60f3a /sql
parent9ad1b390fcf12ec7aa7b9fad157d6e0a61045b40 (diff)
downloadmariadb-git-0c57a67ce0434fa78e2b64f569a271d166371a32.tar.gz
Correctly truncate integers inserted into field and double columns
with a number of decimals specified. (Bug #7361) mysql-test/t/type_float.test: Add test for maximum values of float and double columns with number of decimals mysql-test/r/type_float.result: Add results for new test mysql-test/r/type_float.result.es: Add results for new test sql/field.cc: Use ::store(double nr) from ::store(longlong nr) so we get the same range checking
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc36
1 files changed, 2 insertions, 34 deletions
diff --git a/sql/field.cc b/sql/field.cc
index b27a319b00e..e2c11cc7372 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2395,23 +2395,7 @@ int Field_float::store(double nr)
int Field_float::store(longlong nr)
{
- int error= 0;
- float j= (float) nr;
- if (unsigned_flag && j < 0)
- {
- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
- j=0;
- error= 1;
- }
-#ifdef WORDS_BIGENDIAN
- if (table->db_low_byte_first)
- {
- float4store(ptr,j);
- }
- else
-#endif
- memcpy_fixed(ptr,(byte*) &j,sizeof(j));
- return error;
+ return store((double)nr);
}
@@ -2690,23 +2674,7 @@ int Field_double::store(double nr)
int Field_double::store(longlong nr)
{
- double j= (double) nr;
- int error= 0;
- if (unsigned_flag && j < 0)
- {
- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
- error= 1;
- j=0;
- }
-#ifdef WORDS_BIGENDIAN
- if (table->db_low_byte_first)
- {
- float8store(ptr,j);
- }
- else
-#endif
- doublestore(ptr,j);
- return error;
+ return store((double)nr);
}