diff options
-rw-r--r-- | mysql-test/r/type_newdecimal.result | 10 | ||||
-rw-r--r-- | mysql-test/t/type_newdecimal.test | 11 | ||||
-rw-r--r-- | sql/field.cc | 12 | ||||
-rw-r--r-- | sql/field.h | 1 |
4 files changed, 34 insertions, 0 deletions
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index 702b589c911..a6cf657a278 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -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; diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 74782a5bddb..22f746d0220 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -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; diff --git a/sql/field.cc b/sql/field.cc index 1f65adca2d5..4b5fffaabf9 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -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 ****************************************************************************/ diff --git a/sql/field.h b/sql/field.h index 2ac7ec2c69d..f611b16277e 100644 --- a/sql/field.h +++ b/sql/field.h @@ -514,6 +514,7 @@ public: 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); }; |