diff options
author | unknown <msvensson@pilot.blaudden> | 2007-03-16 14:29:18 +0100 |
---|---|---|
committer | unknown <msvensson@pilot.blaudden> | 2007-03-16 14:29:18 +0100 |
commit | 8d1ab8b4b07fdec87980ed55b794b9726c1fc21f (patch) | |
tree | 9a9bb63e91c890d03221279a63d81a1fff357d45 | |
parent | d8dd784ff4ce92ddbe60c412434d08e019c1a611 (diff) | |
parent | ff07adaec417cf39d455f48f173630669a559b56 (diff) | |
download | mariadb-git-8d1ab8b4b07fdec87980ed55b794b9726c1fc21f.tar.gz |
Merge bk-internal:/home/bk/mysql-5.0-maint
into pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
-rw-r--r-- | mysql-test/r/type_newdecimal.result | 8 | ||||
-rw-r--r-- | mysql-test/t/type_newdecimal.test | 11 | ||||
-rw-r--r-- | sql/field_conv.cc | 9 |
3 files changed, 28 insertions, 0 deletions
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index e65e76ded3f..359a929d9a3 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -1423,3 +1423,11 @@ cast(19999999999999999999 as unsigned) 18446744073709551615 Warnings: Error 1292 Truncated incorrect DECIMAL value: '' +create table t1(a decimal(18)); +insert into t1 values(123456789012345678); +alter table t1 modify column a decimal(19); +select * from t1; +a +123456789012345678 +drop table t1; +End of 5.0 tests diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index f315e88fd0e..4c6098d2121 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -1120,3 +1120,14 @@ drop table t1; # select cast(19999999999999999999 as unsigned); +# +# Bug #24558: Increasing decimal column length causes data loss +# + +create table t1(a decimal(18)); +insert into t1 values(123456789012345678); +alter table t1 modify column a decimal(19); +select * from t1; +drop table t1; + +--echo End of 5.0 tests 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) { |