You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-4957 Fix performance slowdown for processing TIMESTAMP columns.
Part 1: As part of MCOL-3776 to address synchronization issue while accessing the fTimeZone member of the Func class, mutex locks were added to the accessor and mutator methods. However, this slows down processing of TIMESTAMP columns in PrimProc significantly as all threads across all concurrently running queries would serialize on the mutex. This is because PrimProc only has a single global object for the functor class (class derived from Func in utils/funcexp/functor.h) for a given function name. To fix this problem: (1) We remove the fTimeZone as a member of the Func derived classes (hence removing the mutexes) and instead use the fOperationType member of the FunctionColumn class to propagate the timezone values down to the individual functor processing functions such as FunctionColumn::getStrVal(), FunctionColumn::getIntVal(), etc. (2) To achieve (1), a timezone member is added to the execplan::CalpontSystemCatalog::ColType class. Part 2: Several functors in the Funcexp code call dataconvert::gmtSecToMySQLTime() and dataconvert::mySQLTimeToGmtSec() functions for conversion between seconds since unix epoch and broken-down representation. These functions in turn call the C library function localtime_r() which currently has a known bug of holding a global lock via a call to __tz_convert. This significantly reduces performance in multi-threaded applications where multiple threads concurrently call localtime_r(). More details on the bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16145 This bug in localtime_r() caused processing of the Functors in PrimProc to slowdown significantly since a query execution causes Functors code to be processed in a multi-threaded manner. As a fix, we remove the calls to localtime_r() from gmtSecToMySQLTime() and mySQLTimeToGmtSec() by performing the timezone-to-offset conversion (done in dataconvert::timeZoneToOffset()) during the execution plan creation in the plugin. Note that localtime_r() is only called when the time_zone system variable is set to "SYSTEM". This fix also required changing the timezone type from a std::string to a long across the system.
This commit is contained in:
@ -171,7 +171,7 @@ int64_t Func_add_time::getTimestampIntVal(rowgroup::Row& row, FunctionParm& parm
|
||||
TimeStamp timestamp(val1);
|
||||
int64_t seconds = timestamp.second;
|
||||
MySQLTime m_time;
|
||||
gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
gmtSecToMySQLTime(seconds, m_time, ct.getTimeZone());
|
||||
dt1.year = m_time.year;
|
||||
dt1.month = m_time.month;
|
||||
dt1.day = m_time.day;
|
||||
|
@ -328,7 +328,7 @@ CalpontSystemCatalog::ColType Func_between::operationType(FunctionParm& fp,
|
||||
if (cc)
|
||||
{
|
||||
Result result = cc->result();
|
||||
result.intVal = dataconvert::DataConvert::timestampToInt(result.strVal, timeZone());
|
||||
result.intVal = dataconvert::DataConvert::timestampToInt(result.strVal, resultType.getTimeZone());
|
||||
cc->result(result);
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,8 @@ static datatypes::TUInt64Null DecimalToBitOperand(Row& row, const execplan::SPTP
|
||||
// and could be extracted into a utility class with its own header
|
||||
// if that is the case - this is left as future exercise
|
||||
datatypes::TUInt64Null GenericToBitOperand(Row& row, const execplan::SPTP& parm,
|
||||
const funcexp::Func& thisFunc, bool temporalRounding)
|
||||
const funcexp::Func& thisFunc, bool temporalRounding,
|
||||
long timeZone)
|
||||
{
|
||||
switch (parm->data()->resultType().colDataType)
|
||||
{
|
||||
@ -186,7 +187,7 @@ datatypes::TUInt64Null GenericToBitOperand(Row& row, const execplan::SPTP& parm,
|
||||
return datatypes::TUInt64Null();
|
||||
|
||||
TimeStamp dt(time);
|
||||
int64_t value = dt.convertToMySQLint(thisFunc.timeZone());
|
||||
int64_t value = dt.convertToMySQLint(timeZone);
|
||||
if (temporalRounding && dt.msecond >= 500000)
|
||||
value++;
|
||||
return datatypes::TUInt64Null((uint64_t)value);
|
||||
@ -222,8 +223,8 @@ class BitOperandGeneric : public datatypes::TUInt64Null
|
||||
BitOperandGeneric()
|
||||
{
|
||||
}
|
||||
BitOperandGeneric(Row& row, const execplan::SPTP& parm, const funcexp::Func& thisFunc)
|
||||
: TUInt64Null(GenericToBitOperand(row, parm, thisFunc, true))
|
||||
BitOperandGeneric(Row& row, const execplan::SPTP& parm, const funcexp::Func& thisFunc, long timeZone)
|
||||
: TUInt64Null(GenericToBitOperand(row, parm, thisFunc, true, timeZone))
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -236,8 +237,9 @@ class BitOperandGenericShiftAmount : public datatypes::TUInt64Null
|
||||
BitOperandGenericShiftAmount()
|
||||
{
|
||||
}
|
||||
BitOperandGenericShiftAmount(Row& row, const execplan::SPTP& parm, const funcexp::Func& thisFunc)
|
||||
: TUInt64Null(GenericToBitOperand(row, parm, thisFunc, false))
|
||||
BitOperandGenericShiftAmount(Row& row, const execplan::SPTP& parm, const funcexp::Func& thisFunc,
|
||||
long timeZone)
|
||||
: TUInt64Null(GenericToBitOperand(row, parm, thisFunc, false, timeZone))
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -327,7 +329,7 @@ class Func_bitand_return_uint64 : public Func_bitand
|
||||
CalpontSystemCatalog::ColType& operationColType) override
|
||||
{
|
||||
idbassert(parm.size() == 2);
|
||||
Arg2Lazy<TA, TB> args(row, parm, *this);
|
||||
Arg2Lazy<TA, TB> args(row, parm, *this, operationColType.getTimeZone());
|
||||
return (int64_t)(args.a & args.b).nullSafeValue(isNull);
|
||||
}
|
||||
};
|
||||
@ -353,7 +355,7 @@ class Func_leftshift_return_uint64 : public Func_leftshift
|
||||
CalpontSystemCatalog::ColType& operationColType) override
|
||||
{
|
||||
idbassert(parm.size() == 2);
|
||||
Arg2Eager<TA, BitOperandGenericShiftAmount> args(row, parm, *this);
|
||||
Arg2Eager<TA, BitOperandGenericShiftAmount> args(row, parm, *this, operationColType.getTimeZone());
|
||||
return (int64_t)args.a.MariaDBShiftLeft(args.b).nullSafeValue(isNull);
|
||||
}
|
||||
};
|
||||
@ -378,7 +380,7 @@ class Func_rightshift_return_uint64 : public Func_rightshift
|
||||
CalpontSystemCatalog::ColType& operationColType) override
|
||||
{
|
||||
idbassert(parm.size() == 2);
|
||||
Arg2Eager<TA, BitOperandGenericShiftAmount> args(row, parm, *this);
|
||||
Arg2Eager<TA, BitOperandGenericShiftAmount> args(row, parm, *this, operationColType.getTimeZone());
|
||||
return (int64_t)args.a.MariaDBShiftRight(args.b).nullSafeValue(isNull);
|
||||
}
|
||||
};
|
||||
@ -409,7 +411,7 @@ class Func_bitor_return_uint64 : public Func_bitor
|
||||
CalpontSystemCatalog::ColType& operationColType) override
|
||||
{
|
||||
idbassert(parm.size() == 2);
|
||||
Arg2Lazy<TA, TB> args(row, parm, *this);
|
||||
Arg2Lazy<TA, TB> args(row, parm, *this, operationColType.getTimeZone());
|
||||
return (int64_t)(args.a | args.b).nullSafeValue(isNull);
|
||||
}
|
||||
};
|
||||
@ -435,7 +437,7 @@ class Func_bitxor_return_uint64 : public Func_bitxor
|
||||
CalpontSystemCatalog::ColType& operationColType) override
|
||||
{
|
||||
idbassert(parm.size() == 2);
|
||||
Arg2Eager<TA, TB> args(row, parm, *this);
|
||||
Arg2Eager<TA, TB> args(row, parm, *this, operationColType.getTimeZone());
|
||||
return (int64_t)(args.a ^ args.b).nullSafeValue(isNull);
|
||||
}
|
||||
};
|
||||
@ -475,7 +477,7 @@ class Func_bit_count_return_uint64 : public Func_bit_count
|
||||
CalpontSystemCatalog::ColType& operationColType) override
|
||||
{
|
||||
idbassert(parm.size() == 1);
|
||||
return bitCount((uint64_t)TA(row, parm[0], *this).nullSafeValue(isNull));
|
||||
return bitCount((uint64_t)TA(row, parm[0], *this, operationColType.getTimeZone()).nullSafeValue(isNull));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -186,7 +186,7 @@ int64_t Func_cast_signed::getIntVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
int64_t time = parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||
|
||||
TimeStamp dt(time);
|
||||
return dt.convertToMySQLint(timeZone());
|
||||
return dt.convertToMySQLint(operationColType.getTimeZone());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -304,7 +304,7 @@ uint64_t Func_cast_unsigned::getUintVal(Row& row, FunctionParm& parm, bool& isNu
|
||||
int64_t time = parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||
|
||||
TimeStamp dt(time);
|
||||
return dt.convertToMySQLint(timeZone());
|
||||
return dt.convertToMySQLint(operationColType.getTimeZone());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -433,7 +433,7 @@ string Func_cast_char::getStrVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
return dataconvert::DataConvert::timestampToString(parm[0]->data()->getTimestampIntVal(row, isNull),
|
||||
timeZone())
|
||||
operationColType.getTimeZone())
|
||||
.substr(0, length);
|
||||
}
|
||||
break;
|
||||
@ -568,7 +568,7 @@ int32_t Func_cast_date::getDateIntVal(rowgroup::Row& row, FunctionParm& parm, bo
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
int64_t val1 = parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||
string value = dataconvert::DataConvert::timestampToString(val1, timeZone());
|
||||
string value = dataconvert::DataConvert::timestampToString(val1, op_ct.getTimeZone());
|
||||
value = value.substr(0, 10);
|
||||
return dataconvert::DataConvert::stringToDate(value);
|
||||
}
|
||||
@ -691,7 +691,7 @@ int64_t Func_cast_date::getDatetimeIntVal(rowgroup::Row& row, FunctionParm& parm
|
||||
TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
MySQLTime m_time;
|
||||
gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
gmtSecToMySQLTime(seconds, m_time, operationColType.getTimeZone());
|
||||
DateTime dt;
|
||||
dt.year = m_time.year;
|
||||
dt.month = m_time.month;
|
||||
@ -847,7 +847,7 @@ int64_t Func_cast_datetime::getDatetimeIntVal(rowgroup::Row& row, FunctionParm&
|
||||
TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
MySQLTime m_time;
|
||||
gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
gmtSecToMySQLTime(seconds, m_time, operationColType.getTimeZone());
|
||||
DateTime dt;
|
||||
dt.year = m_time.year;
|
||||
dt.month = m_time.month;
|
||||
@ -958,7 +958,7 @@ int64_t Func_cast_datetime::getTimeIntVal(rowgroup::Row& row, FunctionParm& parm
|
||||
TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
MySQLTime m_time;
|
||||
gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
gmtSecToMySQLTime(seconds, m_time, operationColType.getTimeZone());
|
||||
Time time;
|
||||
time.hour = m_time.hour;
|
||||
time.minute = m_time.minute;
|
||||
@ -1362,7 +1362,7 @@ IDB_Decimal Func_cast_decimal::getDecimalVal(Row& row, FunctionParm& parm, bool&
|
||||
int32_t s = 0;
|
||||
|
||||
string value = dataconvert::DataConvert::timestampToString1(
|
||||
parm[0]->data()->getTimestampIntVal(row, isNull), timeZone());
|
||||
parm[0]->data()->getTimestampIntVal(row, isNull), operationColType.getTimeZone());
|
||||
|
||||
// strip off micro seconds
|
||||
string date = value.substr(0, 14);
|
||||
@ -1475,8 +1475,8 @@ double Func_cast_double::getDoubleVal(Row& row, FunctionParm& parm, bool& isNull
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
string str =
|
||||
DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone());
|
||||
string str = DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull),
|
||||
operationColType.getTimeZone());
|
||||
|
||||
// strip off micro seconds
|
||||
str = str.substr(0, 14);
|
||||
|
@ -571,7 +571,7 @@ IDB_Decimal Func_ceil::getDecimalVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
TimeStamp dt(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
|
||||
if (!isNull)
|
||||
ret.value = dt.convertToMySQLint(timeZone());
|
||||
ret.value = dt.convertToMySQLint(op_ct.getTimeZone());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -99,7 +99,7 @@ int64_t Func_char_length::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
string date = dataconvert::DataConvert::timestampToString(
|
||||
parm[0]->data()->getTimestampIntVal(row, isNull), timeZone());
|
||||
parm[0]->data()->getTimestampIntVal(row, isNull), op_ct.getTimeZone());
|
||||
return (int64_t)date.size();
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,9 @@ int64_t Func_convert_tz::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool&
|
||||
}
|
||||
else
|
||||
{
|
||||
seconds = dataconvert::mySQLTimeToGmtSec(my_start_time, from_tz, valid);
|
||||
long from_tz_offset;
|
||||
dataconvert::timeZoneToOffset(from_tz.c_str(), from_tz.size(), &from_tz_offset);
|
||||
seconds = dataconvert::mySQLTimeToGmtSec(my_start_time, from_tz_offset, valid);
|
||||
if (!valid)
|
||||
{
|
||||
if (seconds != 0)
|
||||
@ -196,7 +198,9 @@ int64_t Func_convert_tz::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool&
|
||||
}
|
||||
else
|
||||
{
|
||||
dataconvert::gmtSecToMySQLTime(seconds, my_time_tmp, to_tz);
|
||||
long to_tz_offset;
|
||||
dataconvert::timeZoneToOffset(to_tz.c_str(), to_tz.size(), &to_tz_offset);
|
||||
dataconvert::gmtSecToMySQLTime(seconds, my_time_tmp, to_tz_offset);
|
||||
}
|
||||
|
||||
dataconvert::DateTime result_datetime(my_time_tmp.year, my_time_tmp.month, my_time_tmp.day,
|
||||
|
@ -47,7 +47,7 @@ CalpontSystemCatalog::ColType Func_date::operationType(FunctionParm& fp,
|
||||
}
|
||||
|
||||
int64_t Func_date::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType&)
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
CalpontSystemCatalog::ColDataType type = parm[0]->data()->resultType().colDataType;
|
||||
|
||||
@ -75,7 +75,7 @@ int64_t Func_date::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isNul
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
int64_t val1 = parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||
value = dataconvert::DataConvert::timestampToString(val1, timeZone());
|
||||
value = dataconvert::DataConvert::timestampToString(val1, ct.getTimeZone());
|
||||
value = value.substr(0, 10);
|
||||
break;
|
||||
}
|
||||
|
@ -759,7 +759,7 @@ int64_t Func_date_add::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& i
|
||||
TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
MySQLTime m_time;
|
||||
gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
gmtSecToMySQLTime(seconds, m_time, ct.getTimeZone());
|
||||
DateTime dt;
|
||||
dt.year = m_time.year;
|
||||
dt.month = m_time.month;
|
||||
|
@ -242,7 +242,7 @@ CalpontSystemCatalog::ColType Func_date_format::operationType(FunctionParm& fp,
|
||||
}
|
||||
|
||||
string Func_date_format::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType&)
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
int64_t val = 0;
|
||||
DateTime dt = 0;
|
||||
@ -273,7 +273,7 @@ string Func_date_format::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool&
|
||||
TimeStamp timestamp(val);
|
||||
int64_t seconds = timestamp.second;
|
||||
MySQLTime time;
|
||||
gmtSecToMySQLTime(seconds, time, timeZone());
|
||||
gmtSecToMySQLTime(seconds, time, ct.getTimeZone());
|
||||
dt.year = time.year;
|
||||
dt.month = time.month;
|
||||
dt.day = time.day;
|
||||
@ -412,7 +412,7 @@ int64_t Func_date_format::getDatetimeIntVal(rowgroup::Row& row, FunctionParm& pa
|
||||
int64_t Func_date_format::getTimestampIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
return dataconvert::DataConvert::timestampToInt(getStrVal(row, parm, isNull, ct), timeZone());
|
||||
return dataconvert::DataConvert::timestampToInt(getStrVal(row, parm, isNull, ct), ct.getTimeZone());
|
||||
}
|
||||
|
||||
} // namespace funcexp
|
||||
|
@ -64,7 +64,7 @@ int64_t Func_day::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
return m_time.day;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ int64_t Func_dayname::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& is
|
||||
dataconvert::TimeStamp timestamp(val);
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, time, op_ct.getTimeZone());
|
||||
year = time.year;
|
||||
month = time.month;
|
||||
day = time.day;
|
||||
|
@ -75,7 +75,7 @@ int64_t Func_dayofweek::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool&
|
||||
dataconvert::TimeStamp timestamp(val);
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, time, ct.getTimeZone());
|
||||
year = time.year;
|
||||
month = time.month;
|
||||
day = time.day;
|
||||
|
@ -74,7 +74,7 @@ int64_t Func_dayofyear::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool&
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, ct.getTimeZone());
|
||||
year = m_time.year;
|
||||
month = m_time.month;
|
||||
day = m_time.day;
|
||||
|
@ -202,7 +202,7 @@ int64_t Func_extract::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& is
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, ct.getTimeZone());
|
||||
dataconvert::DateTime dt;
|
||||
dt.year = m_time.year;
|
||||
dt.month = m_time.month;
|
||||
|
@ -225,7 +225,7 @@ uint64_t Func_floor::getUintVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
string str =
|
||||
DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone());
|
||||
DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), op_ct.getTimeZone());
|
||||
|
||||
// strip off micro seconds
|
||||
str = str.substr(0, 14);
|
||||
@ -519,7 +519,7 @@ IDB_Decimal Func_floor::getDecimalVal(Row& row, FunctionParm& parm, bool& isNull
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
string str =
|
||||
DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone());
|
||||
DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), op_ct.getTimeZone());
|
||||
|
||||
// strip off micro seconds
|
||||
str = str.substr(0, 14);
|
||||
|
@ -117,7 +117,7 @@ int64_t Func_hour::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isNul
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
return m_time.hour;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ using namespace rowgroup;
|
||||
|
||||
namespace
|
||||
{
|
||||
bool boolVal(SPTP& parm, Row& row, const string& timeZone)
|
||||
bool boolVal(SPTP& parm, Row& row, long timeZone)
|
||||
{
|
||||
bool ret = true;
|
||||
bool isNull = false; // Keep it local. We don't want to mess with the global one here.
|
||||
@ -122,9 +122,9 @@ CalpontSystemCatalog::ColType Func_if::operationType(FunctionParm& fp,
|
||||
return ct;
|
||||
}
|
||||
|
||||
int64_t Func_if::getIntVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType&)
|
||||
int64_t Func_if::getIntVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
if (boolVal(parm[0], row, timeZone()))
|
||||
if (boolVal(parm[0], row, ct.getTimeZone()))
|
||||
{
|
||||
return parm[1]->data()->getIntVal(row, isNull);
|
||||
}
|
||||
@ -134,9 +134,9 @@ int64_t Func_if::getIntVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSy
|
||||
}
|
||||
}
|
||||
|
||||
string Func_if::getStrVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType&)
|
||||
string Func_if::getStrVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
if (boolVal(parm[0], row, timeZone()))
|
||||
if (boolVal(parm[0], row, ct.getTimeZone()))
|
||||
{
|
||||
return parm[1]->data()->getStrVal(row, isNull);
|
||||
}
|
||||
@ -146,9 +146,10 @@ string Func_if::getStrVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSys
|
||||
}
|
||||
}
|
||||
|
||||
IDB_Decimal Func_if::getDecimalVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType&)
|
||||
IDB_Decimal Func_if::getDecimalVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
if (boolVal(parm[0], row, timeZone()))
|
||||
if (boolVal(parm[0], row, ct.getTimeZone()))
|
||||
{
|
||||
return parm[1]->data()->getDecimalVal(row, isNull);
|
||||
}
|
||||
@ -158,9 +159,9 @@ IDB_Decimal Func_if::getDecimalVal(Row& row, FunctionParm& parm, bool& isNull, C
|
||||
}
|
||||
}
|
||||
|
||||
double Func_if::getDoubleVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType&)
|
||||
double Func_if::getDoubleVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
if (boolVal(parm[0], row, timeZone()))
|
||||
if (boolVal(parm[0], row, ct.getTimeZone()))
|
||||
{
|
||||
return parm[1]->data()->getDoubleVal(row, isNull);
|
||||
}
|
||||
@ -171,9 +172,9 @@ double Func_if::getDoubleVal(Row& row, FunctionParm& parm, bool& isNull, Calpont
|
||||
}
|
||||
|
||||
long double Func_if::getLongDoubleVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType&)
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
if (boolVal(parm[0], row, timeZone()))
|
||||
if (boolVal(parm[0], row, ct.getTimeZone()))
|
||||
{
|
||||
return parm[1]->data()->getLongDoubleVal(row, isNull);
|
||||
}
|
||||
@ -183,9 +184,9 @@ long double Func_if::getLongDoubleVal(Row& row, FunctionParm& parm, bool& isNull
|
||||
}
|
||||
}
|
||||
|
||||
int32_t Func_if::getDateIntVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType&)
|
||||
int32_t Func_if::getDateIntVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
if (boolVal(parm[0], row, timeZone()))
|
||||
if (boolVal(parm[0], row, ct.getTimeZone()))
|
||||
{
|
||||
return parm[1]->data()->getDateIntVal(row, isNull);
|
||||
}
|
||||
@ -195,9 +196,10 @@ int32_t Func_if::getDateIntVal(Row& row, FunctionParm& parm, bool& isNull, Calpo
|
||||
}
|
||||
}
|
||||
|
||||
int64_t Func_if::getDatetimeIntVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType&)
|
||||
int64_t Func_if::getDatetimeIntVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
if (boolVal(parm[0], row, timeZone()))
|
||||
if (boolVal(parm[0], row, ct.getTimeZone()))
|
||||
{
|
||||
return parm[1]->data()->getDatetimeIntVal(row, isNull);
|
||||
}
|
||||
@ -208,9 +210,9 @@ int64_t Func_if::getDatetimeIntVal(Row& row, FunctionParm& parm, bool& isNull, C
|
||||
}
|
||||
|
||||
int64_t Func_if::getTimestampIntVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType&)
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
if (boolVal(parm[0], row, timeZone()))
|
||||
if (boolVal(parm[0], row, ct.getTimeZone()))
|
||||
{
|
||||
return parm[1]->data()->getTimestampIntVal(row, isNull);
|
||||
}
|
||||
@ -220,9 +222,9 @@ int64_t Func_if::getTimestampIntVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
}
|
||||
}
|
||||
|
||||
int64_t Func_if::getTimeIntVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType&)
|
||||
int64_t Func_if::getTimeIntVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
if (boolVal(parm[0], row, timeZone()))
|
||||
if (boolVal(parm[0], row, ct.getTimeZone()))
|
||||
{
|
||||
return parm[1]->data()->getTimeIntVal(row, isNull);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ int64_t Func_last_day::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& i
|
||||
TimeStamp timestamp(parm[0]->data()->getIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
MySQLTime m_time;
|
||||
gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
year = m_time.year;
|
||||
month = m_time.month;
|
||||
day = m_time.day;
|
||||
|
@ -1786,7 +1786,7 @@ string Func_format::getStrVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
value = dataconvert::DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull),
|
||||
timeZone());
|
||||
operationColType.getTimeZone());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -117,7 +117,7 @@ int64_t Func_minute::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isN
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
return m_time.minute;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ int64_t Func_month::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isNu
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
return m_time.month;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ int64_t Func_monthname::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool&
|
||||
dataconvert::TimeStamp timestamp(val);
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, time, op_ct.getTimeZone());
|
||||
return time.month;
|
||||
}
|
||||
|
||||
|
@ -955,7 +955,8 @@ execplan::IDB_Decimal Func_nullif::getDecimalVal(rowgroup::Row& row, FunctionPar
|
||||
string value;
|
||||
|
||||
if (parm[1]->data()->resultType().colDataType == execplan::CalpontSystemCatalog::TIMESTAMP)
|
||||
value = DataConvert::timestampToString1(parm[1]->data()->getTimestampIntVal(row, isNull), timeZone());
|
||||
value =
|
||||
DataConvert::timestampToString1(parm[1]->data()->getTimestampIntVal(row, isNull), op_ct.getTimeZone());
|
||||
else
|
||||
value = DataConvert::datetimeToString1(parm[1]->data()->getDatetimeIntVal(row, isNull));
|
||||
|
||||
|
@ -67,7 +67,7 @@ int64_t Func_quarter::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& is
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
month = m_time.month;
|
||||
break;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ using namespace logging;
|
||||
namespace
|
||||
{
|
||||
inline bool getBool(rowgroup::Row& row, funcexp::FunctionParm& pm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct, const string& timeZone)
|
||||
CalpontSystemCatalog::ColType& ct, long timeZone)
|
||||
{
|
||||
string expr;
|
||||
string pattern;
|
||||
@ -244,7 +244,7 @@ CalpontSystemCatalog::ColType Func_regexp::operationType(FunctionParm& fp,
|
||||
bool Func_regexp::getBoolVal(rowgroup::Row& row, FunctionParm& pm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
return getBool(row, pm, isNull, ct, timeZone()) && !isNull;
|
||||
return getBool(row, pm, isNull, ct, ct.getTimeZone()) && !isNull;
|
||||
}
|
||||
|
||||
} // namespace funcexp
|
||||
|
@ -569,7 +569,7 @@ IDB_Decimal Func_round::getDecimalVal(Row& row, FunctionParm& parm, bool& isNull
|
||||
string value;
|
||||
if (op_ct.colDataType == execplan::CalpontSystemCatalog::TIMESTAMP)
|
||||
value = dataconvert::DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull),
|
||||
timeZone());
|
||||
op_ct.getTimeZone());
|
||||
else
|
||||
value = dataconvert::DataConvert::datetimeToString1(parm[0]->data()->getDatetimeIntVal(row, isNull));
|
||||
|
||||
@ -709,5 +709,11 @@ int64_t Func_round::getDatetimeIntVal(Row& row, FunctionParm& parm, bool& isNull
|
||||
return parm[0]->data()->getIntVal(row, isNull);
|
||||
}
|
||||
|
||||
int64_t Func_round::getTimestampIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
return parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||
}
|
||||
|
||||
} // namespace funcexp
|
||||
// vim:ts=4 sw=4:
|
||||
|
@ -116,7 +116,7 @@ int64_t Func_second::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isN
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
return m_time.second;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace
|
||||
using namespace funcexp;
|
||||
|
||||
dataconvert::DateTime getDateTime(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct, const string& timeZone)
|
||||
CalpontSystemCatalog::ColType& ct, long timeZone)
|
||||
{
|
||||
TimeExtractor extractor;
|
||||
dataconvert::DateTime dateTime;
|
||||
@ -186,7 +186,7 @@ string Func_str_to_date::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool&
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
dataconvert::DateTime dateTime;
|
||||
dateTime = getDateTime(row, parm, isNull, ct, timeZone());
|
||||
dateTime = getDateTime(row, parm, isNull, ct, ct.getTimeZone());
|
||||
string convertedDate = dataconvert::DataConvert::datetimeToString(*((long long*)&dateTime));
|
||||
return convertedDate;
|
||||
}
|
||||
@ -195,7 +195,7 @@ int32_t Func_str_to_date::getDateIntVal(rowgroup::Row& row, FunctionParm& parm,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
dataconvert::DateTime dateTime;
|
||||
dateTime = getDateTime(row, parm, isNull, ct, timeZone());
|
||||
dateTime = getDateTime(row, parm, isNull, ct, ct.getTimeZone());
|
||||
int64_t time = *(reinterpret_cast<int64_t*>(&dateTime));
|
||||
return ((((int32_t)(time >> 32)) & 0xFFFFFFC0) | 0x3E);
|
||||
}
|
||||
@ -204,7 +204,7 @@ int64_t Func_str_to_date::getDatetimeIntVal(rowgroup::Row& row, FunctionParm& pa
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
dataconvert::DateTime dateTime;
|
||||
dateTime = getDateTime(row, parm, isNull, ct, timeZone());
|
||||
dateTime = getDateTime(row, parm, isNull, ct, ct.getTimeZone());
|
||||
int64_t time = *(reinterpret_cast<int64_t*>(&dateTime));
|
||||
return time;
|
||||
}
|
||||
@ -213,7 +213,7 @@ int64_t Func_str_to_date::getTimestampIntVal(rowgroup::Row& row, FunctionParm& p
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
dataconvert::DateTime dateTime;
|
||||
dateTime = getDateTime(row, parm, isNull, ct, timeZone());
|
||||
dateTime = getDateTime(row, parm, isNull, ct, ct.getTimeZone());
|
||||
dataconvert::TimeStamp timestamp;
|
||||
dataconvert::MySQLTime m_time;
|
||||
m_time.year = dateTime.year;
|
||||
@ -223,7 +223,7 @@ int64_t Func_str_to_date::getTimestampIntVal(rowgroup::Row& row, FunctionParm& p
|
||||
m_time.minute = dateTime.minute;
|
||||
m_time.second = dateTime.second;
|
||||
bool isValid = true;
|
||||
int64_t seconds = mySQLTimeToGmtSec(m_time, timeZone(), isValid);
|
||||
int64_t seconds = mySQLTimeToGmtSec(m_time, ct.getTimeZone(), isValid);
|
||||
if (!isValid)
|
||||
{
|
||||
timestamp = -1;
|
||||
@ -243,7 +243,7 @@ int64_t Func_str_to_date::getTimeIntVal(rowgroup::Row& row, FunctionParm& parm,
|
||||
{
|
||||
dataconvert::DateTime dateTime;
|
||||
dataconvert::Time retTime;
|
||||
dateTime = getDateTime(row, parm, isNull, ct, timeZone());
|
||||
dateTime = getDateTime(row, parm, isNull, ct, ct.getTimeZone());
|
||||
retTime.day = 0;
|
||||
retTime.is_neg = false;
|
||||
retTime.hour = dateTime.hour;
|
||||
@ -258,7 +258,7 @@ int64_t Func_str_to_date::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
dataconvert::DateTime dateTime;
|
||||
dateTime = getDateTime(row, parm, isNull, ct, timeZone());
|
||||
dateTime = getDateTime(row, parm, isNull, ct, ct.getTimeZone());
|
||||
int64_t time = *(reinterpret_cast<int64_t*>(&dateTime));
|
||||
return time;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ CalpontSystemCatalog::ColType Func_time::operationType(FunctionParm& fp,
|
||||
}
|
||||
|
||||
string Func_time::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType&)
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
int64_t val = 0;
|
||||
|
||||
@ -126,7 +126,7 @@ string Func_time::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, ct.getTimeZone());
|
||||
dataconvert::Time time;
|
||||
time.hour = m_time.hour;
|
||||
time.minute = m_time.minute;
|
||||
|
@ -45,7 +45,7 @@ CalpontSystemCatalog::ColType Func_time_format::operationType(FunctionParm& fp,
|
||||
}
|
||||
|
||||
string Func_time_format::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType&)
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
// assume 256 is enough. assume not allowing incomplete date
|
||||
char buf[256];
|
||||
@ -72,7 +72,7 @@ string Func_time_format::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool&
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, ct.getTimeZone());
|
||||
hour = m_time.hour;
|
||||
min = m_time.minute;
|
||||
sec = m_time.second;
|
||||
|
@ -70,7 +70,7 @@ int64_t Func_time_to_sec::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool
|
||||
dataconvert::TimeStamp timestamp(val);
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, time, op_ct.getTimeZone());
|
||||
hour = time.hour;
|
||||
min = time.minute;
|
||||
sec = time.second;
|
||||
|
@ -142,16 +142,11 @@ string Func_timediff::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool& is
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
if (type1 != type2)
|
||||
{
|
||||
isNull = true;
|
||||
break;
|
||||
}
|
||||
int64_t temp = parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||
dataconvert::TimeStamp timestamp(temp);
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, time, ct.getTimeZone());
|
||||
dataconvert::DateTime dt;
|
||||
dt.year = time.year;
|
||||
dt.month = time.month;
|
||||
@ -239,7 +234,7 @@ string Func_timediff::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool& is
|
||||
dataconvert::TimeStamp timestamp(temp);
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, time, ct.getTimeZone());
|
||||
dataconvert::DateTime dt;
|
||||
dt.year = time.year;
|
||||
dt.month = time.month;
|
||||
@ -328,7 +323,7 @@ int64_t Func_timediff::getDatetimeIntVal(rowgroup::Row& row, FunctionParm& parm,
|
||||
int64_t Func_timediff::getTimestampIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
return dataconvert::DataConvert::timestampToInt(getStrVal(row, parm, isNull, ct), timeZone());
|
||||
return dataconvert::DataConvert::timestampToInt(getStrVal(row, parm, isNull, ct), ct.getTimeZone());
|
||||
}
|
||||
|
||||
int64_t Func_timediff::getTimeIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
|
||||
|
@ -55,7 +55,7 @@ int64_t Func_timestampdiff::getIntVal(rowgroup::Row& row, FunctionParm& parm, bo
|
||||
TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
MySQLTime m_time;
|
||||
gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
dt1.year = m_time.year;
|
||||
dt1.month = m_time.month;
|
||||
dt1.day = m_time.day;
|
||||
@ -82,7 +82,7 @@ int64_t Func_timestampdiff::getIntVal(rowgroup::Row& row, FunctionParm& parm, bo
|
||||
TimeStamp timestamp(parm[1]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
MySQLTime m_time;
|
||||
gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
dt2.year = m_time.year;
|
||||
dt2.month = m_time.month;
|
||||
dt2.day = m_time.day;
|
||||
|
@ -85,7 +85,7 @@ int64_t Func_to_days::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& is
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
year = m_time.year;
|
||||
month = m_time.month;
|
||||
day = m_time.day;
|
||||
|
@ -560,7 +560,7 @@ IDB_Decimal Func_truncate::getDecimalVal(Row& row, FunctionParm& parm, bool& isN
|
||||
int64_t x = 0;
|
||||
|
||||
string value =
|
||||
DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone());
|
||||
DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), op_ct.getTimeZone());
|
||||
|
||||
s = parm[1]->data()->getIntVal(row, isNull);
|
||||
|
||||
@ -714,5 +714,11 @@ string Func_truncate::getStrVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
return x.toString(true);
|
||||
}
|
||||
|
||||
int64_t Func_truncate::getTimestampIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
return parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||
}
|
||||
|
||||
} // namespace funcexp
|
||||
// vim:ts=4 sw=4:
|
||||
|
@ -76,7 +76,7 @@ int64_t Func_week::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isNul
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
year = m_time.year;
|
||||
month = m_time.month;
|
||||
day = m_time.day;
|
||||
|
@ -73,7 +73,7 @@ int64_t Func_weekday::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& is
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
year = m_time.year;
|
||||
month = m_time.month;
|
||||
day = m_time.day;
|
||||
|
@ -63,7 +63,7 @@ int64_t Func_year::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isNul
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
return m_time.year;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ int64_t Func_yearweek::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& i
|
||||
dataconvert::TimeStamp timestamp(parm[0]->data()->getIntVal(row, isNull));
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone());
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, op_ct.getTimeZone());
|
||||
year = m_time.year;
|
||||
month = m_time.month;
|
||||
day = m_time.day;
|
||||
|
@ -105,9 +105,9 @@ uint64_t Func::stringToDatetime(const string str)
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint64_t Func::stringToTimestamp(const string str)
|
||||
uint64_t Func::stringToTimestamp(const std::string& str, long timeZone)
|
||||
{
|
||||
int64_t ret = DataConvert::stringToTimestamp(str, timeZone());
|
||||
int64_t ret = DataConvert::stringToTimestamp(str, timeZone);
|
||||
|
||||
if (ret == -1)
|
||||
{
|
||||
|
@ -73,17 +73,6 @@ class Func
|
||||
fFuncName = funcName;
|
||||
}
|
||||
|
||||
const std::string timeZone() const
|
||||
{
|
||||
std::unique_lock<std::mutex> l(tzMutex);
|
||||
return fTimeZone;
|
||||
}
|
||||
void timeZone(const std::string timeZone)
|
||||
{
|
||||
std::unique_lock<std::mutex> l(tzMutex);
|
||||
fTimeZone = timeZone;
|
||||
}
|
||||
|
||||
void raiseIllegalParameterDataTypeError(const execplan::CalpontSystemCatalog::ColType& colType) const
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@ -177,7 +166,7 @@ class Func
|
||||
protected:
|
||||
virtual uint32_t stringToDate(std::string);
|
||||
virtual uint64_t stringToDatetime(std::string);
|
||||
virtual uint64_t stringToTimestamp(std::string);
|
||||
virtual uint64_t stringToTimestamp(const std::string&, long);
|
||||
virtual int64_t stringToTime(std::string);
|
||||
|
||||
virtual uint32_t intToDate(int64_t);
|
||||
@ -205,9 +194,6 @@ class Func
|
||||
float fFloatNullVal;
|
||||
double fDoubleNullVal;
|
||||
long double fLongDoubleNullVal;
|
||||
|
||||
std::string fTimeZone;
|
||||
mutable std::mutex tzMutex;
|
||||
};
|
||||
|
||||
class ParmTSInt64 : public datatypes::TSInt64Null
|
||||
@ -216,7 +202,7 @@ class ParmTSInt64 : public datatypes::TSInt64Null
|
||||
ParmTSInt64()
|
||||
{
|
||||
}
|
||||
ParmTSInt64(rowgroup::Row& row, const execplan::SPTP& parm, const funcexp::Func& thisFunc)
|
||||
ParmTSInt64(rowgroup::Row& row, const execplan::SPTP& parm, const funcexp::Func& thisFunc, long timeZone)
|
||||
: TSInt64Null(parm->data()->toTSInt64Null(row))
|
||||
{
|
||||
}
|
||||
@ -228,7 +214,7 @@ class ParmTUInt64 : public datatypes::TUInt64Null
|
||||
ParmTUInt64()
|
||||
{
|
||||
}
|
||||
ParmTUInt64(rowgroup::Row& row, const execplan::SPTP& parm, const funcexp::Func& thisFunc)
|
||||
ParmTUInt64(rowgroup::Row& row, const execplan::SPTP& parm, const funcexp::Func& thisFunc, long timeZone)
|
||||
: TUInt64Null(parm->data()->toTUInt64Null(row))
|
||||
{
|
||||
}
|
||||
@ -240,8 +226,8 @@ class Arg2Lazy
|
||||
public:
|
||||
TA a;
|
||||
TB b;
|
||||
Arg2Lazy(rowgroup::Row& row, FunctionParm& parm, const Func& thisFunc)
|
||||
: a(row, parm[0], thisFunc), b(a.isNull() ? TB() : TB(row, parm[1], thisFunc))
|
||||
Arg2Lazy(rowgroup::Row& row, FunctionParm& parm, const Func& thisFunc, long timeZone)
|
||||
: a(row, parm[0], thisFunc, timeZone), b(a.isNull() ? TB() : TB(row, parm[1], thisFunc, timeZone))
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -252,8 +238,8 @@ class Arg2Eager
|
||||
public:
|
||||
TA a;
|
||||
TB b;
|
||||
Arg2Eager(rowgroup::Row& row, FunctionParm& parm, const Func& thisFunc)
|
||||
: a(row, parm[0], thisFunc), b(row, parm[1], thisFunc)
|
||||
Arg2Eager(rowgroup::Row& row, FunctionParm& parm, const Func& thisFunc, long timeZone)
|
||||
: a(row, parm[0], thisFunc, timeZone), b(row, parm[1], thisFunc, timeZone)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -180,6 +180,9 @@ class Func_round : public Func_Real
|
||||
|
||||
int64_t getDatetimeIntVal(rowgroup::Row& row, FunctionParm& fp, bool& isNull,
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct);
|
||||
|
||||
int64_t getTimestampIntVal(rowgroup::Row& row, FunctionParm& fp, bool& isNull,
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct);
|
||||
};
|
||||
|
||||
/** @brief Func_truncate class
|
||||
@ -214,6 +217,9 @@ class Func_truncate : public Func_Real
|
||||
|
||||
execplan::IDB_Decimal getDecimalVal(rowgroup::Row& row, FunctionParm& fp, bool& isNull,
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct);
|
||||
|
||||
int64_t getTimestampIntVal(rowgroup::Row& row, FunctionParm& fp, bool& isNull,
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct);
|
||||
};
|
||||
|
||||
/** @brief Func_ceil class
|
||||
|
@ -94,7 +94,7 @@ class Func_Str : public Func
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
std::string str = getStrVal(row, fp, isNull, op_ct);
|
||||
return (isNull ? 0 : stringToTimestamp(str));
|
||||
return (isNull ? 0 : stringToTimestamp(str, op_ct.getTimeZone()));
|
||||
}
|
||||
|
||||
int64_t getTimeIntVal(rowgroup::Row& row, FunctionParm& fp, bool& isNull,
|
||||
|
Reference in New Issue
Block a user