You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +03:00
MCOL-1822 add LONG DOUBLE support
This commit is contained in:
@ -196,6 +196,24 @@ inline bool getBool(rowgroup::Row& row,
|
||||
numericLE(val, pm[2]->data()->getDoubleVal(row, isNull));
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::LONGDOUBLE:
|
||||
{
|
||||
long double val = pm[0]->data()->getLongDoubleVal(row, isNull);
|
||||
|
||||
if (notBetween)
|
||||
{
|
||||
if (!numericGE(val, pm[1]->data()->getLongDoubleVal(row, isNull)) && !isNull)
|
||||
return true;
|
||||
|
||||
isNull = false;
|
||||
return (!numericLE(val, pm[2]->data()->getLongDoubleVal(row, isNull)) && !isNull);
|
||||
}
|
||||
|
||||
return !isNull &&
|
||||
numericGE(val, pm[1]->data()->getLongDoubleVal(row, isNull)) &&
|
||||
numericLE(val, pm[2]->data()->getLongDoubleVal(row, isNull));
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
|
@ -123,6 +123,12 @@ int64_t Func_ceil::getIntVal(Row& row,
|
||||
}
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
{
|
||||
ret = (int64_t) ceill(parm[0]->data()->getLongDoubleVal(row, isNull));
|
||||
}
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
case CalpontSystemCatalog::TEXT:
|
||||
|
@ -103,6 +103,21 @@ string Func_hex::getStrVal(rowgroup::Row& row,
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
{
|
||||
char buf[256];
|
||||
long double val = parm[0]->data()->getLongDoubleVal(row, isNull);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
sprintf(buf, "%llA", val);
|
||||
|
||||
#else
|
||||
sprintf(buf, "%LA", val);
|
||||
#endif
|
||||
retval = buf;
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::VARBINARY:
|
||||
case CalpontSystemCatalog::BLOB:
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ std::string Func_substring_index::getStrVal(rowgroup::Row& row,
|
||||
if (isNull)
|
||||
return "";
|
||||
|
||||
int64_t count = fp[2]->data()->getIntVal(row, isNull);
|
||||
size_t count = fp[2]->data()->getIntVal(row, isNull);
|
||||
|
||||
if (isNull)
|
||||
return "";
|
||||
@ -71,7 +71,7 @@ std::string Func_substring_index::getStrVal(rowgroup::Row& row,
|
||||
|
||||
size_t end = strlen(str.c_str());
|
||||
|
||||
if ( count > (int64_t) end )
|
||||
if ( count > end )
|
||||
return str;
|
||||
|
||||
if (( count < 0 ) && ((count * -1) > end))
|
||||
@ -83,7 +83,7 @@ std::string Func_substring_index::getStrVal(rowgroup::Row& row,
|
||||
{
|
||||
int pointer = 0;
|
||||
|
||||
for ( int i = 0 ; i < count ; i ++ )
|
||||
for ( size_t i = 0 ; i < count ; i ++ )
|
||||
{
|
||||
string::size_type pos = str.find(delim, pointer);
|
||||
|
||||
@ -102,13 +102,13 @@ std::string Func_substring_index::getStrVal(rowgroup::Row& row,
|
||||
int pointer = end;
|
||||
int start = 0;
|
||||
|
||||
for ( int i = 0 ; i < count ; i ++ )
|
||||
for ( size_t i = 0 ; i < count ; i ++ )
|
||||
{
|
||||
string::size_type pos = str.rfind(delim, pointer);
|
||||
|
||||
if (pos != string::npos)
|
||||
{
|
||||
if ( count > (int64_t) end )
|
||||
if ( count > end )
|
||||
return "";
|
||||
|
||||
pointer = pos - 1;
|
||||
|
@ -439,6 +439,18 @@ void FuncExp::evaluate(rowgroup::Row& row, std::vector<execplan::SRCP>& expressi
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
{
|
||||
long double val = expression[i]->getLongDoubleVal(row, isNull);
|
||||
|
||||
if (isNull)
|
||||
row.setLongDoubleField(LONGDOUBLENULL, expression[i]->outputIndex());
|
||||
else
|
||||
row.setLongDoubleField(val, expression[i]->outputIndex());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
|
@ -57,6 +57,14 @@ public:
|
||||
return strtod(getStrVal(row, fp, isNull, op_ct).c_str(), NULL);
|
||||
}
|
||||
|
||||
double getLongDoubleVal(rowgroup::Row& row,
|
||||
FunctionParm& fp,
|
||||
bool& isNull,
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
return strtold(getStrVal(row, fp, isNull, op_ct).c_str(), NULL);
|
||||
}
|
||||
|
||||
#if 0
|
||||
std::string getStrVal(rowgroup::Row& row,
|
||||
FunctionParm& fp,
|
||||
@ -105,12 +113,16 @@ protected:
|
||||
// Bug3788, use the shorter of fixed or scientific notation for floating point values.
|
||||
// [ the default format in treenode.h is fixed-point notation ]
|
||||
char buf[20];
|
||||
double floatVal;
|
||||
int exponent;
|
||||
double base;
|
||||
long double floatVal;
|
||||
int64_t exponent;
|
||||
long double base;
|
||||
|
||||
switch (fp->data()->resultType().colDataType)
|
||||
{
|
||||
case execplan::CalpontSystemCatalog::LONGDOUBLE:
|
||||
floatVal = fp->data()->getLongDoubleVal(row, isNull);
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
floatVal = fp->data()->getDoubleVal(row, isNull);
|
||||
break;
|
||||
@ -125,19 +137,19 @@ protected:
|
||||
break;
|
||||
}
|
||||
|
||||
exponent = (int)floor(log10( fabs(floatVal)));
|
||||
exponent = (int)floor(log10( fabsl(floatVal)));
|
||||
base = floatVal * pow(10, -1.0 * exponent);
|
||||
|
||||
if (isnan(exponent) || isnan(base))
|
||||
{
|
||||
snprintf(buf, 20, "%f", floatVal);
|
||||
snprintf(buf, 20, "%Lf", floatVal);
|
||||
fFloatStr = execplan::removeTrailing0(buf, 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(buf, 20, "%.5f", base);
|
||||
snprintf(buf, 20, "%.5Lf", base);
|
||||
fFloatStr = execplan::removeTrailing0(buf, 20);
|
||||
snprintf(buf, 20, "e%02d", exponent);
|
||||
snprintf(buf, 20, "e%02ld", exponent);
|
||||
fFloatStr += buf;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user