diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-09-26 20:49:51 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-09-28 16:37:06 +0200 |
commit | 57e0da50bbef8164635317785b67dd468a908327 (patch) | |
tree | 89d1ed179afce8b040c8f2dfcfe179042ff27b2e /sql/field.cc | |
parent | 7aba6f8f8853acd18d471793f8b72aa1412b8151 (diff) | |
parent | dcbd51cee628d8d8fec9ff5476a6afc855b007aa (diff) | |
download | mariadb-git-57e0da50bbef8164635317785b67dd468a908327.tar.gz |
Merge branch '10.2' into 10.3
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sql/field.cc b/sql/field.cc index 7eb277e23d8..4ba31e17fa4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3075,6 +3075,12 @@ Field *Field_decimal::make_new_field(MEM_ROOT *root, TABLE *new_table, ** Field_new_decimal ****************************************************************************/ +static uint get_decimal_precision(uint len, uint8 dec, bool unsigned_val) +{ + uint precision= my_decimal_length_to_precision(len, dec, unsigned_val); + return MY_MIN(precision, DECIMAL_MAX_PRECISION); +} + Field_new_decimal::Field_new_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, @@ -3085,8 +3091,7 @@ Field_new_decimal::Field_new_decimal(uchar *ptr_arg, :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, dec_arg, zero_arg, unsigned_arg) { - precision= my_decimal_length_to_precision(len_arg, dec_arg, unsigned_arg); - set_if_smaller(precision, DECIMAL_MAX_PRECISION); + precision= get_decimal_precision(len_arg, dec_arg, unsigned_arg); DBUG_ASSERT((precision <= DECIMAL_MAX_PRECISION) && (dec <= DECIMAL_MAX_SCALE)); bin_size= my_decimal_get_binary_size(precision, dec); @@ -4528,7 +4533,7 @@ longlong Field_float::val_int(void) { float j; float4get(j,ptr); - return (longlong) rint(j); + return Converter_double_to_longlong(j, false).result(); } @@ -10289,12 +10294,9 @@ void Column_definition::create_length_to_internal_length_bit() void Column_definition::create_length_to_internal_length_newdecimal() { - key_length= pack_length= - my_decimal_get_binary_size(my_decimal_length_to_precision((uint) length, - decimals, - flags & - UNSIGNED_FLAG), - decimals); + DBUG_ASSERT(length < UINT_MAX32); + uint prec= get_decimal_precision((uint)length, decimals, flags & UNSIGNED_FLAG); + key_length= pack_length= my_decimal_get_binary_size(prec, decimals); } |