summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-08-24 21:03:22 +0300
committerMonty <monty@mariadb.org>2018-08-24 21:03:22 +0300
commit490e220ad2cf14321f18841a3e6c60fcb12a322e (patch)
tree2d8e730648bafdee09d48a7806ae8febeed2b5e0 /sql/field.cc
parentf195286a3eae6328a1f90948205e90201c0479c5 (diff)
downloadmariadb-git-490e220ad2cf14321f18841a3e6c60fcb12a322e.tar.gz
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.
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc17
1 files changed, 11 insertions, 6 deletions
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;