Commit f92fd7c9 authored by unknown's avatar unknown

Fix for bug #18014: data loss caused by altering decimal fields.


mysql-test/r/type_newdecimal.result:
  Fix for bug #18014: data loss caused by altering decimal fields.
    - test result
mysql-test/t/type_newdecimal.test:
  Fix for bug #18014: data loss caused by altering decimal fields.
    - test case
sql/field.cc:
  Fix for bug #18014: data loss caused by altering decimal fields.
    - Field_new_decimal::is_equal() introduced for proper comparisons of the decimal field definitions.
sql/field.h:
  Fix for bug #18014: data loss caused by altering decimal fields.
    - Field_new_decimal::is_equal() introduced for proper comparisons of the decimal field definitions.
parent 2ac90a72
......@@ -1397,3 +1397,13 @@ c1
9999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999
drop table t1;
create table t1(a decimal(7,2));
insert into t1 values(123.12);
select * from t1;
a
123.12
alter table t1 modify a decimal(10,2);
select * from t1;
a
123.12
drop table t1;
......@@ -1095,3 +1095,14 @@ insert into t1 values(
insert into t1 values(1e100);
select * from t1;
drop table t1;
#
# Bug #18014: problem with 'alter table'
#
create table t1(a decimal(7,2));
insert into t1 values(123.12);
select * from t1;
alter table t1 modify a decimal(10,2);
select * from t1;
drop table t1;
......@@ -2604,6 +2604,18 @@ void Field_new_decimal::sql_type(String &str) const
}
uint Field_new_decimal::is_equal(create_field *new_field)
{
return ((new_field->sql_type == real_type()) &&
((new_field->flags & UNSIGNED_FLAG) ==
(uint) (flags & UNSIGNED_FLAG)) &&
((new_field->flags & AUTO_INCREMENT_FLAG) ==
(uint) (flags & AUTO_INCREMENT_FLAG)) &&
(new_field->length == max_length()) &&
(new_field->decimals == dec));
}
/****************************************************************************
** tiny int
****************************************************************************/
......
......@@ -514,6 +514,7 @@ class Field_new_decimal :public Field_num {
uint32 max_length() { return field_length; }
uint size_of() const { return sizeof(*this); }
uint32 pack_length() const { return (uint32) bin_size; }
uint is_equal(create_field *new_field);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment