1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-5215 Fix overflow of UNION operation involving DECIMAL datatypes.

When a UNION operation involving DECIMAL datatypes with scale and digits
before the decimal exceeds the currently supported maximum precision
of 38, we throw an error to the user:
"MCS-2060: Union operation exceeds maximum DECIMAL precision of 38".

This is until MCOL-5417 is implemented where ColumnStore will have
full parity with MariaDB server in terms of maximum supported DECIMAL
precision and scale of 65 and 38 digits respectively.
This commit is contained in:
Gagan Goel
2023-02-17 05:22:34 -05:00
parent 8cdcae0d2f
commit 86dcf92d56
10 changed files with 123 additions and 70 deletions

View File

@ -2934,7 +2934,8 @@ int64_t DataConvert::stringToTime(const string& data)
}
void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& unionedType,
const datatypes::SystemCatalog::TypeHolderStd& type)
const datatypes::SystemCatalog::TypeHolderStd& type,
unsigned int& rc)
{
// limited support for VARBINARY, no implicit conversion.
if (type.colDataType == datatypes::SystemCatalog::VARBINARY ||
@ -2974,6 +2975,19 @@ void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& u
case datatypes::SystemCatalog::UBIGINT:
case datatypes::SystemCatalog::UDECIMAL:
if (type.scale != 0)
{
const unsigned int digitsBeforeDecimal = type.precision - type.scale;
const unsigned int digitsBeforeDecimalUnion = unionedType.precision - unionedType.scale;
if ((std::max(digitsBeforeDecimal, digitsBeforeDecimalUnion) +
std::max(type.scale, unionedType.scale)) > datatypes::INT128MAXPRECISION)
{
rc = logging::ERR_UNION_DECIMAL_OVERFLOW;
return;
}
}
unionedType.precision = std::max(type.precision, unionedType.precision);
unionedType.scale = std::max(type.scale, unionedType.scale);

View File

@ -1290,7 +1290,8 @@ class DataConvert
EXPORT static int64_t stringToTime(const std::string& data);
// bug4388, union type conversion
EXPORT static void joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& unionedType,
const datatypes::SystemCatalog::TypeHolderStd& type);
const datatypes::SystemCatalog::TypeHolderStd& type,
unsigned int& rc);
static boost::any StringToBit(const datatypes::SystemCatalog::TypeAttributesStd& colType,
const datatypes::ConvertFromStringParam& prm, const std::string& dataOrig,