diff --git a/dbcon/execplan/simplefilter.cpp b/dbcon/execplan/simplefilter.cpp index 1da14449c..639a04945 100644 --- a/dbcon/execplan/simplefilter.cpp +++ b/dbcon/execplan/simplefilter.cpp @@ -606,6 +606,7 @@ void SimpleFilter::convertConstant() result.intVal = dataconvert::DataConvert::timeToInt(result.strVal); } } + rcc->result(result); } } diff --git a/dbcon/execplan/treenode.h b/dbcon/execplan/treenode.h index 3b2dd7200..cef9579e9 100644 --- a/dbcon/execplan/treenode.h +++ b/dbcon/execplan/treenode.h @@ -995,6 +995,7 @@ inline int64_t TreeNode::getDatetimeIntVal() int day = 0; memcpy(&tt, &fResult.intVal, 8); + // Note, this should probably be current date +/- time if ((tt.hour > 23) && (!tt.is_neg)) { @@ -1005,6 +1006,7 @@ inline int64_t TreeNode::getDatetimeIntVal() { tt.hour = 0; } + dataconvert::DateTime dt(0, 0, day, tt.hour, tt.minute, tt.second, tt.msecond); memcpy(&fResult.intVal, &dt, 8); return fResult.intVal; diff --git a/dbcon/joblist/groupconcat.cpp b/dbcon/joblist/groupconcat.cpp index 1e84585b3..234fc0a8e 100644 --- a/dbcon/joblist/groupconcat.cpp +++ b/dbcon/joblist/groupconcat.cpp @@ -648,10 +648,12 @@ int64_t GroupConcator::lengthEstimate(const rowgroup::Row& row) fieldLen = 19; // YYYY-MM-DD HH24:MI:SS // Decimal point and milliseconds uint64_t colPrecision = row.getPrecision(*i); + if (colPrecision > 0 && colPrecision < 7) { fieldLen += colPrecision + 1; } + break; } @@ -660,10 +662,12 @@ int64_t GroupConcator::lengthEstimate(const rowgroup::Row& row) fieldLen = 10; // -HHH:MI:SS // Decimal point and milliseconds uint64_t colPrecision = row.getPrecision(*i); + if (colPrecision > 0 && colPrecision < 7) { fieldLen += colPrecision + 1; } + break; } diff --git a/dbcon/mysql/ha_calpont_dml.cpp b/dbcon/mysql/ha_calpont_dml.cpp index 57a91bd89..cf103a801 100644 --- a/dbcon/mysql/ha_calpont_dml.cpp +++ b/dbcon/mysql/ha_calpont_dml.cpp @@ -842,6 +842,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ const uchar* pos = buf; longlong tmp = my_datetime_packed_from_binary(pos, table->field[colpos]->decimals()); TIME_from_longlong_datetime_packed(<ime, tmp); + if (!ltime.second_part) { fprintf(ci.filePtr, "%04d-%02d-%02d %02d:%02d:%02d%c", @@ -855,6 +856,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ ltime.hour, ltime.minute, ltime.second, ltime.second_part, ci.delimiter); } + buf += table->field[colpos]->pack_length(); } else @@ -892,6 +894,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ const uchar* pos = buf; longlong tmp = my_time_packed_from_binary(pos, table->field[colpos]->decimals()); TIME_from_longlong_time_packed(<ime, tmp); + if (!ltime.second_part) { fprintf(ci.filePtr, "%02d:%02d:%02d%c", @@ -903,6 +906,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ ltime.hour, ltime.minute, ltime.second, ltime.second_part, ci.delimiter); } + buf += table->field[colpos]->pack_length(); } diff --git a/utils/dataconvert/dataconvert.cpp b/utils/dataconvert/dataconvert.cpp index 0ba1e4a87..b1cf8bcb2 100644 --- a/utils/dataconvert/dataconvert.cpp +++ b/utils/dataconvert/dataconvert.cpp @@ -1020,10 +1020,11 @@ bool mysql_str_to_time( const string& input, Time& output ) { output.reset(); } + return false; } - output.hour = isNeg ? 0-hour : hour; + output.hour = isNeg ? 0 - hour : hour; output.minute = min; output.second = sec; output.msecond = usec; @@ -1416,7 +1417,7 @@ DataConvert::convertColumnData(const CalpontSystemCatalog::ColType& colType, if (stringToTimeStruct(data, aTime)) { - value = (int64_t) *(reinterpret_cast(&aTime)); + value = (int64_t) * (reinterpret_cast(&aTime)); } else { @@ -1918,6 +1919,7 @@ int64_t DataConvert::convertColumnTime( inSecond = 0; inMicrosecond = 0; bool isNeg = false; + if ( datetimeFormat != CALPONTTIME_ENUM ) { status = -1; @@ -1941,6 +1943,7 @@ int64_t DataConvert::convertColumnTime( } p = strtok_r(NULL, ":.", &savePoint); + if (p == NULL) { status = -1; @@ -1976,6 +1979,7 @@ int64_t DataConvert::convertColumnTime( if (p != NULL) { inMicrosecond = strtol(p, 0, 10); + if (errno) { status = -1; @@ -2017,6 +2021,7 @@ int64_t DataConvert::convertColumnTime( atime.is_neg = false; memcpy( &value, &atime, 8); } + // If neither of the above match then we return a 0 time status = -1; @@ -2067,21 +2072,25 @@ std::string DataConvert::datetimeToString( long long datetimevalue, long decima { decimals = 0; } + // @bug 4703 abandon multiple ostringstream's for conversion DateTime dt(datetimevalue); const int DATETIMETOSTRING_LEN = 28; // YYYY-MM-DD HH:MM:SS.mmmmmm\0 char buf[DATETIMETOSTRING_LEN]; sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02d", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second); + if (dt.msecond && decimals) { snprintf(buf + strlen(buf), 21 + decimals, ".%d", dt.msecond); + // Pad end with zeros if (strlen(buf) < (size_t)(21 + decimals)) { sprintf(buf + strlen(buf), "%0*d", (int)(21 + decimals - strlen(buf)), 0); } } + return buf; } @@ -2092,6 +2101,7 @@ std::string DataConvert::timeToString( long long timevalue, long decimals ) { decimals = 0; } + // @bug 4703 abandon multiple ostringstream's for conversion Time dt(timevalue); const int TIMETOSTRING_LEN = 19; // (-H)HH:MM:SS.mmmmmm\0 @@ -2105,16 +2115,19 @@ std::string DataConvert::timeToString( long long timevalue, long decimals ) } sprintf(outbuf, "%02d:%02d:%02d", dt.hour, dt.minute, dt.second); + if (dt.msecond && decimals) { size_t start = strlen(buf); snprintf(buf + strlen(buf), 12 + decimals, ".%d", dt.msecond); + // Pad end with zeros if (strlen(buf) - start < (size_t)decimals) { sprintf(buf + strlen(buf), "%0*d", (int)(decimals - (strlen(buf) - start) + 1), 0); } } + return buf; } diff --git a/utils/dataconvert/dataconvert.h b/utils/dataconvert/dataconvert.h index 01e530709..0cf3480c5 100644 --- a/utils/dataconvert/dataconvert.h +++ b/utils/dataconvert/dataconvert.h @@ -277,6 +277,7 @@ inline uint32_t getDaysInMonth(uint32_t month, int year) return 0; uint32_t days = daysInMonth[month - 1]; + if ((month == 2) && isLeapYear(year)) days++; @@ -567,11 +568,14 @@ inline void DataConvert::datetimeToString( long long datetimevalue, char* buf, u { decimals = 0; } + int msec = 0; + if ((datetimevalue & 0xfffff) > 0) { msec = (unsigned)((datetimevalue) & 0xfffff); } + snprintf( buf, buflen, "%04d-%02d-%02d %02d:%02d:%02d", (unsigned)((datetimevalue >> 48) & 0xffff), (unsigned)((datetimevalue >> 44) & 0xf), @@ -585,6 +589,7 @@ inline void DataConvert::datetimeToString( long long datetimevalue, char* buf, u { size_t start = strlen(buf); snprintf(buf + strlen(buf), buflen - start, ".%d", msec); + // Pad end with zeros if (strlen(buf) - start < (size_t)decimals) { @@ -600,8 +605,10 @@ inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned { decimals = 0; } + // Handle negative correctly int hour = 0, msec = 0; + if ((timevalue >> 40) & 0x800) { hour = 0xfffff000; @@ -613,12 +620,14 @@ inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned { msec = (unsigned)((timevalue) & 0xffffff); } + if ((hour >= 0) && (timevalue >> 63)) { buf[0] = '-'; buf++; buflen--; } + snprintf( buf, buflen, "%02d:%02d:%02d", hour, (unsigned)((timevalue >> 32) & 0xff), @@ -629,6 +638,7 @@ inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned { size_t start = strlen(buf); snprintf(buf + strlen(buf), buflen - start, ".%d", msec); + // Pad end with zeros if (strlen(buf) - start < (size_t)decimals) { @@ -662,6 +672,7 @@ inline void DataConvert::timeToString1( long long timevalue, char* buf, unsigned { // Handle negative correctly int hour = 0; + if ((timevalue >> 40) & 0x800) { hour = 0xfffff000; diff --git a/utils/funcexp/func_add_time.cpp b/utils/funcexp/func_add_time.cpp index bb32dc79d..ced9beaf2 100644 --- a/utils/funcexp/func_add_time.cpp +++ b/utils/funcexp/func_add_time.cpp @@ -320,9 +320,9 @@ int64_t Func_add_time::getDatetimeIntVal(rowgroup::Row& row, } int64_t Func_add_time::getTimeIntVal(rowgroup::Row& row, - FunctionParm& parm, - bool& isNull, - CalpontSystemCatalog::ColType& ct) + FunctionParm& parm, + bool& isNull, + CalpontSystemCatalog::ColType& ct) { int64_t val1 = parm[0]->data()->getTimeIntVal(row, isNull); diff --git a/utils/funcexp/func_bitand.cpp b/utils/funcexp/func_bitand.cpp index 6906a928a..69429bfb8 100644 --- a/utils/funcexp/func_bitand.cpp +++ b/utils/funcexp/func_bitand.cpp @@ -165,6 +165,7 @@ int64_t Func_bitand::getIntVal(Row& row, min = 0, sec = 0, msec = 0; + // Handle negative correctly if ((time >> 40) & 0x800) { @@ -172,8 +173,10 @@ int64_t Func_bitand::getIntVal(Row& row, } hour |= ((time >> 40) & 0xfff); + if ((hour >= 0) && (time >> 63)) - hour*= -1; + hour *= -1; + min = (uint32_t)((time >> 32) & 0xff); sec = (uint32_t)((time >> 24) & 0xff); msec = (uint32_t)(time & 0xffffff); diff --git a/utils/funcexp/func_case.cpp b/utils/funcexp/func_case.cpp index f9d70cb75..4c416360c 100644 --- a/utils/funcexp/func_case.cpp +++ b/utils/funcexp/func_case.cpp @@ -546,9 +546,9 @@ int64_t Func_simple_case::getDatetimeIntVal(rowgroup::Row& row, int64_t Func_simple_case::getTimeIntVal(rowgroup::Row& row, - FunctionParm& parm, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct) + FunctionParm& parm, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct) { uint64_t i = simple_case_cmp(row, parm, isNull, op_ct); diff --git a/utils/funcexp/func_coalesce.cpp b/utils/funcexp/func_coalesce.cpp index 30091a81e..e03040350 100644 --- a/utils/funcexp/func_coalesce.cpp +++ b/utils/funcexp/func_coalesce.cpp @@ -140,9 +140,9 @@ int64_t Func_coalesce::getDatetimeIntVal(rowgroup::Row& row, } int64_t Func_coalesce::getTimeIntVal(rowgroup::Row& row, - FunctionParm& parm, - bool& isNull, - CalpontSystemCatalog::ColType& ct) + FunctionParm& parm, + bool& isNull, + CalpontSystemCatalog::ColType& ct) { int64_t val = 0; diff --git a/utils/funcexp/func_extract.cpp b/utils/funcexp/func_extract.cpp index c77a23d70..332c05441 100644 --- a/utils/funcexp/func_extract.cpp +++ b/utils/funcexp/func_extract.cpp @@ -135,26 +135,28 @@ long long dateGet( uint64_t time, IntervalColumn::interval_type unit, bool dateT long long timeGet( uint64_t time, IntervalColumn::interval_type unit ) { int32_t hour = 0, - min = 0, - sec = 0, - msec = 0, - day = 0; + min = 0, + sec = 0, + msec = 0, + day = 0; - min = (int32_t)((time >> 32) & 0xff); - sec = (int32_t)((time >> 24) & 0xff); - msec = (int32_t)((time & 0xfffff)); + min = (int32_t)((time >> 32) & 0xff); + sec = (int32_t)((time >> 24) & 0xff); + msec = (int32_t)((time & 0xfffff)); - // If negative, mask so it doesn't turn positive - int64_t mask = 0; - if ((time >> 40) & 0x800) - mask = 0xfffffffffffff000; - hour = mask | ((time >> 40) & 0xfff); + // If negative, mask so it doesn't turn positive + int64_t mask = 0; - if ((hour >= 0) && (time >> 63)) - hour*= -1; + if ((time >> 40) & 0x800) + mask = 0xfffffffffffff000; - // Always positive! - day = abs(hour / 24); + hour = mask | ((time >> 40) & 0xfff); + + if ((hour >= 0) && (time >> 63)) + hour *= -1; + + // Always positive! + day = abs(hour / 24); switch ( unit ) { @@ -275,6 +277,7 @@ int64_t Func_extract::getIntVal(rowgroup::Row& row, } long long value; + if (isTime) value = timeGet( time, unit ); else diff --git a/utils/funcexp/func_greatest.cpp b/utils/funcexp/func_greatest.cpp index 80dbd251f..de63c283e 100644 --- a/utils/funcexp/func_greatest.cpp +++ b/utils/funcexp/func_greatest.cpp @@ -207,9 +207,9 @@ int64_t Func_greatest::getDatetimeIntVal(rowgroup::Row& row, } int64_t Func_greatest::getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& ct) + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& ct) { // Strip off unused day int64_t greatestStr = fp[0]->data()->getTimeIntVal(row, isNull); diff --git a/utils/funcexp/func_hour.cpp b/utils/funcexp/func_hour.cpp index 631b070c8..685a264db 100644 --- a/utils/funcexp/func_hour.cpp +++ b/utils/funcexp/func_hour.cpp @@ -130,6 +130,7 @@ int64_t Func_hour::getIntVal(rowgroup::Row& row, // If negative, mask so it doesn't turn positive bool isNeg = false; int64_t mask = 0; + if ((val >> 40) & 0x800) mask = 0xfffffffffffff000; @@ -137,9 +138,11 @@ int64_t Func_hour::getIntVal(rowgroup::Row& row, { isNeg = true; } + val = mask | ((val >> 40) & 0xfff); + if (isNeg) - val*= -1; + val *= -1; } else { diff --git a/utils/funcexp/func_if.cpp b/utils/funcexp/func_if.cpp index 4cc8cd164..ad65d10c9 100644 --- a/utils/funcexp/func_if.cpp +++ b/utils/funcexp/func_if.cpp @@ -221,9 +221,9 @@ int64_t Func_if::getDatetimeIntVal(Row& row, } int64_t Func_if::getTimeIntVal(Row& row, - FunctionParm& parm, - bool& isNull, - CalpontSystemCatalog::ColType&) + FunctionParm& parm, + bool& isNull, + CalpontSystemCatalog::ColType&) { if (boolVal(parm[0], row)) { diff --git a/utils/funcexp/func_ifnull.cpp b/utils/funcexp/func_ifnull.cpp index 18887f00e..4b8606d4e 100644 --- a/utils/funcexp/func_ifnull.cpp +++ b/utils/funcexp/func_ifnull.cpp @@ -169,9 +169,9 @@ int64_t Func_ifnull::getDatetimeIntVal(Row& row, } int64_t Func_ifnull::getTimeIntVal(Row& row, - FunctionParm& parm, - bool& isNull, - CalpontSystemCatalog::ColType&) + FunctionParm& parm, + bool& isNull, + CalpontSystemCatalog::ColType&) { if (isNull) return 0; diff --git a/utils/funcexp/func_inet_aton.cpp b/utils/funcexp/func_inet_aton.cpp index d6e3465cf..9692cf850 100644 --- a/utils/funcexp/func_inet_aton.cpp +++ b/utils/funcexp/func_inet_aton.cpp @@ -223,9 +223,9 @@ int64_t Func_inet_aton::getDatetimeIntVal(rowgroup::Row& row, } int64_t Func_inet_aton::getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct) + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct) { int64_t iValue = joblist::TIMENULL; diff --git a/utils/funcexp/func_inet_ntoa.cpp b/utils/funcexp/func_inet_ntoa.cpp index e25f56097..ff8c889ed 100644 --- a/utils/funcexp/func_inet_ntoa.cpp +++ b/utils/funcexp/func_inet_ntoa.cpp @@ -257,9 +257,9 @@ int64_t Func_inet_ntoa::getDatetimeIntVal(rowgroup::Row& row, } int64_t Func_inet_ntoa::getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct) + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct) { // std::cout << "In Func_inet_ntoa::getTimeVal" << std::endl; diff --git a/utils/funcexp/func_least.cpp b/utils/funcexp/func_least.cpp index ee5b2afc0..9ba5c98de 100644 --- a/utils/funcexp/func_least.cpp +++ b/utils/funcexp/func_least.cpp @@ -183,9 +183,9 @@ int64_t Func_least::getDatetimeIntVal(rowgroup::Row& row, } int64_t Func_least::getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct) + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct) { // Strip off unused day int64_t leastStr = fp[0]->data()->getTimeIntVal(row, isNull); diff --git a/utils/funcexp/func_nullif.cpp b/utils/funcexp/func_nullif.cpp index 30d4682e5..a268b0ea1 100644 --- a/utils/funcexp/func_nullif.cpp +++ b/utils/funcexp/func_nullif.cpp @@ -129,8 +129,8 @@ int64_t Func_nullif::getIntVal(rowgroup::Row& row, if ((parm[0]->data()->resultType().colDataType == execplan::CalpontSystemCatalog::DATE) || - (parm[0]->data()->resultType().colDataType == - execplan::CalpontSystemCatalog::DATETIME)) + (parm[0]->data()->resultType().colDataType == + execplan::CalpontSystemCatalog::DATETIME)) { // NULLIF arg0 is DATE, arg1 is DATETIME, @@ -164,8 +164,8 @@ int64_t Func_nullif::getIntVal(rowgroup::Row& row, if ((parm[0]->data()->resultType().colDataType == execplan::CalpontSystemCatalog::DATETIME) || - (parm[0]->data()->resultType().colDataType == - execplan::CalpontSystemCatalog::TIME)) + (parm[0]->data()->resultType().colDataType == + execplan::CalpontSystemCatalog::TIME)) { // NULLIF arg0 is DATETIME, arg1 is TIME, // Upgrade arg1 to time @@ -495,9 +495,9 @@ int64_t Func_nullif::getDatetimeIntVal(rowgroup::Row& row, } int64_t Func_nullif::getTimeIntVal(rowgroup::Row& row, - FunctionParm& parm, - bool& isNull, - CalpontSystemCatalog::ColType& ct) + FunctionParm& parm, + bool& isNull, + CalpontSystemCatalog::ColType& ct) { int64_t exp1 = parm[0]->data()->getTimeIntVal(row, isNull); int64_t exp2 = 0; diff --git a/utils/funcexp/func_sysdate.cpp b/utils/funcexp/func_sysdate.cpp index d8e2580bb..bf71e0415 100644 --- a/utils/funcexp/func_sysdate.cpp +++ b/utils/funcexp/func_sysdate.cpp @@ -101,9 +101,9 @@ int64_t Func_sysdate::getDatetimeIntVal(rowgroup::Row& row, } int64_t Func_sysdate::getTimeIntVal(rowgroup::Row& row, - FunctionParm& parm, - bool& isNull, - CalpontSystemCatalog::ColType& operationColType) + FunctionParm& parm, + bool& isNull, + CalpontSystemCatalog::ColType& operationColType) { return getIntVal(row, parm, isNull, operationColType); } diff --git a/utils/funcexp/func_time.cpp b/utils/funcexp/func_time.cpp index bd28d6e6c..4a90e0fe2 100644 --- a/utils/funcexp/func_time.cpp +++ b/utils/funcexp/func_time.cpp @@ -111,6 +111,7 @@ string Func_time::getStrVal(rowgroup::Row& row, val = parm[0]->data()->getTimeIntVal(row, isNull); break; } + case execplan::CalpontSystemCatalog::DATETIME: { val = parm[0]->data()->getTimeIntVal(row, isNull); diff --git a/utils/funcexp/func_time_to_sec.cpp b/utils/funcexp/func_time_to_sec.cpp index 0d804242c..ee5c4b669 100644 --- a/utils/funcexp/func_time_to_sec.cpp +++ b/utils/funcexp/func_time_to_sec.cpp @@ -50,8 +50,8 @@ int64_t Func_time_to_sec::getIntVal(rowgroup::Row& row, { // assume 256 is enough. assume not allowing incomplete date int32_t hour = 0, - min = 0, - sec = 0; + min = 0, + sec = 0; bool bIsNegative = false; // Only set to true if CHAR or VARCHAR with a '-' int64_t val = 0; @@ -72,16 +72,19 @@ int64_t Func_time_to_sec::getIntVal(rowgroup::Row& row, case CalpontSystemCatalog::TIME: val = parm[0]->data()->getTimeIntVal(row, isNull); + // If negative, mask so it doesn't turn positive if ((val >> 40) & 0x800) mask = 0xfffffffffffff000; bIsNegative = val >> 63; hour = (int32_t)(mask | ((val >> 40) & 0xfff)); + if ((hour >= 0) && bIsNegative) - hour*= -1; + hour *= -1; else bIsNegative = false; + min = (int32_t)((val >> 32) & 0xff); sec = (int32_t)((val >> 24) & 0xff); break; @@ -162,6 +165,7 @@ int64_t Func_time_to_sec::getIntVal(rowgroup::Row& row, } int64_t rtn; + if (hour < 0) { rtn = (int64_t)(hour * 60 * 60) - (min * 60) - sec; diff --git a/utils/funcexp/func_timediff.cpp b/utils/funcexp/func_timediff.cpp index 3c9ce96a8..742e8faf7 100644 --- a/utils/funcexp/func_timediff.cpp +++ b/utils/funcexp/func_timediff.cpp @@ -216,9 +216,9 @@ int64_t Func_timediff::getDatetimeIntVal(rowgroup::Row& row, } int64_t Func_timediff::getTimeIntVal(rowgroup::Row& row, - FunctionParm& parm, - bool& isNull, - CalpontSystemCatalog::ColType& ct) + FunctionParm& parm, + bool& isNull, + CalpontSystemCatalog::ColType& ct) { return dataconvert::DataConvert::timeToInt(getStrVal(row, parm, isNull, ct)); } diff --git a/utils/funcexp/functor.h b/utils/funcexp/functor.h index 065eb7865..9edb9bf62 100644 --- a/utils/funcexp/functor.h +++ b/utils/funcexp/functor.h @@ -117,9 +117,9 @@ public: } virtual int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct) + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct) { return intToTime(getIntVal(row, fp, isNull, op_ct)); } diff --git a/utils/funcexp/functor_all.h b/utils/funcexp/functor_all.h index 0eb0df845..553abc40f 100644 --- a/utils/funcexp/functor_all.h +++ b/utils/funcexp/functor_all.h @@ -105,10 +105,10 @@ public: bool& isNull, execplan::CalpontSystemCatalog::ColType& op_ct); - int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + int64_t getTimeIntVal(rowgroup::Row& row, + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); }; @@ -158,9 +158,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); }; @@ -206,9 +206,10 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct);}; + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); +}; /** @brief Func_ifnull class @@ -252,9 +253,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); bool getBoolVal(rowgroup::Row& row, FunctionParm& fp, @@ -309,9 +310,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); }; @@ -357,9 +358,10 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct);}; + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); +}; /** @brief Func_coalesce class @@ -403,9 +405,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); }; @@ -435,9 +437,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getIntVal(rowgroup::Row& row, FunctionParm& fp, diff --git a/utils/funcexp/functor_bool.h b/utils/funcexp/functor_bool.h index f67f405f1..b7b85106b 100644 --- a/utils/funcexp/functor_bool.h +++ b/utils/funcexp/functor_bool.h @@ -99,9 +99,9 @@ public: } int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct) + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct) { isNull = true; return 0; diff --git a/utils/funcexp/functor_dtm.h b/utils/funcexp/functor_dtm.h index 74aa41e38..d7837a4fe 100644 --- a/utils/funcexp/functor_dtm.h +++ b/utils/funcexp/functor_dtm.h @@ -138,9 +138,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getIntVal(rowgroup::Row& row, FunctionParm& fp, @@ -254,9 +254,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); }; @@ -324,9 +324,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); }; @@ -361,9 +361,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); }; @@ -393,9 +393,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getIntVal(rowgroup::Row& row, FunctionParm& fp, @@ -439,9 +439,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); }; /** @brief Func_str_to_date class diff --git a/utils/funcexp/functor_real.h b/utils/funcexp/functor_real.h index 779f4d108..5d40ce589 100644 --- a/utils/funcexp/functor_real.h +++ b/utils/funcexp/functor_real.h @@ -655,9 +655,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); private: diff --git a/utils/funcexp/functor_str.h b/utils/funcexp/functor_str.h index 895101211..c71cdec91 100644 --- a/utils/funcexp/functor_str.h +++ b/utils/funcexp/functor_str.h @@ -90,9 +90,9 @@ public: } int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct) + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct) { std::string str = getStrVal(row, fp, isNull, op_ct); return (isNull ? 0 : stringToTime(str)); @@ -685,9 +685,9 @@ public: execplan::CalpontSystemCatalog::ColType& op_ct); int64_t getTimeIntVal(rowgroup::Row& row, - FunctionParm& fp, - bool& isNull, - execplan::CalpontSystemCatalog::ColType& op_ct); + FunctionParm& fp, + bool& isNull, + execplan::CalpontSystemCatalog::ColType& op_ct); private: void convertNtoa(int64_t ipNum, std::string& ipString); }; diff --git a/utils/rowgroup/rowaggregation.cpp b/utils/rowgroup/rowaggregation.cpp index c496d91e6..8d110cfc8 100644 --- a/utils/rowgroup/rowaggregation.cpp +++ b/utils/rowgroup/rowaggregation.cpp @@ -1543,6 +1543,7 @@ void RowAggregation::doBitOp(const Row& rowIn, int64_t colIn, int64_t colOut, in int64_t dtm = rowIn.getUintField(colIn); // Handle negative correctly int hour = 0; + if ((dtm >> 40) & 0x800) { hour = 0xfffff000; @@ -2077,6 +2078,7 @@ void RowAggregation::doUDAF(const Row& rowIn, int64_t colIn, int64_t colOut, int datum.columnData = rowIn.getUintField(colIn); break; } + case execplan::CalpontSystemCatalog::TIME: { datum.dataType = execplan::CalpontSystemCatalog::BIGINT; diff --git a/writeengine/bulk/we_bulkloadbuffer.cpp b/writeengine/bulk/we_bulkloadbuffer.cpp index ccf73363f..506bff2eb 100644 --- a/writeengine/bulk/we_bulkloadbuffer.cpp +++ b/writeengine/bulk/we_bulkloadbuffer.cpp @@ -902,8 +902,8 @@ void BulkLoadBuffer::convert(char* field, int fieldLength, { bool bSatVal = false; - if ( column.dataType != CalpontSystemCatalog::DATETIME && - column.dataType != CalpontSystemCatalog::TIME ) + if ( column.dataType != CalpontSystemCatalog::DATETIME && + column.dataType != CalpontSystemCatalog::TIME ) { if (nullFlag) {