You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
Merge pull request #1836 from mariadb-corporation/bar-develop-MCOL-4618
A joint patch fixing MCOL-4618 and MCOL-4653:
This commit is contained in:
@ -97,22 +97,7 @@ int64_t Func_ceil::getIntVal(Row& row,
|
||||
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
if (op_ct.colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
ret = static_cast<int64_t>(d.getRoundedIntegralPart());
|
||||
}
|
||||
else
|
||||
{
|
||||
int64_t tmp = d.value;
|
||||
d.value /= helpers::powerOf10_c[d.scale];
|
||||
|
||||
// Add 1 if this is a positive number and there were values to the right of the
|
||||
// decimal point so that we return the largest integer value not less than X.
|
||||
if ((tmp - (d.value * helpers::powerOf10_c[d.scale])) > 0)
|
||||
d.value += 1;
|
||||
|
||||
ret = d.value;
|
||||
}
|
||||
ret = d.toSInt64Ceil();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -240,22 +225,7 @@ uint64_t Func_ceil::getUintVal(Row& row,
|
||||
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
if (op_ct.colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
ret = static_cast<uint64_t>(d.getRoundedIntegralPart());
|
||||
}
|
||||
else
|
||||
{
|
||||
int64_t tmp = d.value;
|
||||
d.value /= helpers::powerOf10_c[d.scale];
|
||||
|
||||
// Add 1 if this is a positive number and there were values to the right of the
|
||||
// decimal point so that we return the largest integer value not less than X.
|
||||
if ((tmp - (d.value * helpers::powerOf10_c[d.scale])) > 0)
|
||||
d.value += 1;
|
||||
|
||||
ret = (uint64_t) d.value;
|
||||
}
|
||||
ret = d.toUInt64Ceil();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -562,23 +532,7 @@ IDB_Decimal Func_ceil::getDecimalVal(Row& row,
|
||||
<< " with scale " << (int) ret.scale << " is beyond supported scale";
|
||||
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
if (op_ct.colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
ret = IDB_Decimal(ret.getRoundedIntegralPart(),
|
||||
ret.scale,
|
||||
ret.precision);
|
||||
}
|
||||
else
|
||||
{
|
||||
int64_t tmp = ret.value;
|
||||
ret.value /= helpers::powerOf10_c[ret.scale];
|
||||
|
||||
// Add 1 if this is a positive number and there were values to the right of the
|
||||
// decimal point so that we return the largest integer value not less than X.
|
||||
if ((tmp - (ret.value * helpers::powerOf10_c[ret.scale])) > 0)
|
||||
ret.value += 1;
|
||||
}
|
||||
return ret.ceil();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -138,16 +138,7 @@ int64_t Func_floor::getIntVal(Row& row,
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
IDB_Decimal tmp = getDecimalVal(row, parm, isNull, op_ct);
|
||||
|
||||
if (op_ct.colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
ret = static_cast<int64_t>(tmp.toTSInt128());
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = tmp.value;
|
||||
}
|
||||
ret = parm[0]->data()->getDecimalVal(row, isNull).toSInt64Floor();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -177,8 +168,6 @@ uint64_t Func_floor::getUintVal(Row& row,
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
ret = parm[0]->data()->getIntVal(row, isNull);
|
||||
}
|
||||
@ -268,6 +257,13 @@ uint64_t Func_floor::getUintVal(Row& row,
|
||||
}
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
ret = parm[0]->data()->getDecimalVal(row, isNull).toUInt64Floor();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@ -483,26 +479,7 @@ IDB_Decimal Func_floor::getDecimalVal(Row& row,
|
||||
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
if (op_ct.colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
int128_t tmp = ret.s128Value;
|
||||
int128_t scaleDivisor;
|
||||
datatypes::getScaleDivisor(scaleDivisor, ret.scale);
|
||||
ret.s128Value /= scaleDivisor;
|
||||
|
||||
// Largest integer value not greater than X.
|
||||
if (tmp < 0 && tmp < ret.s128Value)
|
||||
ret.s128Value -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int64_t tmp = ret.value;
|
||||
ret.value /= helpers::powerOf10_c[ret.scale];
|
||||
|
||||
// Largest integer value not greater than X.
|
||||
if (tmp < 0 && tmp < ret.value)
|
||||
ret.value -= 1;
|
||||
}
|
||||
return ret.floor();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user