Details
-
Task
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
6.1.1
-
None
Description
We have at least two implementations of string-to-decimal conversion:
- dataconvert::number_int_value(), which is used either directly or inside the wrapper SystemCatalog::TypeAttributesStd::decimal128FromString().
- Func_cast_decimal::getDecimalVal()
These two implementations have a lot of duplicate code and have problems:
MCOL-4462- This problem existed for a long timeMCOL-4500- This problem was introduced byMCOL-4464MCOL-4532- Introduced byMCOL-641- They use a lot of std::string objects copying and padding, which is not performance friendly.
Under terms of this task we'll do the following:
- Introduce a new implementation of a string-to-decimal conversion function which won't have the mentioned bugs
- The new function should not do any std::string copying/padding and should only use the source string (and therefore should hopefully be faster). It should only iterate on the source string.
- The new function should get a const char * pointer and its length instead of a '\0' terminated C-style string. This is to avoid calling string::c_ptr() which is also not performance friendly.
- Add a new constructor:
Decimal::Decimal(const char *str, size_t length, DataCondition & convError,
int8_t s, uint8_t p)
which will use the new conversion function internally.
- Replace the code in GenericToBitOperand() in func_bit.cc to the new function call
- Replace the code in Func_cast_decimal::getDecimalVal() to thew new constructor call
Further steps
Note, after these changes, the functions dataconvert::number_int_value() and SystemCatalog::TypeAttributesStd::decimal128FromString() will still exist.
Later, under terms of a separate tasks (or even multiple tasks), we'll:
- Replace all remaining calls for dataconvert::number_int_value() to the new functionality.
- Replace all remaining calls for SystemCatalog::TypeAttributesStd::decimal128FromString() to the new functionality.
- Remove dataconvert::number_int_value() and SystemCatalog::TypeAttributesStd::decimal128FromString() completely.
Attachments
Issue Links
- blocks
-
MCOL-4462 CAST(varchar_expr AS DECIMAL(M,N)) returns a wrong result
- Closed
-
MCOL-4500 Bit functions processing throws internally trying to cast char into decimal representation
- Closed
-
MCOL-4532 CAST(AS DECIMAL) returns a garbage for large values
- Closed
- relates to
-
MCOL-4464 Bitwise operations not like in MariaDB
- Closed
-
MDEV-24790 CAST('0e1111111111' AS DECIMAL(38,0)) returns a wrong result
- Closed