summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/sql/field.cc b/sql/field.cc
index be9c10a3bae..57cf3deed35 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -3116,6 +3116,15 @@ Field *Field_decimal::make_new_field(MEM_ROOT *root, TABLE *new_table,
}
+void Field_new_decimal::set_and_validate_prec(uint32 len_arg,
+ uint8 dec_arg, bool unsigned_arg)
+{
+ precision= my_decimal_length_to_precision(len_arg, dec_arg, unsigned_arg);
+ set_if_smaller(precision, DECIMAL_MAX_PRECISION);
+ bin_size= my_decimal_get_binary_size(precision, dec);
+}
+
+
/****************************************************************************
** Field_new_decimal
****************************************************************************/
@@ -3134,12 +3143,10 @@ Field_new_decimal::Field_new_decimal(uchar *ptr_arg,
uint8 dec_arg,bool zero_arg,
bool unsigned_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)
+ unireg_check_arg, field_name_arg,
+ MY_MIN(dec_arg, DECIMAL_MAX_SCALE), zero_arg, unsigned_arg)
{
- 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);
+ set_and_validate_prec(len_arg, dec_arg, unsigned_arg);
}