Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
Description
The code in Item::decimal_precision():
uint Item::decimal_precision() const |
{
|
Item_result restype= result_type();
|
|
if ((restype == DECIMAL_RESULT) || (restype == INT_RESULT)) |
{
|
uint prec=
|
my_decimal_length_to_precision(max_char_length(), decimals,
|
unsigned_flag);
|
return MY_MIN(prec, DECIMAL_MAX_PRECISION); |
}
|
uint res= max_char_length();
|
/* |
Return at least one decimal digit, even if Item::max_char_length()
|
returned 0. This is important to avoid attempts to create fields of types
|
INT(0) or DECIMAL(0,0) when converting NULL or empty strings to INT/DECIMAL:
|
CREATE TABLE t1 AS SELECT CONVERT(NULL,SIGNED) AS a;
|
*/
|
return res ? MY_MIN(res, DECIMAL_MAX_PRECISION) : 1; |
}
|
|
- is not friendly to pluggable types
- does not handle temporal types properly (e.g.
MDEV-12769)
We'll introduce a new method in Type_handler:
virtual uint Item_decimal_precision(const Item *item) const; |
and split Item::decimal_precision() into implementations of the relevant Type_handler_xxx.
The implementation of Item::decimal_precision() will change to:
|
virtual uint decimal_precision() const
{ return type_handler()->Item_decimal_precision(this); } {cpp}Attachments
Issue Links
- blocks
-
MDEV-4912 Data type plugin API version 1
- Closed
- relates to
-
MDEV-12769 Arithmetic operators with temporal types create excessive column types
- Closed