mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
34eb10e406
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
51 lines
2 KiB
C
51 lines
2 KiB
C
#ifndef MY_DECIMAL_LIMITS_INCLUDED
|
|
#define MY_DECIMAL_LIMITS_INCLUDED
|
|
/* Copyright (c) 2011 Monty Program Ab
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#define DECIMAL_LONGLONG_DIGITS 22
|
|
#define DECIMAL_LONG_DIGITS 10
|
|
#define DECIMAL_LONG3_DIGITS 8
|
|
|
|
/** maximum length of buffer in our big digits (uint32). */
|
|
#define DECIMAL_BUFF_LENGTH 9
|
|
|
|
/* the number of digits that my_decimal can possibly contain */
|
|
#define DECIMAL_MAX_POSSIBLE_PRECISION (DECIMAL_BUFF_LENGTH * 9)
|
|
|
|
|
|
/**
|
|
maximum guaranteed precision of number in decimal digits (number of our
|
|
digits * number of decimal digits in one our big digit - number of decimal
|
|
digits in one our big digit decreased by 1 (because we always put decimal
|
|
point on the border of our big digits))
|
|
|
|
With normal precession we can handle 65 digits. MariaDB can store in
|
|
the .frm up to 63 digits. By default we use DECIMAL_NOT_SPECIFIED digits
|
|
when converting strings to decimal, so we don't want to set this too high.
|
|
To not use up all digits for the scale we limit the number of decimals to
|
|
38.
|
|
*/
|
|
#define DECIMAL_MAX_PRECISION (DECIMAL_MAX_POSSIBLE_PRECISION - 8*2)
|
|
#define DECIMAL_MAX_SCALE 38
|
|
#define DECIMAL_NOT_SPECIFIED 39
|
|
|
|
/**
|
|
maximum length of string representation (number of maximum decimal
|
|
digits + 1 position for sign + 1 position for decimal point, no terminator)
|
|
*/
|
|
#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_POSSIBLE_PRECISION + 2)
|
|
|
|
#endif /* MY_DECIMAL_LIMITS_INCLUDED */
|