From 490e220ad2cf14321f18841a3e6c60fcb12a322e Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 24 Aug 2018 21:03:22 +0300 Subject: MDEV-17067 Server crash in write_block_record Problem was that Create_field::create_length_to_internal_length() calculated a different pack_length for NEWDECIMAL compared to Field_new_decimal constructor which lead to some unused bytes in the middle of the record, which Aria didn't like. --- sql/field.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index a9a7d54929b..1427e055324 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9065,13 +9065,18 @@ void Create_field::create_length_to_internal_length(void) } break; case MYSQL_TYPE_NEWDECIMAL: - key_length= pack_length= - my_decimal_get_binary_size(my_decimal_length_to_precision(length, - decimals, - flags & - UNSIGNED_FLAG), - decimals); + { + /* + This code must be identical to code in + Field_new_decimal::Field_new_decimal as otherwise the record layout + gets out of sync. + */ + uint precision= my_decimal_length_to_precision(length, decimals, + flags & UNSIGNED_FLAG); + set_if_smaller(precision, DECIMAL_MAX_PRECISION); + key_length= pack_length= my_decimal_get_binary_size(precision, decimals); break; + } default: key_length= pack_length= calc_pack_length(sql_type, length); break; -- cgit v1.2.1