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
MCOL-4387 Convert dataconvert::decimalToString() into VDecimal and TSInt128 methods
This commit is contained in:
@ -542,15 +542,10 @@ string Func_cast_char::getStrVal(Row& row,
|
||||
{
|
||||
IDB_Decimal d = parm[0]->data()->getDecimalVal(row, isNull);
|
||||
|
||||
char buf[80];
|
||||
|
||||
if (parm[0]->data()->resultType().colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
dataconvert::DataConvert::decimalToString( &d.s128Value, d.scale, buf, 80, parm[0]->data()->resultType().colDataType);
|
||||
return d.toString(true).substr(0, length);
|
||||
else
|
||||
dataconvert::DataConvert::decimalToString( d.value, d.scale, buf, 80, parm[0]->data()->resultType().colDataType);
|
||||
|
||||
string sbuf = buf;
|
||||
return sbuf.substr(0, length);
|
||||
return d.toString().substr(0, length);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1231,17 +1226,10 @@ string Func_cast_decimal::getStrVal(Row& row,
|
||||
parm,
|
||||
isNull,
|
||||
operationColType);
|
||||
|
||||
char buf[80];
|
||||
|
||||
if (decimal.precision > datatypes::INT64MAXPRECISION)
|
||||
dataconvert::DataConvert::decimalToString( &decimal.s128Value, decimal.scale, buf, 80, operationColType.colDataType);
|
||||
if (operationColType.colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
return decimal.toString(true);
|
||||
else
|
||||
dataconvert::DataConvert::decimalToString( decimal.value, decimal.scale, buf, 80, operationColType.colDataType);
|
||||
|
||||
string value = buf;
|
||||
return value;
|
||||
|
||||
return decimal.toString();
|
||||
}
|
||||
|
||||
|
||||
|
@ -515,11 +515,11 @@ string Func_ceil::getStrVal(Row& row,
|
||||
|
||||
if (op_ct.colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
dataconvert::DataConvert::decimalToString(&d.s128Value, d.scale, tmp, 511, op_ct.colDataType);
|
||||
return d.toString(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataconvert::DataConvert::decimalToString(d.value, d.scale, tmp, 511, op_ct.colDataType);
|
||||
return d.toString();
|
||||
}
|
||||
}
|
||||
else if (isUnsigned(op_ct.colDataType))
|
||||
|
@ -436,11 +436,11 @@ string Func_floor::getStrVal(Row& row,
|
||||
|
||||
if (op_ct.colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
dataconvert::DataConvert::decimalToString(&d.s128Value, d.scale, tmp, 511, op_ct.colDataType);
|
||||
return d.toString(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataconvert::DataConvert::decimalToString(d.value, d.scale, tmp, 511, op_ct.colDataType);
|
||||
return d.toString();
|
||||
}
|
||||
}
|
||||
else if (isUnsigned(op_ct.colDataType))
|
||||
|
@ -1849,8 +1849,7 @@ string Func_format::getStrVal(Row& row,
|
||||
{
|
||||
IDB_Decimal decimal = parm[0]->data()->getDecimalVal(row, isNull);
|
||||
|
||||
char buf[80];
|
||||
|
||||
// This is an unacceptable way of doing rounding
|
||||
//perform rouding if needed
|
||||
if ( scale < 0 )
|
||||
scale = 0;
|
||||
@ -1912,9 +1911,7 @@ string Func_format::getStrVal(Row& row,
|
||||
|
||||
decimal.s128Value = x;
|
||||
}
|
||||
|
||||
dataconvert::DataConvert::decimalToString(&decimal.s128Value,
|
||||
decimal.scale, buf, 80, parm[0]->data()->resultType().colDataType);
|
||||
value = decimal.toString(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1973,12 +1970,8 @@ string Func_format::getStrVal(Row& row,
|
||||
|
||||
decimal.value = x;
|
||||
}
|
||||
|
||||
dataconvert::DataConvert::decimalToString( decimal.value,
|
||||
decimal.scale, buf, 80, parm[0]->data()->resultType().colDataType);
|
||||
value = decimal.toString();
|
||||
}
|
||||
|
||||
value = buf;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -116,18 +116,15 @@ inline bool getBool(rowgroup::Row& row,
|
||||
{
|
||||
IDB_Decimal d = pm[0]->data()->getDecimalVal(row, isNull);
|
||||
|
||||
char buf[80];
|
||||
|
||||
if (pm[0]->data()->resultType().colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
dataconvert::DataConvert::decimalToString(&d.s128Value, d.scale, buf, 80, pm[0]->data()->resultType().colDataType);
|
||||
expr = d.toString(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataconvert::DataConvert::decimalToString(d.value, d.scale, buf, 80, pm[0]->data()->resultType().colDataType);
|
||||
expr = d.toString();
|
||||
}
|
||||
|
||||
expr = buf;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -198,18 +195,14 @@ inline bool getBool(rowgroup::Row& row,
|
||||
{
|
||||
IDB_Decimal d = pm[1]->data()->getDecimalVal(row, isNull);
|
||||
|
||||
char buf[80];
|
||||
|
||||
if (pm[1]->data()->resultType().colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
dataconvert::DataConvert::decimalToString(&d.s128Value, d.scale, buf, 80, pm[1]->data()->resultType().colDataType);
|
||||
pattern = d.toString(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataconvert::DataConvert::decimalToString(d.value, d.scale, buf, 80, pm[1]->data()->resultType().colDataType);
|
||||
pattern = d.toString();
|
||||
}
|
||||
|
||||
pattern = buf;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -721,13 +721,9 @@ string Func_round::getStrVal(Row& row,
|
||||
}
|
||||
|
||||
if (!op_ct.isWideDecimalType())
|
||||
return dataconvert::DataConvert::decimalToString(x.value, x.scale, op_ct.colDataType);
|
||||
return x.toString();
|
||||
else
|
||||
{
|
||||
char buf[datatypes::Decimal::MAXLENGTH16BYTES];
|
||||
dataconvert::DataConvert::decimalToString( &x.s128Value, x.scale, buf, (uint8_t) sizeof(buf), op_ct.colDataType);
|
||||
return string(buf);
|
||||
}
|
||||
return x.toString(true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -740,13 +740,9 @@ string Func_truncate::getStrVal(Row& row,
|
||||
}
|
||||
|
||||
if (!op_ct.isWideDecimalType())
|
||||
return dataconvert::DataConvert::decimalToString(x.value, x.scale, op_ct.colDataType);
|
||||
return x.toString();
|
||||
else
|
||||
{
|
||||
char buf[datatypes::Decimal::MAXLENGTH16BYTES];
|
||||
dataconvert::DataConvert::decimalToString( &x.s128Value, x.scale, buf, (uint8_t) sizeof(buf), op_ct.colDataType);
|
||||
return string(buf);
|
||||
}
|
||||
return x.toString(true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -785,10 +785,6 @@ string longDoubleToString(long double ld)
|
||||
return buf;
|
||||
}
|
||||
|
||||
//@bug6146, remove duplicate function with incorrect impl. Use the DataConvert::decimalToString()
|
||||
//string decimalToString( execplan::IDB_Decimal x, int p )
|
||||
|
||||
|
||||
uint64_t dateAdd( uint64_t time, const std::string& expr, execplan::IntervalColumn::interval_type unit, bool dateType, execplan::OpType funcType );
|
||||
const std::string IDB_date_format(const dataconvert::DateTime&, const std::string&);
|
||||
const std::string timediff(int64_t, int64_t, bool isDateTime = true);
|
||||
|
Reference in New Issue
Block a user