From d6ef3cad3d05e9c3af8b79b4474c730478e36669 Mon Sep 17 00:00:00 2001 From: Patrick LeBlanc <43503225+pleblanc1976@users.noreply.github.com> Date: Thu, 13 Feb 2020 18:02:03 -0600 Subject: [PATCH] Merge pull request #1049 from pleblanc1976/mcol-3776 Mcol 3776 - shared but unsync'd timezone var --- utils/funcexp/func_add_time.cpp | 2 +- utils/funcexp/func_between.cpp | 2 +- utils/funcexp/func_bitand.cpp | 2 +- utils/funcexp/func_bitwise.cpp | 22 +++++++++++----------- utils/funcexp/func_cast.cpp | 18 +++++++++--------- utils/funcexp/func_ceil.cpp | 4 ++-- utils/funcexp/func_char_length.cpp | 2 +- utils/funcexp/func_date.cpp | 2 +- utils/funcexp/func_date_add.cpp | 2 +- utils/funcexp/func_date_format.cpp | 4 ++-- utils/funcexp/func_day.cpp | 2 +- utils/funcexp/func_dayname.cpp | 2 +- utils/funcexp/func_dayofweek.cpp | 2 +- utils/funcexp/func_dayofyear.cpp | 2 +- utils/funcexp/func_extract.cpp | 2 +- utils/funcexp/func_floor.cpp | 4 ++-- utils/funcexp/func_hour.cpp | 2 +- utils/funcexp/func_if.cpp | 18 +++++++++--------- utils/funcexp/func_last_day.cpp | 2 +- utils/funcexp/func_math.cpp | 2 +- utils/funcexp/func_minute.cpp | 2 +- utils/funcexp/func_month.cpp | 2 +- utils/funcexp/func_monthname.cpp | 2 +- utils/funcexp/func_nullif.cpp | 2 +- utils/funcexp/func_quarter.cpp | 2 +- utils/funcexp/func_regexp.cpp | 2 +- utils/funcexp/func_round.cpp | 2 +- utils/funcexp/func_second.cpp | 2 +- utils/funcexp/func_str_to_date.cpp | 14 +++++++------- utils/funcexp/func_time.cpp | 2 +- utils/funcexp/func_time_format.cpp | 2 +- utils/funcexp/func_time_to_sec.cpp | 2 +- utils/funcexp/func_timediff.cpp | 6 +++--- utils/funcexp/func_timestampdiff.cpp | 4 ++-- utils/funcexp/func_to_days.cpp | 2 +- utils/funcexp/func_truncate.cpp | 2 +- utils/funcexp/func_week.cpp | 2 +- utils/funcexp/func_weekday.cpp | 2 +- utils/funcexp/func_year.cpp | 2 +- utils/funcexp/func_yearweek.cpp | 2 +- utils/funcexp/functor.cpp | 2 +- utils/funcexp/functor.h | 7 ++++++- 42 files changed, 85 insertions(+), 80 deletions(-) diff --git a/utils/funcexp/func_add_time.cpp b/utils/funcexp/func_add_time.cpp index a95eff53d..f5f501949 100644 --- a/utils/funcexp/func_add_time.cpp +++ b/utils/funcexp/func_add_time.cpp @@ -181,7 +181,7 @@ int64_t Func_add_time::getTimestampIntVal(rowgroup::Row& row, TimeStamp timestamp(val1); int64_t seconds = timestamp.second; MySQLTime m_time; - gmtSecToMySQLTime(seconds, m_time, fTimeZone); + gmtSecToMySQLTime(seconds, m_time, timeZone()); dt1.year = m_time.year; dt1.month = m_time.month; dt1.day = m_time.day; diff --git a/utils/funcexp/func_between.cpp b/utils/funcexp/func_between.cpp index 8330c4fc0..d742c2d16 100644 --- a/utils/funcexp/func_between.cpp +++ b/utils/funcexp/func_between.cpp @@ -344,7 +344,7 @@ CalpontSystemCatalog::ColType Func_between::operationType( FunctionParm& fp, Cal if (cc) { Result result = cc->result(); - result.intVal = dataconvert::DataConvert::timestampToInt(result.strVal, fTimeZone); + result.intVal = dataconvert::DataConvert::timestampToInt(result.strVal, timeZone()); cc->result(result); } } diff --git a/utils/funcexp/func_bitand.cpp b/utils/funcexp/func_bitand.cpp index 64fa4078b..2863eadf8 100644 --- a/utils/funcexp/func_bitand.cpp +++ b/utils/funcexp/func_bitand.cpp @@ -162,7 +162,7 @@ int64_t Func_bitand::getIntVal(Row& row, TimeStamp timestamp(parm[i]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; MySQLTime m_time; - gmtSecToMySQLTime(seconds, m_time, fTimeZone); + gmtSecToMySQLTime(seconds, m_time, timeZone()); values.push_back((m_time.month * 100000000000000) + (m_time.day * 1000000000000) + (m_time.hour * 10000000000) + (m_time.minute * 100000000) + (m_time.second * 1000000) + timestamp.msecond); } diff --git a/utils/funcexp/func_bitwise.cpp b/utils/funcexp/func_bitwise.cpp index 028aedc1c..2154f125b 100644 --- a/utils/funcexp/func_bitwise.cpp +++ b/utils/funcexp/func_bitwise.cpp @@ -195,8 +195,8 @@ int64_t Func_bitand::getIntVal(Row& row, uint64_t val1 = 0; uint64_t val2 = 0; - if (!getUIntValFromParm(row, parm[0], val1, isNull, fTimeZone) || - !getUIntValFromParm(row, parm[1], val2, isNull, fTimeZone)) + if (!getUIntValFromParm(row, parm[0], val1, isNull, timeZone()) || + !getUIntValFromParm(row, parm[1], val2, isNull, timeZone())) { std::ostringstream oss; oss << "bitand: datatype of " << execplan::colDataTypeToString(operationColType.colDataType); @@ -231,8 +231,8 @@ int64_t Func_leftshift::getIntVal(Row& row, uint64_t val1 = 0; uint64_t val2 = 0; - if (!getUIntValFromParm(row, parm[0], val1, isNull, fTimeZone) || - !getUIntValFromParm(row, parm[1], val2, isNull, fTimeZone)) + if (!getUIntValFromParm(row, parm[0], val1, isNull, timeZone()) || + !getUIntValFromParm(row, parm[1], val2, isNull, timeZone())) { std::ostringstream oss; oss << "leftshift: datatype of " << execplan::colDataTypeToString(operationColType.colDataType); @@ -267,8 +267,8 @@ int64_t Func_rightshift::getIntVal(Row& row, uint64_t val1 = 0; uint64_t val2 = 0; - if (!getUIntValFromParm(row, parm[0], val1, isNull, fTimeZone) || - !getUIntValFromParm(row, parm[1], val2, isNull, fTimeZone)) + if (!getUIntValFromParm(row, parm[0], val1, isNull, timeZone()) || + !getUIntValFromParm(row, parm[1], val2, isNull, timeZone())) { std::ostringstream oss; oss << "rightshift: datatype of " << execplan::colDataTypeToString(operationColType.colDataType); @@ -303,8 +303,8 @@ int64_t Func_bitor::getIntVal(Row& row, uint64_t val1 = 0; uint64_t val2 = 0; - if (!getUIntValFromParm(row, parm[0], val1, isNull, fTimeZone) || - !getUIntValFromParm(row, parm[1], val2, isNull, fTimeZone)) + if (!getUIntValFromParm(row, parm[0], val1, isNull, timeZone()) || + !getUIntValFromParm(row, parm[1], val2, isNull, timeZone())) { std::ostringstream oss; oss << "bitor: datatype of " << execplan::colDataTypeToString(operationColType.colDataType); @@ -347,8 +347,8 @@ int64_t Func_bitxor::getIntVal(Row& row, uint64_t val1 = 0; uint64_t val2 = 0; - if (!getUIntValFromParm(row, parm[0], val1, isNull, fTimeZone) || - !getUIntValFromParm(row, parm[1], val2, isNull, fTimeZone)) + if (!getUIntValFromParm(row, parm[0], val1, isNull, timeZone()) || + !getUIntValFromParm(row, parm[1], val2, isNull, timeZone())) { std::ostringstream oss; oss << "bitxor: datatype of " << execplan::colDataTypeToString(operationColType.colDataType); @@ -382,7 +382,7 @@ int64_t Func_bit_count::getIntVal(Row& row, uint64_t val = 0; - if (!getUIntValFromParm(row, parm[0], val, isNull, fTimeZone)) + if (!getUIntValFromParm(row, parm[0], val, isNull, timeZone())) { std::ostringstream oss; oss << "bit_count: datatype of " << execplan::colDataTypeToString(operationColType.colDataType); diff --git a/utils/funcexp/func_cast.cpp b/utils/funcexp/func_cast.cpp index d335ddc81..ce3d6a531 100644 --- a/utils/funcexp/func_cast.cpp +++ b/utils/funcexp/func_cast.cpp @@ -218,7 +218,7 @@ int64_t Func_cast_signed::getIntVal(Row& row, int64_t time = parm[0]->data()->getTimestampIntVal(row, isNull); TimeStamp dt(time); - return dt.convertToMySQLint(fTimeZone); + return dt.convertToMySQLint(timeZone()); } break; @@ -379,7 +379,7 @@ uint64_t Func_cast_unsigned::getUintVal(Row& row, int64_t time = parm[0]->data()->getTimestampIntVal(row, isNull); TimeStamp dt(time); - return dt.convertToMySQLint(fTimeZone); + return dt.convertToMySQLint(timeZone()); } break; @@ -509,7 +509,7 @@ string Func_cast_char::getStrVal(Row& row, case execplan::CalpontSystemCatalog::TIMESTAMP: { - return dataconvert::DataConvert::timestampToString(parm[0]->data()->getTimestampIntVal(row, isNull), fTimeZone).substr(0, length); + return dataconvert::DataConvert::timestampToString(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone()).substr(0, length); } break; @@ -676,7 +676,7 @@ int32_t Func_cast_date::getDateIntVal(rowgroup::Row& row, case execplan::CalpontSystemCatalog::TIMESTAMP: { int64_t val1 = parm[0]->data()->getTimestampIntVal(row, isNull); - string value = dataconvert::DataConvert::timestampToString(val1, fTimeZone); + string value = dataconvert::DataConvert::timestampToString(val1, timeZone()); value = value.substr(0, 10); return dataconvert::DataConvert::stringToDate(value); } @@ -803,7 +803,7 @@ int64_t Func_cast_date::getDatetimeIntVal(rowgroup::Row& row, TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; MySQLTime m_time; - gmtSecToMySQLTime(seconds, m_time, fTimeZone); + gmtSecToMySQLTime(seconds, m_time, timeZone()); DateTime dt; dt.year = m_time.year; dt.month = m_time.month; @@ -985,7 +985,7 @@ int64_t Func_cast_datetime::getDatetimeIntVal(rowgroup::Row& row, TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; MySQLTime m_time; - gmtSecToMySQLTime(seconds, m_time, fTimeZone); + gmtSecToMySQLTime(seconds, m_time, timeZone()); DateTime dt; dt.year = m_time.year; dt.month = m_time.month; @@ -1099,7 +1099,7 @@ int64_t Func_cast_datetime::getTimeIntVal(rowgroup::Row& row, TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; MySQLTime m_time; - gmtSecToMySQLTime(seconds, m_time, fTimeZone); + gmtSecToMySQLTime(seconds, m_time, timeZone()); Time time; time.hour = m_time.hour; time.minute = m_time.minute; @@ -1478,7 +1478,7 @@ IDB_Decimal Func_cast_decimal::getDecimalVal(Row& row, { int32_t s = 0; - string value = dataconvert::DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), fTimeZone); + string value = dataconvert::DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone()); //strip off micro seconds string date = value.substr(0, 14); @@ -1599,7 +1599,7 @@ double Func_cast_double::getDoubleVal(Row& row, case execplan::CalpontSystemCatalog::TIMESTAMP: { string str = - DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), fTimeZone); + DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone()); // strip off micro seconds str = str.substr(0, 14); diff --git a/utils/funcexp/func_ceil.cpp b/utils/funcexp/func_ceil.cpp index b1f886166..f9f9c1891 100644 --- a/utils/funcexp/func_ceil.cpp +++ b/utils/funcexp/func_ceil.cpp @@ -164,7 +164,7 @@ int64_t Func_ceil::getIntVal(Row& row, TimeStamp dt(parm[0]->data()->getTimestampIntVal(row, isNull)); if (!isNull) - ret = dt.convertToMySQLint(fTimeZone); + ret = dt.convertToMySQLint(timeZone()); } break; @@ -269,7 +269,7 @@ uint64_t Func_ceil::getUintVal(Row& row, TimeStamp dt(parm[0]->data()->getTimestampIntVal(row, isNull)); if (!isNull) - ret = dt.convertToMySQLint(fTimeZone); + ret = dt.convertToMySQLint(timeZone()); } break; diff --git a/utils/funcexp/func_char_length.cpp b/utils/funcexp/func_char_length.cpp index c7c382c94..72bdfdfda 100644 --- a/utils/funcexp/func_char_length.cpp +++ b/utils/funcexp/func_char_length.cpp @@ -103,7 +103,7 @@ int64_t Func_char_length::getIntVal(rowgroup::Row& row, case execplan::CalpontSystemCatalog::TIMESTAMP: { - string date = dataconvert::DataConvert::timestampToString(parm[0]->data()->getTimestampIntVal(row, isNull), fTimeZone); + string date = dataconvert::DataConvert::timestampToString(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone()); return (int64_t)date.size(); } diff --git a/utils/funcexp/func_date.cpp b/utils/funcexp/func_date.cpp index 7280e838a..76a50a90f 100644 --- a/utils/funcexp/func_date.cpp +++ b/utils/funcexp/func_date.cpp @@ -78,7 +78,7 @@ int64_t Func_date::getIntVal(rowgroup::Row& row, case execplan::CalpontSystemCatalog::TIMESTAMP: { int64_t val1 = parm[0]->data()->getTimestampIntVal(row, isNull); - value = dataconvert::DataConvert::timestampToString(val1, fTimeZone); + value = dataconvert::DataConvert::timestampToString(val1, timeZone()); value = value.substr(0, 10); break; } diff --git a/utils/funcexp/func_date_add.cpp b/utils/funcexp/func_date_add.cpp index 5ed920e44..5004f5521 100644 --- a/utils/funcexp/func_date_add.cpp +++ b/utils/funcexp/func_date_add.cpp @@ -782,7 +782,7 @@ int64_t Func_date_add::getIntVal(rowgroup::Row& row, TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; MySQLTime m_time; - gmtSecToMySQLTime(seconds, m_time, fTimeZone); + gmtSecToMySQLTime(seconds, m_time, timeZone()); DateTime dt; dt.year = m_time.year; dt.month = m_time.month; diff --git a/utils/funcexp/func_date_format.cpp b/utils/funcexp/func_date_format.cpp index e62bc3952..105069c59 100644 --- a/utils/funcexp/func_date_format.cpp +++ b/utils/funcexp/func_date_format.cpp @@ -275,7 +275,7 @@ string Func_date_format::getStrVal(rowgroup::Row& row, TimeStamp timestamp(val); int64_t seconds = timestamp.second; MySQLTime time; - gmtSecToMySQLTime(seconds, time, fTimeZone); + gmtSecToMySQLTime(seconds, time, timeZone()); dt.year = time.year; dt.month = time.month; dt.day = time.day; @@ -419,7 +419,7 @@ int64_t Func_date_format::getTimestampIntVal(rowgroup::Row& row, bool& isNull, CalpontSystemCatalog::ColType& ct) { - return dataconvert::DataConvert::timestampToInt(getStrVal(row, parm, isNull, ct), fTimeZone); + return dataconvert::DataConvert::timestampToInt(getStrVal(row, parm, isNull, ct), timeZone()); } diff --git a/utils/funcexp/func_day.cpp b/utils/funcexp/func_day.cpp index c8ba97e6c..c414fd5d4 100644 --- a/utils/funcexp/func_day.cpp +++ b/utils/funcexp/func_day.cpp @@ -67,7 +67,7 @@ int64_t Func_day::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); return m_time.day; } diff --git a/utils/funcexp/func_dayname.cpp b/utils/funcexp/func_dayname.cpp index 02955fcf4..e46bfa46f 100644 --- a/utils/funcexp/func_dayname.cpp +++ b/utils/funcexp/func_dayname.cpp @@ -79,7 +79,7 @@ int64_t Func_dayname::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(val); int64_t seconds = timestamp.second; dataconvert::MySQLTime time; - dataconvert::gmtSecToMySQLTime(seconds, time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, time, timeZone()); year = time.year; month = time.month; day = time.day; diff --git a/utils/funcexp/func_dayofweek.cpp b/utils/funcexp/func_dayofweek.cpp index e66e1d864..3a29f592d 100644 --- a/utils/funcexp/func_dayofweek.cpp +++ b/utils/funcexp/func_dayofweek.cpp @@ -77,7 +77,7 @@ int64_t Func_dayofweek::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(val); int64_t seconds = timestamp.second; dataconvert::MySQLTime time; - dataconvert::gmtSecToMySQLTime(seconds, time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, time, timeZone()); year = time.year; month = time.month; day = time.day; diff --git a/utils/funcexp/func_dayofyear.cpp b/utils/funcexp/func_dayofyear.cpp index 6d4fc9fcf..ee13730c1 100644 --- a/utils/funcexp/func_dayofyear.cpp +++ b/utils/funcexp/func_dayofyear.cpp @@ -76,7 +76,7 @@ int64_t Func_dayofyear::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); year = m_time.year; month = m_time.month; day = m_time.day; diff --git a/utils/funcexp/func_extract.cpp b/utils/funcexp/func_extract.cpp index b8b1f90bc..f69b8dcbe 100644 --- a/utils/funcexp/func_extract.cpp +++ b/utils/funcexp/func_extract.cpp @@ -252,7 +252,7 @@ int64_t Func_extract::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); dataconvert::DateTime dt; dt.year = m_time.year; dt.month = m_time.month; diff --git a/utils/funcexp/func_floor.cpp b/utils/funcexp/func_floor.cpp index 50dd3d919..1e0ee7f09 100644 --- a/utils/funcexp/func_floor.cpp +++ b/utils/funcexp/func_floor.cpp @@ -161,7 +161,7 @@ int64_t Func_floor::getIntVal(Row& row, case execplan::CalpontSystemCatalog::TIMESTAMP: { string str = - DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), fTimeZone); + DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone()); // strip off micro seconds str = str.substr(0, 14); @@ -278,7 +278,7 @@ uint64_t Func_floor::getUintVal(Row& row, case execplan::CalpontSystemCatalog::TIMESTAMP: { string str = - DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), fTimeZone); + DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone()); // strip off micro seconds str = str.substr(0, 14); diff --git a/utils/funcexp/func_hour.cpp b/utils/funcexp/func_hour.cpp index 6959ce526..666e84ce0 100644 --- a/utils/funcexp/func_hour.cpp +++ b/utils/funcexp/func_hour.cpp @@ -114,7 +114,7 @@ int64_t Func_hour::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); return m_time.hour; } diff --git a/utils/funcexp/func_if.cpp b/utils/funcexp/func_if.cpp index b17ad7317..ef2827bbe 100644 --- a/utils/funcexp/func_if.cpp +++ b/utils/funcexp/func_if.cpp @@ -134,7 +134,7 @@ int64_t Func_if::getIntVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, fTimeZone)) + if (boolVal(parm[0], row, timeZone())) { return parm[1]->data()->getIntVal(row, isNull); } @@ -151,7 +151,7 @@ string Func_if::getStrVal(Row& row, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, fTimeZone)) + if (boolVal(parm[0], row, timeZone())) { return parm[1]->data()->getStrVal(row, isNull); } @@ -167,7 +167,7 @@ IDB_Decimal Func_if::getDecimalVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, fTimeZone)) + if (boolVal(parm[0], row, timeZone())) { return parm[1]->data()->getDecimalVal(row, isNull); } @@ -183,7 +183,7 @@ double Func_if::getDoubleVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, fTimeZone)) + if (boolVal(parm[0], row, timeZone())) { return parm[1]->data()->getDoubleVal(row, isNull); } @@ -198,7 +198,7 @@ long double Func_if::getLongDoubleVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, fTimeZone)) + if (boolVal(parm[0], row, timeZone())) { return parm[1]->data()->getLongDoubleVal(row, isNull); } @@ -214,7 +214,7 @@ int32_t Func_if::getDateIntVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, fTimeZone)) + if (boolVal(parm[0], row, timeZone())) { return parm[1]->data()->getDateIntVal(row, isNull); } @@ -230,7 +230,7 @@ int64_t Func_if::getDatetimeIntVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, fTimeZone)) + if (boolVal(parm[0], row, timeZone())) { return parm[1]->data()->getDatetimeIntVal(row, isNull); } @@ -246,7 +246,7 @@ int64_t Func_if::getTimestampIntVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, fTimeZone)) + if (boolVal(parm[0], row, timeZone())) { return parm[1]->data()->getTimestampIntVal(row, isNull); } @@ -262,7 +262,7 @@ int64_t Func_if::getTimeIntVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, fTimeZone)) + if (boolVal(parm[0], row, timeZone())) { return parm[1]->data()->getTimeIntVal(row, isNull); } diff --git a/utils/funcexp/func_last_day.cpp b/utils/funcexp/func_last_day.cpp index c201898db..2099ea71a 100644 --- a/utils/funcexp/func_last_day.cpp +++ b/utils/funcexp/func_last_day.cpp @@ -77,7 +77,7 @@ int64_t Func_last_day::getIntVal(rowgroup::Row& row, TimeStamp timestamp(parm[0]->data()->getIntVal(row, isNull)); int64_t seconds = timestamp.second; MySQLTime m_time; - gmtSecToMySQLTime(seconds, m_time, fTimeZone); + gmtSecToMySQLTime(seconds, m_time, timeZone()); year = m_time.year; month = m_time.month; day = m_time.day; diff --git a/utils/funcexp/func_math.cpp b/utils/funcexp/func_math.cpp index 705a13620..13c738217 100644 --- a/utils/funcexp/func_math.cpp +++ b/utils/funcexp/func_math.cpp @@ -1834,7 +1834,7 @@ string Func_format::getStrVal(Row& row, case execplan::CalpontSystemCatalog::TIMESTAMP: { - value = dataconvert::DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), fTimeZone); + value = dataconvert::DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone()); } break; diff --git a/utils/funcexp/func_minute.cpp b/utils/funcexp/func_minute.cpp index 10b3f1ef6..6cdd109a6 100644 --- a/utils/funcexp/func_minute.cpp +++ b/utils/funcexp/func_minute.cpp @@ -114,7 +114,7 @@ int64_t Func_minute::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); return m_time.minute; } diff --git a/utils/funcexp/func_month.cpp b/utils/funcexp/func_month.cpp index 94708fb1b..ffb3f5fc1 100644 --- a/utils/funcexp/func_month.cpp +++ b/utils/funcexp/func_month.cpp @@ -66,7 +66,7 @@ int64_t Func_month::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); return m_time.month; } diff --git a/utils/funcexp/func_monthname.cpp b/utils/funcexp/func_monthname.cpp index 831d16586..7c27c9581 100644 --- a/utils/funcexp/func_monthname.cpp +++ b/utils/funcexp/func_monthname.cpp @@ -107,7 +107,7 @@ int64_t Func_monthname::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(val); int64_t seconds = timestamp.second; dataconvert::MySQLTime time; - dataconvert::gmtSecToMySQLTime(seconds, time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, time, timeZone()); return time.month; } diff --git a/utils/funcexp/func_nullif.cpp b/utils/funcexp/func_nullif.cpp index a81b439dc..3af8a7d4b 100644 --- a/utils/funcexp/func_nullif.cpp +++ b/utils/funcexp/func_nullif.cpp @@ -978,7 +978,7 @@ execplan::IDB_Decimal Func_nullif::getDecimalVal(rowgroup::Row& row, string value; if (parm[1]->data()->resultType().colDataType == execplan::CalpontSystemCatalog::TIMESTAMP) - value = DataConvert::timestampToString1(parm[1]->data()->getTimestampIntVal(row, isNull), fTimeZone); + value = DataConvert::timestampToString1(parm[1]->data()->getTimestampIntVal(row, isNull), timeZone()); else value = DataConvert::datetimeToString1(parm[1]->data()->getDatetimeIntVal(row, isNull)); diff --git a/utils/funcexp/func_quarter.cpp b/utils/funcexp/func_quarter.cpp index e402444a7..6cc4316c4 100644 --- a/utils/funcexp/func_quarter.cpp +++ b/utils/funcexp/func_quarter.cpp @@ -70,7 +70,7 @@ int64_t Func_quarter::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); month = m_time.month; break; } diff --git a/utils/funcexp/func_regexp.cpp b/utils/funcexp/func_regexp.cpp index 809cb239a..120a727e6 100644 --- a/utils/funcexp/func_regexp.cpp +++ b/utils/funcexp/func_regexp.cpp @@ -244,7 +244,7 @@ bool Func_regexp::getBoolVal(rowgroup::Row& row, bool& isNull, CalpontSystemCatalog::ColType& ct) { - return getBool(row, pm, isNull, ct, fTimeZone) && !isNull; + return getBool(row, pm, isNull, ct, timeZone()) && !isNull; } diff --git a/utils/funcexp/func_round.cpp b/utils/funcexp/func_round.cpp index 293f94021..0064ae8df 100644 --- a/utils/funcexp/func_round.cpp +++ b/utils/funcexp/func_round.cpp @@ -490,7 +490,7 @@ IDB_Decimal Func_round::getDecimalVal(Row& row, string value; if (op_ct.colDataType == execplan::CalpontSystemCatalog::TIMESTAMP) - value = dataconvert::DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), fTimeZone); + value = dataconvert::DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone()); else value = dataconvert::DataConvert::datetimeToString1(parm[0]->data()->getDatetimeIntVal(row, isNull)); diff --git a/utils/funcexp/func_second.cpp b/utils/funcexp/func_second.cpp index 4f12cfca8..45cca7e21 100644 --- a/utils/funcexp/func_second.cpp +++ b/utils/funcexp/func_second.cpp @@ -113,7 +113,7 @@ int64_t Func_second::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); return m_time.second; } diff --git a/utils/funcexp/func_str_to_date.cpp b/utils/funcexp/func_str_to_date.cpp index 3432ba100..c4b0226f2 100644 --- a/utils/funcexp/func_str_to_date.cpp +++ b/utils/funcexp/func_str_to_date.cpp @@ -187,7 +187,7 @@ string Func_str_to_date::getStrVal(rowgroup::Row& row, CalpontSystemCatalog::ColType& ct) { dataconvert::DateTime dateTime; - dateTime = getDateTime(row, parm, isNull, ct, fTimeZone); + dateTime = getDateTime(row, parm, isNull, ct, timeZone()); string convertedDate = dataconvert::DataConvert::datetimeToString(*((long long*) &dateTime)); return convertedDate; } @@ -198,7 +198,7 @@ int32_t Func_str_to_date::getDateIntVal(rowgroup::Row& row, CalpontSystemCatalog::ColType& ct) { dataconvert::DateTime dateTime; - dateTime = getDateTime(row, parm, isNull, ct, fTimeZone); + dateTime = getDateTime(row, parm, isNull, ct, timeZone()); int64_t time = *(reinterpret_cast(&dateTime)); return ((((int32_t)(time >> 32)) & 0xFFFFFFC0) | 0x3E); } @@ -209,7 +209,7 @@ int64_t Func_str_to_date::getDatetimeIntVal(rowgroup::Row& row, CalpontSystemCatalog::ColType& ct) { dataconvert::DateTime dateTime; - dateTime = getDateTime(row, parm, isNull, ct, fTimeZone); + dateTime = getDateTime(row, parm, isNull, ct, timeZone()); int64_t time = *(reinterpret_cast(&dateTime)); return time; } @@ -220,7 +220,7 @@ int64_t Func_str_to_date::getTimestampIntVal(rowgroup::Row& row, CalpontSystemCatalog::ColType& ct) { dataconvert::DateTime dateTime; - dateTime = getDateTime(row, parm, isNull, ct, fTimeZone); + dateTime = getDateTime(row, parm, isNull, ct, timeZone()); dataconvert::TimeStamp timestamp; dataconvert::MySQLTime m_time; m_time.year = dateTime.year; @@ -230,7 +230,7 @@ int64_t Func_str_to_date::getTimestampIntVal(rowgroup::Row& row, m_time.minute = dateTime.minute; m_time.second = dateTime.second; bool isValid = true; - int64_t seconds = mySQLTimeToGmtSec(m_time, fTimeZone, isValid); + int64_t seconds = mySQLTimeToGmtSec(m_time, timeZone(), isValid); if (!isValid) { timestamp = -1; @@ -252,7 +252,7 @@ int64_t Func_str_to_date::getTimeIntVal(rowgroup::Row& row, { dataconvert::DateTime dateTime; dataconvert::Time retTime; - dateTime = getDateTime(row, parm, isNull, ct, fTimeZone); + dateTime = getDateTime(row, parm, isNull, ct, timeZone()); retTime.day = 0; retTime.is_neg = false; retTime.hour = dateTime.hour; @@ -269,7 +269,7 @@ int64_t Func_str_to_date::getIntVal(rowgroup::Row& row, CalpontSystemCatalog::ColType& ct) { dataconvert::DateTime dateTime; - dateTime = getDateTime(row, parm, isNull, ct, fTimeZone); + dateTime = getDateTime(row, parm, isNull, ct, timeZone()); int64_t time = *(reinterpret_cast(&dateTime)); return time; } diff --git a/utils/funcexp/func_time.cpp b/utils/funcexp/func_time.cpp index b83c678db..70202ac63 100644 --- a/utils/funcexp/func_time.cpp +++ b/utils/funcexp/func_time.cpp @@ -123,7 +123,7 @@ string Func_time::getStrVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); dataconvert::Time time; time.hour = m_time.hour; time.minute = m_time.minute; diff --git a/utils/funcexp/func_time_format.cpp b/utils/funcexp/func_time_format.cpp index 08739b046..5dd2f666a 100644 --- a/utils/funcexp/func_time_format.cpp +++ b/utils/funcexp/func_time_format.cpp @@ -77,7 +77,7 @@ string Func_time_format::getStrVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); hour = m_time.hour; min = m_time.minute; sec = m_time.second; diff --git a/utils/funcexp/func_time_to_sec.cpp b/utils/funcexp/func_time_to_sec.cpp index f8391d12f..e19ce2f81 100644 --- a/utils/funcexp/func_time_to_sec.cpp +++ b/utils/funcexp/func_time_to_sec.cpp @@ -76,7 +76,7 @@ int64_t Func_time_to_sec::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(val); int64_t seconds = timestamp.second; dataconvert::MySQLTime time; - dataconvert::gmtSecToMySQLTime(seconds, time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, time, timeZone()); hour = time.hour; min = time.minute; sec = time.second; diff --git a/utils/funcexp/func_timediff.cpp b/utils/funcexp/func_timediff.cpp index 881c04017..5bf16e413 100644 --- a/utils/funcexp/func_timediff.cpp +++ b/utils/funcexp/func_timediff.cpp @@ -152,7 +152,7 @@ string Func_timediff::getStrVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(temp); int64_t seconds = timestamp.second; dataconvert::MySQLTime time; - dataconvert::gmtSecToMySQLTime(seconds, time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, time, timeZone()); dataconvert::DateTime dt; dt.year = time.year; dt.month = time.month; @@ -239,7 +239,7 @@ string Func_timediff::getStrVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(temp); int64_t seconds = timestamp.second; dataconvert::MySQLTime time; - dataconvert::gmtSecToMySQLTime(seconds, time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, time, timeZone()); dataconvert::DateTime dt; dt.year = time.year; dt.month = time.month; @@ -332,7 +332,7 @@ int64_t Func_timediff::getTimestampIntVal(rowgroup::Row& row, bool& isNull, CalpontSystemCatalog::ColType& ct) { - return dataconvert::DataConvert::timestampToInt(getStrVal(row, parm, isNull, ct), fTimeZone); + return dataconvert::DataConvert::timestampToInt(getStrVal(row, parm, isNull, ct), timeZone()); } int64_t Func_timediff::getTimeIntVal(rowgroup::Row& row, diff --git a/utils/funcexp/func_timestampdiff.cpp b/utils/funcexp/func_timestampdiff.cpp index 60b18cdc7..3972554d3 100644 --- a/utils/funcexp/func_timestampdiff.cpp +++ b/utils/funcexp/func_timestampdiff.cpp @@ -57,7 +57,7 @@ int64_t Func_timestampdiff::getIntVal(rowgroup::Row& row, TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; MySQLTime m_time; - gmtSecToMySQLTime(seconds, m_time, fTimeZone); + gmtSecToMySQLTime(seconds, m_time, timeZone()); dt1.year = m_time.year; dt1.month = m_time.month; dt1.day = m_time.day; @@ -84,7 +84,7 @@ int64_t Func_timestampdiff::getIntVal(rowgroup::Row& row, TimeStamp timestamp(parm[1]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; MySQLTime m_time; - gmtSecToMySQLTime(seconds, m_time, fTimeZone); + gmtSecToMySQLTime(seconds, m_time, timeZone()); dt2.year = m_time.year; dt2.month = m_time.month; dt2.day = m_time.day; diff --git a/utils/funcexp/func_to_days.cpp b/utils/funcexp/func_to_days.cpp index b51eb5aff..26a993d1a 100644 --- a/utils/funcexp/func_to_days.cpp +++ b/utils/funcexp/func_to_days.cpp @@ -90,7 +90,7 @@ int64_t Func_to_days::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); year = m_time.year; month = m_time.month; day = m_time.day; diff --git a/utils/funcexp/func_truncate.cpp b/utils/funcexp/func_truncate.cpp index 441047f74..057a1c299 100644 --- a/utils/funcexp/func_truncate.cpp +++ b/utils/funcexp/func_truncate.cpp @@ -497,7 +497,7 @@ IDB_Decimal Func_truncate::getDecimalVal(Row& row, int64_t x = 0; string value = - DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), fTimeZone); + DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone()); s = parm[1]->data()->getIntVal(row, isNull); diff --git a/utils/funcexp/func_week.cpp b/utils/funcexp/func_week.cpp index 326f1c13a..af024cfe4 100644 --- a/utils/funcexp/func_week.cpp +++ b/utils/funcexp/func_week.cpp @@ -80,7 +80,7 @@ int64_t Func_week::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); year = m_time.year; month = m_time.month; day = m_time.day; diff --git a/utils/funcexp/func_weekday.cpp b/utils/funcexp/func_weekday.cpp index 9b6cc8c63..04ca938b4 100644 --- a/utils/funcexp/func_weekday.cpp +++ b/utils/funcexp/func_weekday.cpp @@ -76,7 +76,7 @@ int64_t Func_weekday::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getTimestampIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); year = m_time.year; month = m_time.month; day = m_time.day; diff --git a/utils/funcexp/func_year.cpp b/utils/funcexp/func_year.cpp index 94abdd79a..2c5ec41f9 100644 --- a/utils/funcexp/func_year.cpp +++ b/utils/funcexp/func_year.cpp @@ -66,7 +66,7 @@ int64_t Func_year::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); return m_time.year; } diff --git a/utils/funcexp/func_yearweek.cpp b/utils/funcexp/func_yearweek.cpp index 3ae72a7f2..91bb60a8c 100644 --- a/utils/funcexp/func_yearweek.cpp +++ b/utils/funcexp/func_yearweek.cpp @@ -83,7 +83,7 @@ int64_t Func_yearweek::getIntVal(rowgroup::Row& row, dataconvert::TimeStamp timestamp(parm[0]->data()->getIntVal(row, isNull)); int64_t seconds = timestamp.second; dataconvert::MySQLTime m_time; - dataconvert::gmtSecToMySQLTime(seconds, m_time, fTimeZone); + dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone()); year = m_time.year; month = m_time.month; day = m_time.day; diff --git a/utils/funcexp/functor.cpp b/utils/funcexp/functor.cpp index 06999c9fd..7fb55b47e 100644 --- a/utils/funcexp/functor.cpp +++ b/utils/funcexp/functor.cpp @@ -112,7 +112,7 @@ uint64_t Func::stringToDatetime(const string str) uint64_t Func::stringToTimestamp(const string str) { - int64_t ret = DataConvert::stringToTimestamp(str, fTimeZone); + int64_t ret = DataConvert::stringToTimestamp(str, timeZone()); if (ret == -1) { diff --git a/utils/funcexp/functor.h b/utils/funcexp/functor.h index 357d8639d..12dadc83a 100644 --- a/utils/funcexp/functor.h +++ b/utils/funcexp/functor.h @@ -27,6 +27,7 @@ #include #include #include +#include #include "parsetree.h" #include "exceptclasses.h" @@ -73,10 +74,12 @@ public: const std::string timeZone() const { + std::unique_lock l(tzMutex); return fTimeZone; } void timeZone(const std::string timeZone) { + std::unique_lock l(tzMutex); fTimeZone = timeZone; } @@ -201,7 +204,6 @@ protected: virtual int64_t addTime(dataconvert::Time& dt1, dataconvert::Time& dt2); std::string fFuncName; - std::string fTimeZone; private: //defaults okay @@ -213,6 +215,9 @@ private: float fFloatNullVal; double fDoubleNullVal; long double fLongDoubleNullVal; + + std::string fTimeZone; + mutable std::mutex tzMutex; };