diff options
author | unknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru> | 2007-03-15 12:06:06 +0400 |
---|---|---|
committer | unknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru> | 2007-03-15 12:06:06 +0400 |
commit | 9e5691cb331b98188ab3ffc324f9c3e3fa87cb0c (patch) | |
tree | b13114b0e6e341f7a1dc245e5fc11a90e235a593 /sql/field_conv.cc | |
parent | d6bd171fd2ecf9a58c2dcd3f34b9b248c7ac62ba (diff) | |
download | mariadb-git-9e5691cb331b98188ab3ffc324f9c3e3fa87cb0c.tar.gz |
Fix for bug #24558: Increasing decimal column length causes data loss
Altering to a decimal field we get double value then store it
that may cause data loss.
Fix: use store_decimal() instead.
mysql-test/r/type_newdecimal.result:
Fix for bug #24558: Increasing decimal column length causes data loss
- test result.
mysql-test/t/type_newdecimal.test:
Fix for bug #24558: Increasing decimal column length causes data loss
- test case.
sql/field_conv.cc:
Fix for bug #24558: Increasing decimal column length causes data loss
- if target field's result type is DECIMAL_RESULT
use store_decimal(val_decimal()) in order not to loss data.
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r-- | sql/field_conv.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc index dbe58d804ad..32180f0a93e 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -337,6 +337,13 @@ static void do_field_real(Copy_field *copy) } +static void do_field_decimal(Copy_field *copy) +{ + my_decimal value; + copy->to_field->store_decimal(copy->from_field->val_decimal(&value)); +} + + /* string copy for single byte characters set when to string is shorter than from string @@ -581,6 +588,8 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*) if (to->real_type() == FIELD_TYPE_BIT || from->real_type() == FIELD_TYPE_BIT) return do_field_int; + if (to->result_type() == DECIMAL_RESULT) + return do_field_decimal; // Check if identical fields if (from->result_type() == STRING_RESULT) { |