diff options
author | Monty <monty@mariadb.org> | 2016-06-18 14:28:34 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2016-06-22 22:04:55 +0300 |
commit | 34eb10e4064a7f38fc7d41016a6bcc5443ebe0c3 (patch) | |
tree | 45f76f02034419697e5bff5f539b20eaac8f8c8d /sql/item_sum.cc | |
parent | e4062d4d203a6be596d3f61dfe4db1b4f91e24aa (diff) | |
download | mariadb-git-34eb10e4064a7f38fc7d41016a6bcc5443ebe0c3.tar.gz |
MDEV-10138 Support for decimals up to 38 digits
Decimals with float, double and decimal now works the following way:
- DECIMAL_NOT_SPECIFIED is used when declaring DECIMALS without a firm number
of decimals. It's only used in asserts and my_decimal_int_part.
- FLOATING_POINT_DECIMALS (31) is used to mark that a FLOAT or DOUBLE
was defined without decimals. This is regarded as a floating point value.
- Max decimals allowed for FLOAT and DOUBLE is FLOATING_POINT_DECIMALS-1
- Clients assumes that float and double with decimals >= NOT_FIXED_DEC are
floating point values (no decimals)
- In the .frm decimals=FLOATING_POINT_DECIMALS are used to define
floating point for float and double (31, like before)
To ensure compatibility with old clients we do:
- When storing float and double, we change NOT_FIXED_DEC to
FLOATING_POINT_DECIMALS.
- When creating fields from .frm we change for float and double
FLOATING_POINT_DEC to NOT_FIXED_DEC
- When sending definition for a float/decimal field without decimals
to the client as part of a result set we convert NOT_FIXED_DEC to
FLOATING_POINT_DECIMALS.
- variance() and std() has changed to limit the decimals to
FLOATING_POINT_DECIMALS -1 to not get the double converted floating point.
(This was to preserve compatiblity)
- FLOAT and DOUBLE still have 30 as max number of decimals.
Bugs fixed:
variance() printed more decimals than we support for double values.
New behaviour:
- Strings now have 38 decimals instead of 30 when converted to decimal
- CREATE ... SELECT with a decimal with > 30 decimals will create a column
with a smaller range than before as we are trying to preserve the number of
decimals.
Other changes
- We are now using the obsolete bit FIELDFLAG_LEFT_FULLSCREEN to specify
decimals > 31
- NOT_FIXED_DEC is now declared in one place
- For clients, NOT_FIXED_DEC is always 31 (to ensure compatibility).
On the server NOT_FIXED_DEC is DECIMAL_NOT_SPECIFIED (39)
- AUTO_SEC_PART_DIGITS is taken from DECIMAL_NOT_SPECIFIED
- DOUBLE conversion functions are now using DECIMAL_NOT_SPECIFIED instead of
NOT_FIXED_DEC
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r-- | sql/item_sum.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc index f774ee5a561..f7e02bc55f9 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1624,7 +1624,8 @@ void Item_sum_avg::fix_length_and_dec() } else { - decimals= MY_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC); + decimals= MY_MIN(args[0]->decimals + prec_increment, + FLOATING_POINT_DECIMALS); max_length= MY_MIN(args[0]->max_length + prec_increment, float_length(decimals)); } } @@ -1839,13 +1840,14 @@ void Item_sum_variance::fix_length_and_dec() switch (args[0]->result_type()) { case REAL_RESULT: case STRING_RESULT: - decimals= MY_MIN(args[0]->decimals + 4, NOT_FIXED_DEC); + decimals= MY_MIN(args[0]->decimals + 4, FLOATING_POINT_DECIMALS); break; case INT_RESULT: case DECIMAL_RESULT: { int precision= args[0]->decimal_precision()*2 + prec_increment; - decimals= MY_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE); + decimals= MY_MIN(args[0]->decimals + prec_increment, + FLOATING_POINT_DECIMALS-1); max_length= my_decimal_precision_to_length_no_truncation(precision, decimals, unsigned_flag); |