diff options
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/sql/field.cc b/sql/field.cc index 7c1798b983e..efc20fa37fc 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3054,6 +3054,23 @@ void Field_decimal::sql_type(String &res) const } +Field *Field_decimal::make_new_field(MEM_ROOT *root, TABLE *new_table, + bool keep_type) +{ + if (keep_type) + return Field_real::make_new_field(root, new_table, keep_type); + + Field *field= new (root) Field_new_decimal(NULL, field_length, + maybe_null() ? (uchar*) "" : 0, 0, + NONE, &field_name, + dec, flags & ZEROFILL_FLAG, + unsigned_flag); + if (field) + field->init_for_make_new_field(new_table, orig_table); + return field; +} + + /**************************************************************************** ** Field_new_decimal ****************************************************************************/ @@ -7473,15 +7490,7 @@ Field *Field_string::make_new_field(MEM_ROOT *root, TABLE *new_table, This is done to ensure that ALTER TABLE will convert old VARCHAR fields to now VARCHAR fields. */ - field->init(new_table); - /* - Normally orig_table is different from table only if field was - created via ::make_new_field. Here we alter the type of field, - so ::make_new_field is not applicable. But we still need to - preserve the original field metadata for the client-server - protocol. - */ - field->orig_table= orig_table; + field->init_for_make_new_field(new_table, orig_table); } return field; } |