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

clang format apply

This commit is contained in:
Leonid Fedorov
2022-02-11 12:24:40 +00:00
parent 509f005be7
commit 7c808317dc
1367 changed files with 394342 additions and 413129 deletions

View File

@@ -16,10 +16,10 @@
MA 02110-1301, USA. */
/****************************************************************************
* $Id: func_maketime.cpp 2665 2011-06-01 20:42:52Z rdempsey $
*
*
****************************************************************************/
* $Id: func_maketime.cpp 2665 2011-06-01 20:42:52Z rdempsey $
*
*
****************************************************************************/
#include <cstdlib>
#include <string>
@@ -37,147 +37,138 @@ using namespace dataconvert;
namespace funcexp
{
CalpontSystemCatalog::ColType Func_maketime::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
CalpontSystemCatalog::ColType Func_maketime::operationType(FunctionParm& fp,
CalpontSystemCatalog::ColType& resultType)
{
return resultType;
return resultType;
}
string Func_maketime::getStrVal(rowgroup::Row& row,
FunctionParm& parm,
bool& isNull,
string Func_maketime::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
CalpontSystemCatalog::ColType&)
{
int64_t hour = 0;
int64_t min = 0;
int64_t sec = 0;
int64_t hour = 0;
int64_t min = 0;
int64_t sec = 0;
//get hour
switch (parm[0]->data()->resultType().colDataType)
// get hour
switch (parm[0]->data()->resultType().colDataType)
{
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
double value = parm[0]->data()->getDoubleVal(row, isNull);
hour = (int64_t) value;
break;
}
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
hour = parm[0]->data()->getDecimalVal(row, isNull).toSInt64Round();
break;
}
default:
isNull = true;
return "";
double value = parm[0]->data()->getDoubleVal(row, isNull);
hour = (int64_t)value;
break;
}
//get minute
switch (parm[1]->data()->resultType().colDataType)
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
double value = parm[1]->data()->getDoubleVal(row, isNull);
min = (int64_t) value;
break;
}
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
min = parm[1]->data()->getDecimalVal(row, isNull).toSInt64Round();
break;
}
default:
isNull = true;
return "";
hour = parm[0]->data()->getDecimalVal(row, isNull).toSInt64Round();
break;
}
if (min < 0 || min > 59)
default: isNull = true; return "";
}
// get minute
switch (parm[1]->data()->resultType().colDataType)
{
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
isNull = true;
return "";
double value = parm[1]->data()->getDoubleVal(row, isNull);
min = (int64_t)value;
break;
}
//get second
switch (parm[2]->data()->resultType().colDataType)
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
double value = parm[2]->data()->getDoubleVal(row, isNull);
sec = (int64_t) value;
break;
}
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
sec = parm[2]->data()->getDecimalVal(row, isNull).toSInt64Round();
break;
}
default:
isNull = true;
return "";
min = parm[1]->data()->getDecimalVal(row, isNull).toSInt64Round();
break;
}
if (sec < 0 || sec > 59)
default: isNull = true; return "";
}
if (min < 0 || min > 59)
{
isNull = true;
return "";
}
// get second
switch (parm[2]->data()->resultType().colDataType)
{
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
isNull = true;
return "";
double value = parm[2]->data()->getDoubleVal(row, isNull);
sec = (int64_t)value;
break;
}
if (hour > 838)
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
hour = 838;
min = 59;
sec = 59;
sec = parm[2]->data()->getDecimalVal(row, isNull).toSInt64Round();
break;
}
if (hour < -838)
{
hour = -838;
min = 59;
sec = 59;
}
default: isNull = true; return "";
}
// in worst case hour is 4 characters (3 digits + '-') so max
// string length is 11 (4:2:2 + '\0')
char buf[11];
snprintf(buf, 11, "%02d:%02d:%02d", (int) hour, (int) min, (int) sec);
return buf;
if (sec < 0 || sec > 59)
{
isNull = true;
return "";
}
if (hour > 838)
{
hour = 838;
min = 59;
sec = 59;
}
if (hour < -838)
{
hour = -838;
min = 59;
sec = 59;
}
// in worst case hour is 4 characters (3 digits + '-') so max
// string length is 11 (4:2:2 + '\0')
char buf[11];
snprintf(buf, 11, "%02d:%02d:%02d", (int)hour, (int)min, (int)sec);
return buf;
}
} // namespace funcexp
} // namespace funcexp
// vim:ts=4 sw=4: