diff --git a/datatypes/mcs_datatype.cpp b/datatypes/mcs_datatype.cpp index 9a0a3d5fd..a66bb6147 100644 --- a/datatypes/mcs_datatype.cpp +++ b/datatypes/mcs_datatype.cpp @@ -289,6 +289,18 @@ const string& TypeHandlerEnum::name() const return xname; } +const string& TypeHandlerSet::name() const +{ + static const string xname = "SET"; + return xname; +} + +const string& TypeHandlerJson::name() const +{ + static const string xname = "JSON"; + return xname; +} + TypeHandlerBit mcs_type_handler_bit; TypeHandlerSInt8 mcs_type_handler_sint8; @@ -304,6 +316,8 @@ TypeHandlerUInt32 mcs_type_handler_uint32; TypeHandlerUInt64 mcs_type_handler_uint64; TypeHandlerEnum mcs_type_handler_enum; +TypeHandlerSet mcs_type_handler_set; +TypeHandlerJson mcs_type_handler_json; TypeHandlerSFloat mcs_type_handler_sfloat; TypeHandlerSDouble mcs_type_handler_sdouble; @@ -353,6 +367,8 @@ const TypeHandler* TypeHandler::find(SystemCatalog::ColDataType typeCode, case SystemCatalog::UDOUBLE: return &mcs_type_handler_udouble; case SystemCatalog::ENUM: return &mcs_type_handler_enum; + case SystemCatalog::SET: return &mcs_type_handler_set; + case SystemCatalog::JSON: return &mcs_type_handler_json; case SystemCatalog::DECIMAL: if (static_cast(ct.colWidth) < datatypes::MAXDECIMALWIDTH) @@ -1567,8 +1583,8 @@ boost::any TypeHandlerEnum::convertFromString(const SystemCatalog::TypeAttribute { unsigned short val = 0; - for (; valsize(); ++val) { + if (colType.colDataType.values().get()->operator[](val) == data) { break; } } @@ -1579,6 +1595,36 @@ boost::any TypeHandlerEnum::convertFromString(const SystemCatalog::TypeAttribute return value; } +boost::any TypeHandlerSet::convertFromString(const SystemCatalog::TypeAttributesStd& colType, + const ConvertFromStringParam&, const std::string& data, + bool&) const +{ + unsigned short val = 0; + + for (; valsize(); ++val) { + if (colType.colDataType.values().get()->operator[](val) == data) { + break; + } + } + + // Nedeljko TO DO + boost::any value = val; + + return value; +} + +boost::any TypeHandlerJson::convertFromString(const SystemCatalog::TypeAttributesStd&, + const ConvertFromStringParam&, const std::string&, + bool&) const +{ + unsigned short val = 0; + + // Nedeljko TO DO + boost::any value = val; + + return value; +} + boost::any TypeHandlerSInt8::convertFromString(const SystemCatalog::TypeAttributesStd& colType, const ConvertFromStringParam& prm, const std::string& data, bool& pushWarning) const diff --git a/datatypes/mcs_datatype.h b/datatypes/mcs_datatype.h index 2b3194a1c..d332198d9 100644 --- a/datatypes/mcs_datatype.h +++ b/datatypes/mcs_datatype.h @@ -19,6 +19,7 @@ #include #include +#include #include "exceptclasses.h" #include "basic/conststring.h" #include "mcs_datatype_basic.h" @@ -148,11 +149,13 @@ class SystemCatalog /** the set of Calpont column data types * - */ - enum ColDataType - { + */ + + enum Kind { BIT, /*!< BIT type */ ENUM, /*!< ENUM type */ + SET, + JSON, TINYINT, /*!< TINYINT type */ CHAR, /*!< CHAR type */ SMALLINT, /*!< SMALLINT type */ @@ -185,6 +188,65 @@ class SystemCatalog UNDEFINED, /*!< Undefined - used in UDAF API */ }; + class ColDataType + { + Kind _kind; + std::shared_ptr> _values; + + public: + ColDataType() : _kind(UNDEFINED) + { + } + + ColDataType(Kind kind) : _kind(kind) + { + assert(_kind != ENUM && _kind != SET); + } + + ColDataType(Kind kind, const std::vector &values) : _kind(kind), _values(new std::vector(values)) + { + assert(_kind != ENUM || _kind == SET); + } + + operator Kind() const { + return _kind; + } + + bool operator==(Kind val) const { + assert((_kind!=val) || (_kind!=ENUM && _kind!=SET)); + + return _kind==val; + } + + Kind kind() const + { + return _kind; + } + + const std::shared_ptr>& values() const + { + return _values; + } + + ColDataType& operator=(Kind kind) + { + assert(_kind != ENUM && _kind != SET); + _kind = kind; + _values.reset(); + + return *this; + } + + void set(Kind kind, const std::shared_ptr> &values) + { + assert(_kind != ENUM || _kind == SET); + _kind = kind; + _values = values; + } + + bool operator==(const ColDataType &) const = default; + }; + // XXX: It is assumed here that ALL TYPES have width, scale and precision. // XXX: And then some of them have the type tag itself. // XXX: But, all types have type tag, some need explicit width (decimals, for example) @@ -196,12 +258,13 @@ class SystemCatalog int32_t colWidth; int32_t scale; // number after decimal points int32_t precision; - std::vector enumVals; + ColDataType colDataType; +// std::vector enumVals; - TypeAttributesStd() : colWidth(0), scale(0), precision(-1) + TypeAttributesStd() : colWidth(0), scale(0), precision(-1), colDataType(MEDINT) { } - TypeAttributesStd(int32_t w, int32_t s, int32_t p) : colWidth(w), scale(s), precision(p) + TypeAttributesStd(int32_t w, int32_t s, int32_t p) : colWidth(w), scale(s), precision(p), colDataType(MEDINT) { } /** @@ -279,8 +342,7 @@ class SystemCatalog class TypeHolderStd : public TypeAttributesStd { public: - ColDataType colDataType; - TypeHolderStd() : colDataType(MEDINT) + TypeHolderStd() { } const class TypeHandler* typeHandler() const; @@ -292,7 +354,7 @@ class SystemCatalog */ inline bool isWideDecimalType() const { - return (colDataType == DECIMAL || colDataType == UDECIMAL) && colWidth == MAXDECIMALWIDTH; + return (colDataType.kind() == DECIMAL || colDataType.kind() == UDECIMAL) && colWidth == MAXDECIMALWIDTH; } inline bool isWide() const @@ -357,7 +419,7 @@ class SystemCatalog */ static inline bool isWideDecimalType(const datatypes::SystemCatalog::ColDataType& dt, const int32_t width) { - return width == MAXDECIMALWIDTH && (dt == SystemCatalog::DECIMAL || dt == SystemCatalog::UDECIMAL); + return width == MAXDECIMALWIDTH && (dt.kind() == SystemCatalog::DECIMAL || dt.kind() == SystemCatalog::UDECIMAL); } /** convenience function to determine if column type is a char @@ -365,14 +427,14 @@ static inline bool isWideDecimalType(const datatypes::SystemCatalog::ColDataType */ inline bool isCharType(const datatypes::SystemCatalog::ColDataType type) { - return (datatypes::SystemCatalog::VARCHAR == type || datatypes::SystemCatalog::CHAR == type || - datatypes::SystemCatalog::BLOB == type || datatypes::SystemCatalog::TEXT == type); + return (datatypes::SystemCatalog::VARCHAR == type.kind() || datatypes::SystemCatalog::CHAR == type.kind() || + datatypes::SystemCatalog::BLOB == type.kind() || datatypes::SystemCatalog::TEXT == type.kind()); } inline bool typeHasCollation(const datatypes::SystemCatalog::ColDataType type) { - return datatypes::SystemCatalog::VARCHAR == type || datatypes::SystemCatalog::CHAR == type || - datatypes::SystemCatalog::TEXT == type; + return datatypes::SystemCatalog::VARCHAR == type.kind() || datatypes::SystemCatalog::CHAR == type.kind() || + datatypes::SystemCatalog::TEXT == type.kind(); } /** convenience function to determine if column type is a @@ -380,7 +442,7 @@ inline bool typeHasCollation(const datatypes::SystemCatalog::ColDataType type) */ inline bool isNumeric(const datatypes::SystemCatalog::ColDataType type) { - switch (type) + switch (type.kind()) { case datatypes::SystemCatalog::TINYINT: case datatypes::SystemCatalog::SMALLINT: @@ -405,7 +467,7 @@ inline bool isNumeric(const datatypes::SystemCatalog::ColDataType type) inline bool isInteger(const datatypes::SystemCatalog::ColDataType type) { - switch (type) + switch (type.kind()) { case datatypes::SystemCatalog::TINYINT: case datatypes::SystemCatalog::SMALLINT: @@ -424,17 +486,17 @@ inline bool isInteger(const datatypes::SystemCatalog::ColDataType type) inline bool isLongDouble(const datatypes::SystemCatalog::ColDataType type) { - return type == datatypes::SystemCatalog::LONGDOUBLE; + return type.kind() == datatypes::SystemCatalog::LONGDOUBLE; } inline bool isDecimal(const datatypes::SystemCatalog::ColDataType type) { - return (type == datatypes::SystemCatalog::DECIMAL || type == datatypes::SystemCatalog::UDECIMAL); + return (type.kind() == datatypes::SystemCatalog::DECIMAL || type.kind() == datatypes::SystemCatalog::UDECIMAL); } inline bool isUnsignedInteger(const datatypes::SystemCatalog::ColDataType type) { - switch (type) + switch (type.kind()) { case datatypes::SystemCatalog::UTINYINT: case datatypes::SystemCatalog::USMALLINT: @@ -454,7 +516,7 @@ inline bool isUnsigned(const datatypes::SystemCatalog::ColDataType type) if (isUnsignedInteger(type)) return true; - switch (type) + switch (type.kind()) { case datatypes::SystemCatalog::CHAR: case datatypes::SystemCatalog::VARCHAR: @@ -467,7 +529,7 @@ inline bool isUnsigned(const datatypes::SystemCatalog::ColDataType type) inline bool isSignedInteger(const datatypes::SystemCatalog::ColDataType type) { - switch (type) + switch (type.kind()) { case datatypes::SystemCatalog::TINYINT: case datatypes::SystemCatalog::SMALLINT: @@ -495,7 +557,7 @@ inline bool differentSignednessInteger(const datatypes::SystemCatalog::ColDataTy inline void promoteSignedInteger(datatypes::SystemCatalog::TypeHolderStd& unionedType) { - switch (unionedType.colDataType) + switch (unionedType.colDataType.kind()) { case datatypes::SystemCatalog::TINYINT: case datatypes::SystemCatalog::UTINYINT: @@ -1204,6 +1266,122 @@ class TypeHandlerEnum : public TypeHandler } }; +class TypeHandlerSet : public TypeHandler +{ + const string& name() const override; + code_t code() const override + { + return SystemCatalog::SET; + } + size_t ColWriteBatch(WriteBatchField* /*field*/, const unsigned char* /*buf*/, bool /*nullVal*/, + ColBatchWriter& /*writer*/) const override + { + idbassert(0); // QQ + return 0; + } + int storeValueToField(rowgroup::Row& /*row*/, int /*pos*/, StoreField* /*f*/) const override + { + idbassert(0); // QQ + return 0; + } + std::string format(const SimpleValue& /*v*/, const SystemCatalog::TypeAttributesStd& /*attr*/) const override + { + return "0"; // QQ + } + std::string formatPartitionInfo(const SystemCatalog::TypeAttributesStd& /*attr*/, + const MinMaxInfo& /*i*/) const override + { + idbassert(0); + return "Error"; + } + + execplan::SimpleColumn* newSimpleColumn(const DatabaseQualifiedColumnName& /*name*/, + SystemCatalog::TypeHolderStd& /*ct*/, + const SimpleColumnParam& /*prm*/) const override + { + idbassert(0); + return nullptr; + } + SimpleValue toSimpleValue(const SessionParam& /*sp*/, const SystemCatalog::TypeAttributesStd& /*attr*/, + const char* /*str*/, round_style_t& /*rf*/) const override + { + idbassert(0); + return {}; + } + boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd& /*attr*/) const override + { + return {}; + } + boost::any convertFromString(const SystemCatalog::TypeAttributesStd& /*colType*/, + const ConvertFromStringParam& /*prm*/, const std::string& /*str*/, + bool& /*pushWarning*/) const override; + + const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd& /*attr*/) const override + { + idbassert(0); + return nullptr; + } +}; + +// QQ: perhaps not needed yet +class TypeHandlerJson : public TypeHandler +{ + const string& name() const override; + code_t code() const override + { + return SystemCatalog::JSON; + } + size_t ColWriteBatch(WriteBatchField* /*field*/, const unsigned char* /*buf*/, bool /*nullVal*/, + ColBatchWriter& /*writer*/) const override + { + idbassert(0); // QQ + return 0; + } + int storeValueToField(rowgroup::Row& /*row*/, int /*pos*/, StoreField* /*f*/) const override + { + idbassert(0); // QQ + return 0; + } + std::string format(const SimpleValue& /*v*/, const SystemCatalog::TypeAttributesStd& /*attr*/) const override + { + return "0"; // QQ + } + std::string formatPartitionInfo(const SystemCatalog::TypeAttributesStd& /*attr*/, + const MinMaxInfo& /*i*/) const override + { + idbassert(0); + return "Error"; + } + + execplan::SimpleColumn* newSimpleColumn(const DatabaseQualifiedColumnName& /*name*/, + SystemCatalog::TypeHolderStd& /*ct*/, + const SimpleColumnParam& /*prm*/) const override + { + idbassert(0); + return nullptr; + } + SimpleValue toSimpleValue(const SessionParam& /*sp*/, const SystemCatalog::TypeAttributesStd& /*attr*/, + const char* /*str*/, round_style_t& /*rf*/) const override + { + idbassert(0); + return {}; + } + boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd& /*attr*/) const override + { + return {}; + } + boost::any convertFromString(const SystemCatalog::TypeAttributesStd& /*colType*/, + const ConvertFromStringParam& /*prm*/, const std::string& /*str*/, + bool& /*pushWarning*/) const override; + + const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd& /*attr*/) const override + { + idbassert(0); + return nullptr; + } +}; + + class TypeHandlerInt : public TypeHandler { protected: diff --git a/dbcon/ddlpackageproc/altertableprocessor.cpp b/dbcon/ddlpackageproc/altertableprocessor.cpp index 9428c9946..02d6155cd 100644 --- a/dbcon/ddlpackageproc/altertableprocessor.cpp +++ b/dbcon/ddlpackageproc/altertableprocessor.cpp @@ -100,7 +100,7 @@ bool checkTextTypesLengthAreEqual(const CalpontSystemCatalog::ColType& colType, bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType& newType) { - switch (colType.colDataType) + switch (colType.colDataType.kind()) { case (CalpontSystemCatalog::BIT): if (newType.fType == DDL_BIT) @@ -109,7 +109,7 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType break; case (CalpontSystemCatalog::ENUM): - if (newType.fType == DDL_ENUM && colType.enumVals == newType.fEnumValues) + if (newType.fType == DDL_ENUM && *(colType.colDataType.values()) == newType.fEnumValues) return true; break; @@ -2198,7 +2198,7 @@ void AlterTableProcessor::tableComment(uint32_t sessionID, execplan::CalpontSyst bool validated = true; bool negative = false; - switch (type.colDataType) + switch (type.colDataType.kind()) { case CalpontSystemCatalog::BIGINT: if (static_cast(nextVal) > MAX_BIGINT) diff --git a/dbcon/ddlpackageproc/createtableprocessor.cpp b/dbcon/ddlpackageproc/createtableprocessor.cpp index 0b9f68f00..a8a29ca8b 100644 --- a/dbcon/ddlpackageproc/createtableprocessor.cpp +++ b/dbcon/ddlpackageproc/createtableprocessor.cpp @@ -259,7 +259,7 @@ CreateTableProcessor::DDLResult CreateTableProcessor::processPackageInternal( for (unsigned i = 0; i < numColumns; i++) { int dataType; - dataType = convertDataType(tableDef.fColumns[i]->fType->fType); + dataType = convertDataType(tableDef.fColumns[i]->fType->fType).kind(); if ((dataType == CalpontSystemCatalog::CHAR && tableDef.fColumns[i]->fType->fLength > 8) || (dataType == CalpontSystemCatalog::VARCHAR && tableDef.fColumns[i]->fType->fLength > 7) || @@ -593,7 +593,7 @@ CreateTableProcessor::DDLResult CreateTableProcessor::processPackageInternal( } bytestream << (fStartingColOID + (colNum++) + 1); - bytestream << (uint8_t)dataType; + bytestream << dataType; bytestream << (uint8_t) false; bytestream << (uint32_t)colDefPtr->fType->fLength; @@ -607,7 +607,7 @@ CreateTableProcessor::DDLResult CreateTableProcessor::processPackageInternal( (dataType == CalpontSystemCatalog::TEXT && colDefPtr->fType->fLength > 7)) { bytestream << (uint32_t)(fStartingColOID + numColumns + (dictNum++) + 1); - bytestream << (uint8_t)dataType; + bytestream << dataType; bytestream << (uint8_t) true; bytestream << (uint32_t)colDefPtr->fType->fLength; bytestream << (uint16_t)useDBRoot; @@ -618,7 +618,7 @@ CreateTableProcessor::DDLResult CreateTableProcessor::processPackageInternal( } bytestream << (fStartingColOID + numColumnOids); - bytestream << (uint8_t)execplan::AUX_COL_DATATYPE; + bytestream << (uint8_t)execplan::AUX_COL_DATATYPE.kind(); bytestream << (uint8_t) false; bytestream << (uint32_t)execplan::AUX_COL_WIDTH; bytestream << (uint16_t)useDBRoot; diff --git a/dbcon/ddlpackageproc/ddlindexpopulator.cpp b/dbcon/ddlpackageproc/ddlindexpopulator.cpp index 1bc3c210f..be8908050 100644 --- a/dbcon/ddlpackageproc/ddlindexpopulator.cpp +++ b/dbcon/ddlpackageproc/ddlindexpopulator.cpp @@ -311,7 +311,7 @@ boost::any DDLIndexPopulator::convertData(const CalpontSystemCatalog::ColType& c { uint64_t data = cr->GetData(idx); - switch (colType.colDataType) + switch (colType.colDataType.kind()) { case CalpontSystemCatalog::BIT: case CalpontSystemCatalog::ENUM: return colType.fEnumValues[data]; @@ -457,7 +457,7 @@ bool DDLIndexPopulator::checkNotNull(const IdxTuple& data, const CalpontSystemCa any nullvalue = DDLNullValueForType(colType); bool isNull = false; - switch (colType.colDataType) + switch (colType.colDataType.kind()) { case CalpontSystemCatalog::BIT: break; diff --git a/dbcon/ddlpackageproc/ddlpackageprocessor.cpp b/dbcon/ddlpackageproc/ddlpackageprocessor.cpp index 011dacf87..cb8f64776 100644 --- a/dbcon/ddlpackageproc/ddlpackageprocessor.cpp +++ b/dbcon/ddlpackageproc/ddlpackageprocessor.cpp @@ -589,7 +589,7 @@ void DDLPackageProcessor::createFiles(CalpontSystemCatalog::TableName aTableName { colType = systemCatalogPtr->colType(ridList[col].objnum); bytestream << (uint32_t)ridList[col].objnum; - bytestream << (uint8_t)colType.colDataType; + bytestream << colType.colDataType; bytestream << (uint8_t) false; bytestream << (uint32_t)colType.colWidth; bytestream << (uint16_t)useDBRoot; @@ -598,7 +598,7 @@ void DDLPackageProcessor::createFiles(CalpontSystemCatalog::TableName aTableName if (colType.ddn.dictOID > 3000) { bytestream << (uint32_t)colType.ddn.dictOID; - bytestream << (uint8_t)colType.colDataType; + bytestream << colType.colDataType; bytestream << (uint8_t) true; bytestream << (uint32_t)colType.colWidth; bytestream << (uint16_t)useDBRoot; diff --git a/dbcon/execplan/aggregatecolumn.cpp b/dbcon/execplan/aggregatecolumn.cpp index 2317459ca..5511ace0c 100644 --- a/dbcon/execplan/aggregatecolumn.cpp +++ b/dbcon/execplan/aggregatecolumn.cpp @@ -339,7 +339,7 @@ bool AggregateColumn::hasAggregate() void AggregateColumn::evaluate(Row& row, bool& isNull) { - switch (fResultType.colDataType) + switch (fResultType.colDataType.kind()) { case CalpontSystemCatalog::DATE: if (row.equals<4>(DATENULL, fInputIndex)) diff --git a/dbcon/execplan/calpontsystemcatalog.cpp b/dbcon/execplan/calpontsystemcatalog.cpp index ed7a6fa33..aba49226c 100644 --- a/dbcon/execplan/calpontsystemcatalog.cpp +++ b/dbcon/execplan/calpontsystemcatalog.cpp @@ -689,7 +689,7 @@ CalpontSystemCatalog::OID CalpontSystemCatalog::lookupOID(const TableColName& ta if ((*it)->ColumnOID() == oid[0]) ct.colWidth = ((*it)->GetData(0)); else if ((*it)->ColumnOID() == oid[2]) - ct.colDataType = (ColDataType)((*it)->GetData(0)); + ct.colDataType = (Kind)((*it)->GetData(0)); else if ((*it)->ColumnOID() == oid[3]) ct.ddn.dictOID = ((*it)->GetData(0)); else if ((*it)->ColumnOID() == oid[4]) @@ -1210,7 +1210,7 @@ const CalpontSystemCatalog::ColType CalpontSystemCatalog::colType(const OID& Oid rid = (*it)->GetRid(0); } else if ((*it)->ColumnOID() == oid[2]) - ct.colDataType = (ColDataType)((*it)->GetData(0)); + ct.colDataType = (Kind)((*it)->GetData(0)); else if ((*it)->ColumnOID() == oid[3]) ct.ddn.dictOID = ((*it)->GetData(0)); else if ((*it)->ColumnOID() == oid[4]) @@ -3266,7 +3266,7 @@ const CalpontSystemCatalog::RIDList CalpontSystemCatalog::columnRIDs(const Table else if ((*it)->ColumnOID() == oid[2]) { for (int i = 0; i < (*it)->dataCount(); i++) - ctList[i].colDataType = (ColDataType)((*it)->GetData(i)); + ctList[i].colDataType = (Kind)((*it)->GetData(i)); } else if ((*it)->ColumnOID() == oid[3]) { @@ -5770,7 +5770,7 @@ void CalpontSystemCatalog::getSchemaInfo(const string& in_schema, int lower_case else if ((*it)->ColumnOID() == oid[2]) { for (int i = 0; i < (*it)->dataCount(); i++) - ctList[i].colDataType = (ColDataType)((*it)->GetData(i)); + ctList[i].colDataType = (Kind)((*it)->GetData(i)); } else if ((*it)->ColumnOID() == oid[3]) { diff --git a/dbcon/execplan/calpontsystemcatalog.h b/dbcon/execplan/calpontsystemcatalog.h index 8da301aa2..47dd05ea7 100644 --- a/dbcon/execplan/calpontsystemcatalog.h +++ b/dbcon/execplan/calpontsystemcatalog.h @@ -278,7 +278,18 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog // for F&E use. only serialize necessary info for now void serialize(messageqcpp::ByteStream& b) const { - b << (uint32_t)colDataType; + b << (uint8_t)colDataType.kind(); + b << (uint8_t)(colDataType.values().get()!=nullptr); + + if (colDataType.values()) { + const std::vector &v = *colDataType.values(); + b << (uint16_t)v.size(); + + for (size_t i = 0; i> (uint32_t&)val; - colDataType = (ColDataType)val; + uint8_t kind; + uint8_t nonempty; + std::shared_ptr> vals_ptr; + + b >> (uint8_t&)kind; + b >> (uint8_t&)nonempty; + + if (nonempty) { + uint16_t size; + + b >> (uint16_t&)size; + vals_ptr = std::shared_ptr>(new std::vector); + + std::vector &vals = *vals_ptr; + + for (size_t i = 0; i> val; + vals.push_back(val); + } + } + + colDataType.set((Kind)kind, vals_ptr); b >> (uint32_t&)colWidth; b >> (uint32_t&)scale; b >> (uint32_t&)precision; @@ -1024,7 +1056,7 @@ inline bool isNull(int64_t val, const execplan::CalpontSystemCatalog::ColType& c { bool ret = false; - switch (ct.colDataType) + switch (ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::TINYINT: { diff --git a/dbcon/execplan/simplecolumn.cpp b/dbcon/execplan/simplecolumn.cpp index b974b14f0..35d028f63 100644 --- a/dbcon/execplan/simplecolumn.cpp +++ b/dbcon/execplan/simplecolumn.cpp @@ -547,7 +547,7 @@ void SimpleColumn::evaluate(Row& row, bool& isNull) return; } - switch (fResultType.colDataType) + switch (fResultType.colDataType.kind()) { case CalpontSystemCatalog::DATE: { diff --git a/dbcon/execplan/treenode.h b/dbcon/execplan/treenode.h index c8da260a8..1755c6f2a 100644 --- a/dbcon/execplan/treenode.h +++ b/dbcon/execplan/treenode.h @@ -407,7 +407,7 @@ class TreeNode inline bool TreeNode::getBoolVal() { - switch (fResultType.colDataType) + switch (fResultType.colDataType.kind()) { case CalpontSystemCatalog::CHAR: if (fResultType.colWidth <= 8) @@ -472,15 +472,15 @@ inline bool TreeNode::getBoolVal() inline const utils::NullString& TreeNode::getStrVal(const long timeZone) { - switch (fResultType.colDataType) + switch (fResultType.colDataType.kind()) { case CalpontSystemCatalog::ENUM: - // Nedeljko TO DO if (fResult.uintVal==joblist::USMALLINTNULL) { - fResult.strVal.assign(fResultType.enumVals[fResult.uintVal]); - } else { fResult.strVal.dropString(); + } else { + const std::vector &vals = *(fResultType.colDataType.values()); + fResult.strVal.assign(vals[fResult.uintVal]); } break; @@ -693,7 +693,7 @@ inline const utils::NullString& TreeNode::getStrVal(const long timeZone) inline int64_t TreeNode::getIntVal() { - switch (fResultType.colDataType) + switch (fResultType.colDataType.kind()) { case CalpontSystemCatalog::CHAR: { @@ -754,7 +754,7 @@ inline int64_t TreeNode::getIntVal() } inline uint64_t TreeNode::getUintVal() { - switch (fResultType.colDataType) + switch (fResultType.colDataType.kind()) { case CalpontSystemCatalog::CHAR: case CalpontSystemCatalog::VARCHAR: @@ -806,7 +806,7 @@ inline uint64_t TreeNode::getUintVal() } inline float TreeNode::getFloatVal() { - switch (fResultType.colDataType) + switch (fResultType.colDataType.kind()) { case CalpontSystemCatalog::CHAR: if (fResultType.colWidth <= 8) @@ -877,7 +877,7 @@ inline float TreeNode::getFloatVal() } inline double TreeNode::getDoubleVal() { - switch (fResultType.colDataType) + switch (fResultType.colDataType.kind()) { case CalpontSystemCatalog::CHAR: if (fResultType.colWidth <= 8) @@ -948,7 +948,7 @@ inline double TreeNode::getDoubleVal() } inline long double TreeNode::getLongDoubleVal() { - switch (fResultType.colDataType) + switch (fResultType.colDataType.kind()) { case CalpontSystemCatalog::CHAR: if (fResultType.colWidth <= 8) @@ -1018,7 +1018,7 @@ inline long double TreeNode::getLongDoubleVal() } inline IDB_Decimal TreeNode::getDecimalVal() { - switch (fResultType.colDataType) + switch (fResultType.colDataType.kind()) { case CalpontSystemCatalog::CHAR: case CalpontSystemCatalog::VARCHAR: @@ -1113,9 +1113,9 @@ inline IDB_Decimal TreeNode::getDecimalVal() inline int64_t TreeNode::getDatetimeIntVal(long timeZone) { - if (fResultType.colDataType == execplan::CalpontSystemCatalog::DATE) + if (fResultType.colDataType.kind() == execplan::CalpontSystemCatalog::DATE) return (fResult.intVal & 0x00000000FFFFFFC0LL) << 32; - else if (fResultType.colDataType == execplan::CalpontSystemCatalog::TIME) + else if (fResultType.colDataType.kind() == execplan::CalpontSystemCatalog::TIME) { dataconvert::Time tt; int day = 0; @@ -1139,10 +1139,10 @@ inline int64_t TreeNode::getDatetimeIntVal(long timeZone) memcpy(&fResult.intVal, &dt, 8); return fResult.intVal; } - else if (fResultType.colDataType == execplan::CalpontSystemCatalog::DATETIME) + else if (fResultType.colDataType.kind() == execplan::CalpontSystemCatalog::DATETIME) // return (fResult.intVal & 0xFFFFFFFFFFF00000LL); return (fResult.intVal); - else if (fResultType.colDataType == execplan::CalpontSystemCatalog::TIMESTAMP) + else if (fResultType.colDataType.kind() == execplan::CalpontSystemCatalog::TIMESTAMP) { dataconvert::TimeStamp timestamp(fResult.intVal); int64_t seconds = timestamp.second; @@ -1159,7 +1159,7 @@ inline int64_t TreeNode::getDatetimeIntVal(long timeZone) inline int64_t TreeNode::getTimestampIntVal() { - if (fResultType.colDataType == execplan::CalpontSystemCatalog::TIMESTAMP) + if (fResultType.colDataType.kind() == execplan::CalpontSystemCatalog::TIMESTAMP) return fResult.intVal; else return getIntVal(); @@ -1167,7 +1167,7 @@ inline int64_t TreeNode::getTimestampIntVal() inline int64_t TreeNode::getTimeIntVal() { - if (fResultType.colDataType == execplan::CalpontSystemCatalog::DATETIME) + if (fResultType.colDataType.kind() == execplan::CalpontSystemCatalog::DATETIME) { dataconvert::DateTime dt; @@ -1176,7 +1176,7 @@ inline int64_t TreeNode::getTimeIntVal() memcpy(&fResult.intVal, &tt, 8); return fResult.intVal; } - else if (fResultType.colDataType == execplan::CalpontSystemCatalog::TIME) + else if (fResultType.colDataType.kind() == execplan::CalpontSystemCatalog::TIME) return (fResult.intVal); else return getIntVal(); @@ -1184,9 +1184,9 @@ inline int64_t TreeNode::getTimeIntVal() inline int32_t TreeNode::getDateIntVal() { - if (fResultType.colDataType == execplan::CalpontSystemCatalog::DATETIME) + if (fResultType.colDataType.kind() == execplan::CalpontSystemCatalog::DATETIME) return (((int32_t)(fResult.intVal >> 32) & 0xFFFFFFC0) | 0x3E); - else if (fResultType.colDataType == execplan::CalpontSystemCatalog::DATE) + else if (fResultType.colDataType.kind() == execplan::CalpontSystemCatalog::DATE) return ((fResult.intVal & 0xFFFFFFC0) | 0x3E); else return getIntVal(); diff --git a/dbcon/execplan/windowfunctioncolumn.cpp b/dbcon/execplan/windowfunctioncolumn.cpp index b10bee0ec..f01c7926f 100644 --- a/dbcon/execplan/windowfunctioncolumn.cpp +++ b/dbcon/execplan/windowfunctioncolumn.cpp @@ -444,7 +444,7 @@ void WindowFunctionColumn::adjustResultType() void WindowFunctionColumn::evaluate(Row& row, bool& isNull) { - switch (fResultType.colDataType) + switch (fResultType.colDataType.kind()) { case CalpontSystemCatalog::DATE: { diff --git a/dbcon/joblist/batchprimitiveprocessor-jl.cpp b/dbcon/joblist/batchprimitiveprocessor-jl.cpp index 64ed49a31..7d4fbb174 100644 --- a/dbcon/joblist/batchprimitiveprocessor-jl.cpp +++ b/dbcon/joblist/batchprimitiveprocessor-jl.cpp @@ -830,7 +830,7 @@ void BatchPrimitiveProcessorJL::getRowGroupData(ByteStream& in, vector* { std::ostringstream oss; oss << __func__ << " WARNING!!! Not implemented for the data type "; - oss << colType.colDataType << std::endl; + oss << colType.colDataType.kind() << std::endl; std::cout << oss.str(); idbassert(false); } @@ -1561,7 +1561,7 @@ bool BatchPrimitiveProcessorJL::nextTupleJoinerMsg(ByteStream& bs) // Small side is a long double. Since CS can't store larger than DOUBLE, // we need to convert to whatever type large side is -- double or int64 long double smallkeyld = r.getLongDoubleField(smallKeyCol); - switch (largeSideRG.getColType(tJoiners[joinerNum]->getLargeKeyColumns()[0])) + switch (largeSideRG.getColType(tJoiners[joinerNum]->getLargeKeyColumns()[0]).kind()) { case CalpontSystemCatalog::DOUBLE: case CalpontSystemCatalog::UDOUBLE: diff --git a/dbcon/joblist/crossenginestep.cpp b/dbcon/joblist/crossenginestep.cpp index 05c9a9d6a..5d928a442 100644 --- a/dbcon/joblist/crossenginestep.cpp +++ b/dbcon/joblist/crossenginestep.cpp @@ -234,7 +234,7 @@ T CrossEngineStep::convertValueNum(const char* str, const CalpontSystemCatalog:: anyVal = ct.getNullValueForType(); } - switch (ct.colDataType) + switch (ct.colDataType.kind()) { case CalpontSystemCatalog::BIT: rv = boost::any_cast(anyVal); break; diff --git a/dbcon/joblist/jlf_common.cpp b/dbcon/joblist/jlf_common.cpp index cd055eb0a..ffcdc5a8f 100644 --- a/dbcon/joblist/jlf_common.cpp +++ b/dbcon/joblist/jlf_common.cpp @@ -334,7 +334,7 @@ CalpontSystemCatalog::OID isDictCol(const CalpontSystemCatalog::ColType& colType //------------------------------------------------------------------------------ bool isCharCol(const CalpontSystemCatalog::ColType& colType) { - switch (colType.colDataType) + switch (colType.colDataType.kind()) { case CalpontSystemCatalog::VARCHAR: case CalpontSystemCatalog::CHAR: diff --git a/dbcon/joblist/jlf_execplantojoblist.cpp b/dbcon/joblist/jlf_execplantojoblist.cpp index e79c843a8..1b9af5012 100644 --- a/dbcon/joblist/jlf_execplantojoblist.cpp +++ b/dbcon/joblist/jlf_execplantojoblist.cpp @@ -138,7 +138,7 @@ void valueNullNum(const CalpontSystemCatalog::ColType& ct, const long timeZone, bool pushWarning = false; boost::any anyVal = ct.convertColumnData("", pushWarning, timeZone, true, false, false); - switch (ct.colDataType) + switch (ct.colDataType.kind()) { case CalpontSystemCatalog::BIT: // n = boost::any_cast(anyVal); @@ -288,7 +288,7 @@ void convertValueNum(const string& str, const CalpontSystemCatalog::ColType& ct, bool pushWarning = false; boost::any anyVal = ct.convertColumnData(str, pushWarning, timeZone, false, true, false); - switch (ct.colDataType) + switch (ct.colDataType.kind()) { case CalpontSystemCatalog::BIT: v = boost::any_cast(anyVal); break; @@ -1723,7 +1723,7 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo) } catch (...) { - switch (ct.colDataType) + switch (ct.colDataType.kind()) { case CalpontSystemCatalog::ENUM: case CalpontSystemCatalog::TINYINT: diff --git a/dbcon/joblist/primitivemsg.h b/dbcon/joblist/primitivemsg.h index 0d3cdaccc..887086b7d 100644 --- a/dbcon/joblist/primitivemsg.h +++ b/dbcon/joblist/primitivemsg.h @@ -331,8 +331,8 @@ struct ColRequestHeaderDataType : public datatypes::Charset { int32_t CompType; uint16_t DataSize; - uint8_t DataType; // enum ColDataType defined in calpont system catalog header file - ColRequestHeaderDataType() : Charset(my_charset_bin), CompType(0), DataSize(0), DataType(0) + execplan::CalpontSystemCatalog::ColDataType DataType; // enum ColDataType defined in calpont system catalog header file + ColRequestHeaderDataType() : Charset(my_charset_bin), CompType(0), DataSize(0), DataType(datatypes::SystemCatalog::ColDataType(datatypes::SystemCatalog::Kind::UNDEFINED)) { } explicit ColRequestHeaderDataType(const execplan::CalpontSystemCatalog::ColType& rhs) diff --git a/dbcon/joblist/rowestimator.cpp b/dbcon/joblist/rowestimator.cpp index 59816d7bf..232ee0ddc 100644 --- a/dbcon/joblist/rowestimator.cpp +++ b/dbcon/joblist/rowestimator.cpp @@ -83,7 +83,7 @@ uint32_t RowEstimator::daysThroughMonth(uint32_t mth) // The values are adjusted so that one can be subtracted from another to find a range, compare, etc. uint64_t RowEstimator::adjustValue(const execplan::CalpontSystemCatalog::ColType& ct, const uint64_t& value) { - switch (ct.colDataType) + switch (ct.colDataType.kind()) { // Use day precision for dates. We'll use day relative to the year 0 without worrying about leap // years. This is for row count estimation and we are close enough for hand grenades. @@ -132,11 +132,11 @@ uint32_t RowEstimator::estimateDistinctValues(const execplan::CalpontSystemCatal // If no casual partitioning info available for extent. These rules were defined in the requirements. if (cpStatus != BRM::CP_VALID) { - switch (ct.colDataType) + switch (ct.colDataType.kind()) { case CalpontSystemCatalog::BIT: return 2; - case CalpontSystemCatalog::ENUM: return ct.enumVals.size(); + case CalpontSystemCatalog::ENUM: return ct.colDataType.values()->size(); // Return limit/2 for integers where limit is number of possible values. case CalpontSystemCatalog::TINYINT: return (1 << 8) / 2; diff --git a/dbcon/joblist/tdriver-agg.cpp b/dbcon/joblist/tdriver-agg.cpp index 94c62c85e..30883f44a 100644 --- a/dbcon/joblist/tdriver-agg.cpp +++ b/dbcon/joblist/tdriver-agg.cpp @@ -598,7 +598,7 @@ class AggDriver : public CppUnit::TestFixture boost::any anyVal = DataConvert::convertColumnData(ct, str, false); - switch (ct.colDataType) + switch (ct.colDataType.kind()) { case CalpontSystemCatalog::BIT: v = boost::any_cast(anyVal); break; diff --git a/primitives/linux-port/column.cpp b/primitives/linux-port/column.cpp index 8d2f8ae77..c4be79299 100644 --- a/primitives/linux-port/column.cpp +++ b/primitives/linux-port/column.cpp @@ -248,7 +248,7 @@ inline bool isMinMaxValid(const NewColRequestHeader* in) } else { - switch (in->colType.DataType) + switch (in->colType.DataType.kind()) { case CalpontSystemCatalog::CHAR: return (in->colType.DataSize < 9); @@ -1831,7 +1831,7 @@ namespace primitives // The routine used to dispatch CHAR|VARCHAR|TEXT|BLOB scan. inline bool isDictTokenScan(NewColRequestHeader* in) { - switch (in->colType.DataType) + switch (in->colType.DataType.kind()) { case CalpontSystemCatalog::CHAR: return (in->colType.DataSize > 8); diff --git a/primitives/linux-port/primitiveprocessor.h b/primitives/linux-port/primitiveprocessor.h index a07cf750a..f82b93ceb 100644 --- a/primitives/linux-port/primitiveprocessor.h +++ b/primitives/linux-port/primitiveprocessor.h @@ -614,7 +614,7 @@ boost::shared_ptr _parseColumnFilter( ret->prestored_rfs[argIndex] = args->rf; - auto colDataType = (execplan::CalpontSystemCatalog::ColDataType)colType; + auto colDataType = (execplan::CalpontSystemCatalog::Kind)colType; bool isFilterValueNull = false; if (datatypes::isUnsigned(colDataType)) diff --git a/tests/brm-em-standalone.cpp b/tests/brm-em-standalone.cpp index e560fe978..746fe4251 100644 --- a/tests/brm-em-standalone.cpp +++ b/tests/brm-em-standalone.cpp @@ -1039,8 +1039,8 @@ static void* EMRunner([[maybe_unused]] void* arg) colWidth = colWidthsAvailable[randNumber % colWidthsAvailable.size()]; partNum = randNumber % std::numeric_limits::max(); segmentNum = randNumber % std::numeric_limits::max(); - colDataType = (execplan::CalpontSystemCatalog::ColDataType)( - randNumber % (int)execplan::CalpontSystemCatalog::ColDataType::TIMESTAMP); + colDataType = (execplan::CalpontSystemCatalog::Kind)( + randNumber % (int)execplan::CalpontSystemCatalog::TIMESTAMP); #ifdef BRM_VERBOSE cerr << "next op is " << op << endl; #endif diff --git a/utils/common/nullvaluemanip.cpp b/utils/common/nullvaluemanip.cpp index ff5836d2d..1901434fc 100644 --- a/utils/common/nullvaluemanip.cpp +++ b/utils/common/nullvaluemanip.cpp @@ -26,7 +26,7 @@ namespace utils { uint64_t getNullValue(CalpontSystemCatalog::ColDataType t, uint32_t colWidth) { - switch (t) + switch (t.kind()) { case CalpontSystemCatalog::TINYINT: return joblist::TINYINTNULL; @@ -104,14 +104,14 @@ uint64_t getNullValue(CalpontSystemCatalog::ColDataType t, uint32_t colWidth) case CalpontSystemCatalog::VARBINARY: default: ostringstream os; - os << "getNullValue(): got bad column type (" << t << "). Width=" << colWidth << endl; + os << "getNullValue(): got bad column type (" << t.kind() << "). Width=" << colWidth << endl; throw logic_error(os.str()); } } int64_t getSignedNullValue(CalpontSystemCatalog::ColDataType t, uint32_t colWidth) { - switch (t) + switch(t.kind()) { case CalpontSystemCatalog::TINYINT: return (int64_t)((int8_t)joblist::TINYINTNULL); @@ -174,7 +174,7 @@ int64_t getSignedNullValue(CalpontSystemCatalog::ColDataType t, uint32_t colWidt default: ostringstream os; - os << "getSignedNullValue(): got bad column width (" << t << "). Width=" << colWidth << endl; + os << "getSignedNullValue(): got bad column width (" << t.kind() << "). Width=" << colWidth << endl; throw logic_error(os.str()); } @@ -195,7 +195,7 @@ int64_t getSignedNullValue(CalpontSystemCatalog::ColDataType t, uint32_t colWidt case CalpontSystemCatalog::VARBINARY: default: ostringstream os; - os << "getSignedNullValue(): got bad column type (" << t << "). Width=" << colWidth << endl; + os << "getSignedNullValue(): got bad column type (" << t.kind() << "). Width=" << colWidth << endl; throw logic_error(os.str()); } return 0; diff --git a/utils/dataconvert/dataconvert.cpp b/utils/dataconvert/dataconvert.cpp index 44f671447..98139fdaa 100644 --- a/utils/dataconvert/dataconvert.cpp +++ b/utils/dataconvert/dataconvert.cpp @@ -2920,7 +2920,7 @@ void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& u throw runtime_error("VARBINARY in UNION must be the same width."); } - switch (type.colDataType) + switch (type.colDataType.kind()) { case datatypes::SystemCatalog::TINYINT: case datatypes::SystemCatalog::SMALLINT: @@ -2935,7 +2935,7 @@ void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& u case datatypes::SystemCatalog::UBIGINT: case datatypes::SystemCatalog::UDECIMAL: { - switch (unionedType.colDataType) + switch (unionedType.colDataType.kind()) { case datatypes::SystemCatalog::TINYINT: case datatypes::SystemCatalog::SMALLINT: @@ -3054,7 +3054,7 @@ void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& u case datatypes::SystemCatalog::DATE: { - switch (unionedType.colDataType) + switch (unionedType.colDataType.kind()) { case datatypes::SystemCatalog::TINYINT: case datatypes::SystemCatalog::SMALLINT: @@ -3102,7 +3102,7 @@ void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& u case datatypes::SystemCatalog::DATETIME: { - switch (unionedType.colDataType) + switch (unionedType.colDataType.kind()) { case datatypes::SystemCatalog::TINYINT: case datatypes::SystemCatalog::SMALLINT: @@ -3154,7 +3154,7 @@ void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& u case datatypes::SystemCatalog::TIMESTAMP: { - switch (unionedType.colDataType) + switch (unionedType.colDataType.kind()) { case datatypes::SystemCatalog::TINYINT: case datatypes::SystemCatalog::SMALLINT: @@ -3208,7 +3208,7 @@ void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& u case datatypes::SystemCatalog::UFLOAT: case datatypes::SystemCatalog::UDOUBLE: { - switch (unionedType.colDataType) + switch (unionedType.colDataType.kind()) { case datatypes::SystemCatalog::DATE: unionedType.colDataType = datatypes::SystemCatalog::CHAR; @@ -3272,7 +3272,7 @@ void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& u case datatypes::SystemCatalog::LONGDOUBLE: { - switch (unionedType.colDataType) + switch (unionedType.colDataType.kind()) { case datatypes::SystemCatalog::DATE: unionedType.colDataType = datatypes::SystemCatalog::CHAR; @@ -3339,7 +3339,7 @@ void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& u case datatypes::SystemCatalog::CHAR: case datatypes::SystemCatalog::VARCHAR: { - switch (unionedType.colDataType) + switch (unionedType.colDataType.kind()) { case datatypes::SystemCatalog::TINYINT: case datatypes::SystemCatalog::SMALLINT: diff --git a/utils/dataconvert/dataconvert.h b/utils/dataconvert/dataconvert.h index 136b6df0b..a2cd0cf67 100644 --- a/utils/dataconvert/dataconvert.h +++ b/utils/dataconvert/dataconvert.h @@ -75,7 +75,7 @@ inline uint64_t uint64ToStr(uint64_t n) return htonll(n); } -using cscDataType = datatypes::SystemCatalog::ColDataType; +using cscDataType = datatypes::SystemCatalog::Kind; #define EXPORT diff --git a/utils/funcexp/func_between.cpp b/utils/funcexp/func_between.cpp index 4d859d73e..e5af3ba6b 100644 --- a/utils/funcexp/func_between.cpp +++ b/utils/funcexp/func_between.cpp @@ -67,7 +67,7 @@ inline bool strLE(CHARSET_INFO& cs, const string& op1, const string& op2) inline bool getBool(rowgroup::Row& row, funcexp::FunctionParm& pm, bool& isNull, CalpontSystemCatalog::ColType& ct, bool notBetween) { - switch (ct.colDataType) + switch (ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::INT: diff --git a/utils/funcexp/func_ceil.cpp b/utils/funcexp/func_ceil.cpp index 4db3fe55e..ad482883b 100644 --- a/utils/funcexp/func_ceil.cpp +++ b/utils/funcexp/func_ceil.cpp @@ -73,7 +73,7 @@ int64_t Func_ceil::getIntVal(Row& row, FunctionParm& parm, bool& isNull, Calpont { int64_t ret = 0; - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { case CalpontSystemCatalog::BIGINT: case CalpontSystemCatalog::INT: @@ -198,7 +198,7 @@ uint64_t Func_ceil::getUintVal(Row& row, FunctionParm& parm, bool& isNull, { uint64_t ret = 0; - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { case CalpontSystemCatalog::BIGINT: case CalpontSystemCatalog::INT: @@ -498,7 +498,7 @@ IDB_Decimal Func_ceil::getDecimalVal(Row& row, FunctionParm& parm, bool& isNull, // and call an appropriate ctor IDB_Decimal ret; - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::INT: diff --git a/utils/funcexp/func_floor.cpp b/utils/funcexp/func_floor.cpp index ab916be36..171126fb5 100644 --- a/utils/funcexp/func_floor.cpp +++ b/utils/funcexp/func_floor.cpp @@ -51,7 +51,7 @@ int64_t Func_floor::getIntVal(Row& row, FunctionParm& parm, bool& isNull, { int64_t ret = 0; - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::INT: @@ -154,7 +154,7 @@ uint64_t Func_floor::getUintVal(Row& row, FunctionParm& parm, bool& isNull, { int64_t ret = 0; - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::INT: @@ -425,7 +425,7 @@ IDB_Decimal Func_floor::getDecimalVal(Row& row, FunctionParm& parm, bool& isNull { IDB_Decimal ret; - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::INT: diff --git a/utils/funcexp/func_in.cpp b/utils/funcexp/func_in.cpp index 7e1816049..c43cbeb64 100644 --- a/utils/funcexp/func_in.cpp +++ b/utils/funcexp/func_in.cpp @@ -56,7 +56,7 @@ inline bool getBoolForIn(rowgroup::Row& row, funcexp::FunctionParm& pm, bool& is { IDB_Decimal d; // to be removed; - switch (ct.colDataType) + switch (ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::INT: diff --git a/utils/funcexp/func_isnull.cpp b/utils/funcexp/func_isnull.cpp index 3c1216eae..ba7eff470 100644 --- a/utils/funcexp/func_isnull.cpp +++ b/utils/funcexp/func_isnull.cpp @@ -52,7 +52,7 @@ CalpontSystemCatalog::ColType Func_isnull::operationType(FunctionParm& fp, */ bool Func_isnull::getBoolVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType& op_ct) { - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { // For the purpose of this function, one does not need to get the value of // the argument. One only need to know if the argument is NULL. The passed diff --git a/utils/funcexp/func_round.cpp b/utils/funcexp/func_round.cpp index 8285af5b1..a3010812e 100644 --- a/utils/funcexp/func_round.cpp +++ b/utils/funcexp/func_round.cpp @@ -80,7 +80,7 @@ CalpontSystemCatalog::ColType Func_round::operationType(FunctionParm& fp, { CalpontSystemCatalog::ColType ct = fp[0]->data()->resultType(); - switch (ct.colDataType) + switch (ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::INT: @@ -313,7 +313,7 @@ IDB_Decimal Func_round::getDecimalVal(Row& row, FunctionParm& parm, bool& isNull { IDB_Decimal decimal; - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::INT: @@ -694,7 +694,7 @@ string Func_round::getStrVal(Row& row, FunctionParm& parm, bool& isNull, Calpont while (e-- > 0) p *= 10; - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::INT: diff --git a/utils/funcexp/func_truncate.cpp b/utils/funcexp/func_truncate.cpp index b83596506..01cb7f748 100644 --- a/utils/funcexp/func_truncate.cpp +++ b/utils/funcexp/func_truncate.cpp @@ -75,7 +75,7 @@ CalpontSystemCatalog::ColType Func_truncate::operationType(FunctionParm& fp, { CalpontSystemCatalog::ColType ct = fp[0]->data()->resultType(); - switch (ct.colDataType) + switch (ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::INT: @@ -171,7 +171,7 @@ uint64_t Func_truncate::getUintVal(Row& row, FunctionParm& parm, bool& isNull, double Func_truncate::getDoubleVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType& op_ct) { - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::DOUBLE: case execplan::CalpontSystemCatalog::FLOAT: @@ -296,7 +296,7 @@ IDB_Decimal Func_truncate::getDecimalVal(Row& row, FunctionParm& parm, bool& isN { IDB_Decimal decimal; - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::INT: @@ -612,7 +612,7 @@ string Func_truncate::getStrVal(Row& row, FunctionParm& parm, bool& isNull, { IDB_Decimal x = getDecimalVal(row, parm, isNull, op_ct); - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::INT: diff --git a/utils/joiner/tuplejoiner.cpp b/utils/joiner/tuplejoiner.cpp index 7d3b59114..f3afbb092 100644 --- a/utils/joiner/tuplejoiner.cpp +++ b/utils/joiner/tuplejoiner.cpp @@ -773,7 +773,7 @@ void TupleJoiner::doneInserting() if (isLongDouble(smallSideColType)) { double dval = (double)roundl(smallRow.getLongDoubleField(smallSideColIdx)); - switch (largeRG.getColType(largeKeyColumns[col])) + switch (largeRG.getColType(largeKeyColumns[col]).kind()) { case CalpontSystemCatalog::DOUBLE: case CalpontSystemCatalog::UDOUBLE: @@ -1120,7 +1120,7 @@ void TupleJoiner::updateCPData(const Row& r) if (r.getColType(colIdx) == CalpontSystemCatalog::LONGDOUBLE) { double dval = (double)roundl(r.getLongDoubleField(smallKeyColumns[col])); - switch (largeRG.getColType(largeKeyColumns[col])) + switch (largeRG.getColType(largeKeyColumns[col]).kind()) { case CalpontSystemCatalog::DOUBLE: case CalpontSystemCatalog::UDOUBLE: @@ -1158,7 +1158,7 @@ void TupleJoiner::updateCPData(const Row& r) if (r.getColType(colIdx) == CalpontSystemCatalog::LONGDOUBLE) { double dval = (double)roundl(r.getLongDoubleField(colIdx)); - switch (largeRG.getColType(largeKeyColumns[col])) + switch (largeRG.getColType(largeKeyColumns[col]).kind()) { case CalpontSystemCatalog::DOUBLE: case CalpontSystemCatalog::UDOUBLE: @@ -1356,7 +1356,7 @@ uint32 TypelessData::hash(const RowGroup& r, const std::vector& keyCol datatypes::MariaDBHasher hasher; for (auto keyColId : keyCols) { - switch (r.getColTypes()[keyColId]) + switch (r.getColTypes()[keyColId].kind()) { case CalpontSystemCatalog::VARCHAR: case CalpontSystemCatalog::CHAR: @@ -1398,7 +1398,7 @@ int TypelessData::cmpToRow(const RowGroup& r, const std::vector& keyCo for (uint32_t i = 0; i < keyCols.size(); i++) { auto largeSideKeyColRowIdx = keyCols[i]; - switch (r.getColType(largeSideKeyColRowIdx)) + switch (r.getColType(largeSideKeyColRowIdx).kind()) { case CalpontSystemCatalog::VARCHAR: case CalpontSystemCatalog::CHAR: @@ -1492,7 +1492,7 @@ int TypelessData::cmp(const RowGroup& r, const std::vector& keyCols, c for (uint32_t i = 0; i < keyCols.size(); ++i) { auto keyColIdx = keyCols[i]; - switch (r.getColTypes()[keyColIdx]) + switch (r.getColTypes()[keyColIdx].kind()) { case CalpontSystemCatalog::VARCHAR: case CalpontSystemCatalog::CHAR: @@ -1563,7 +1563,7 @@ TypelessData makeTypelessKey(const Row& r, const vector& keyCols, uint { bool otherSideIsIntOrNarrow = otherSideRG.getColumnWidth(otherKeyCols[i]) <= datatypes::MAXLEGACYWIDTH; // useless if otherSideIsInt is false - auto otherSideType = (otherSideIsIntOrNarrow) ? otherSideRG.getColType(otherKeyCols[i]) + auto otherSideType = (otherSideIsIntOrNarrow) ? otherSideRG.getColType(otherKeyCols[i]).kind() : datatypes::SystemCatalog::UNDEFINED; if (WideDecimalKeyConverter(r, keyCols[i]) .convert(otherSideIsIntOrNarrow, otherSideType) @@ -1579,7 +1579,7 @@ TypelessData makeTypelessKey(const Row& r, const vector& keyCols, uint // Small side is a long double. Since CS can't store larger than DOUBLE, // we need to convert to whatever type large side is -- double or int64 long double keyld = r.getLongDoubleField(keyCols[i]); - switch (otherSideRG.getColType(otherKeyCols[i])) + switch (otherSideRG.getColType(otherKeyCols[i]).kind()) { case CalpontSystemCatalog::DOUBLE: case CalpontSystemCatalog::UDOUBLE: @@ -1921,7 +1921,7 @@ uint32_t calculateKeyLength(const std::vector& aKeyColumnsIds, : std::numeric_limits::max(); const auto& smallKeyColumnType = aSmallRowGroup.getColTypes()[smallSideKeyColumnId]; // Not used if aLargeRowGroup is 0 that happens in PrimProc. - const auto& largeKeyColumntype = (aLargeRowGroup) ? aLargeRowGroup->getColTypes()[largeSideKeyColumnId] + const auto& largeKeyColumntype = (aLargeRowGroup) ? aLargeRowGroup->getColTypes()[largeSideKeyColumnId].kind() : datatypes::SystemCatalog::UNDEFINED; if (datatypes::isCharType(smallKeyColumnType)) { diff --git a/utils/messageqcpp/bytestream.h b/utils/messageqcpp/bytestream.h index ccc359d8e..606fefe2a 100644 --- a/utils/messageqcpp/bytestream.h +++ b/utils/messageqcpp/bytestream.h @@ -34,6 +34,7 @@ #include #include "mcs_basic_types.h" +#include "mcs_datatype.h" #include "exceptclasses.h" #include "serializeable.h" #include "any.hpp" @@ -168,6 +169,37 @@ class ByteStream : public Serializeable * push a NullString onto the end of the stream. */ EXPORT ByteStream& operator<<(const utils::NullString& s); + + /** + * push a bool + */ + inline ByteStream& operator<<(bool b) + { + *this << (uint8_t)b; + + return *this; + } + + /** + * push a ColDataType + */ + ByteStream& operator<<(const datatypes::SystemCatalog::ColDataType& c) + { + *this << (uint16_t)c.kind(); + *this << (uint8_t)(bool)c.values(); + + if (c.values()) { + const std::vector &vals = *(c.values()); + + *this << (uint16_t) vals.size(); + + for (size_t i = 0; i < vals.size(); ++i) { + *this << vals[i]; + } + } + + return *this; + } /** * push an arbitrary class onto the end of the stream. */ @@ -251,6 +283,44 @@ class ByteStream : public Serializeable * calling length()). */ EXPORT ByteStream& operator>>(uint8_t*& b); + + ByteStream& operator>>(datatypes::SystemCatalog::ColDataType &c) + { + uint8_t kind; + uint8_t nonempty; + std::shared_ptr> values; + + *this >> kind >> nonempty; + + if (nonempty) { + values = std::shared_ptr>(new std::vector); + std::vector &vals = *values; + uint16_t size; + + *this >> size; + + for (size_t i = 0; i > val; + vals.push_back(val); + } + } + + c.set((datatypes::SystemCatalog::Kind) kind, values); + + return *this; + } + + /** + * extract bool. + */ + inline ByteStream& operator>>(bool &b) + { + *this >> (uint8_t&)b; + + return *this; + } /** * extract an arbitrary object from the front of the stream. */ diff --git a/utils/querytele/queryteleprotoimpl.cpp b/utils/querytele/queryteleprotoimpl.cpp index d5b5e9e7e..a3ac47fd0 100644 --- a/utils/querytele/queryteleprotoimpl.cpp +++ b/utils/querytele/queryteleprotoimpl.cpp @@ -126,7 +126,7 @@ void log_query(const querytele::QueryTele& qtdata) #ifdef QUERY_TELE_DEBUG const string st2str(enum querytele::StepType::type t) { - switch (t) + switch(t.kind()) { case querytele::StepType::T_HJS: return "HJS"; diff --git a/utils/querytele/serverdriver.cpp b/utils/querytele/serverdriver.cpp index bbbbd49c4..f1a89de23 100644 --- a/utils/querytele/serverdriver.cpp +++ b/utils/querytele/serverdriver.cpp @@ -54,7 +54,7 @@ class QueryTeleServiceHandler : public QueryTeleServiceIf const string st2str(enum StepType::type t) { - switch (t) + switch(t.kind()) { case StepType::T_HJS: return "HJS"; diff --git a/utils/regr/moda.cpp b/utils/regr/moda.cpp index d239371ec..0ccd36adf 100644 --- a/utils/regr/moda.cpp +++ b/utils/regr/moda.cpp @@ -76,7 +76,7 @@ mcsv1_UDAF* moda::getImpl(mcsv1Context* context) if (data->modaImpl) return data->modaImpl; - switch (context->getResultType()) + switch (context->getResultType().kind()) { case execplan::CalpontSystemCatalog::TINYINT: data->modaImpl = &moda_impl_int8; break; case execplan::CalpontSystemCatalog::SMALLINT: data->modaImpl = &moda_impl_int16; break; @@ -131,8 +131,8 @@ mcsv1_UDAF::ReturnCode moda::init(mcsv1Context* context, ColumnDatum* colTypes) if (!(datatypes::isNumeric(colTypes[0].dataType))) { - if (colTypes[0].dataType != datatypes::SystemCatalog::VARCHAR && - colTypes[0].dataType != datatypes::SystemCatalog::CHAR) + if (colTypes[0].dataType.kind() != datatypes::SystemCatalog::VARCHAR && + colTypes[0].dataType.kind() != datatypes::SystemCatalog::CHAR) { // The error message will be prepended with // "The storage engine for the table doesn't support " @@ -141,7 +141,7 @@ mcsv1_UDAF::ReturnCode moda::init(mcsv1Context* context, ColumnDatum* colTypes) } } - if (colTypes[0].dataType == execplan::CalpontSystemCatalog::DECIMAL || + if (colTypes[0].dataType.kind() == execplan::CalpontSystemCatalog::DECIMAL || colTypes[0].dataType == execplan::CalpontSystemCatalog::UDECIMAL) { if (colTypes[0].precision < 3) @@ -188,8 +188,8 @@ mcsv1_UDAF::ReturnCode moda::init(mcsv1Context* context, ColumnDatum* colTypes) template mcsv1_UDAF::ReturnCode Moda_impl_T::init(mcsv1Context* context, ColumnDatum* colTypes) { - if (!(colTypes[0].dataType == execplan::CalpontSystemCatalog::DECIMAL || - colTypes[0].dataType == execplan::CalpontSystemCatalog::UDECIMAL)) + if (!(colTypes[0].dataType.kind() == execplan::CalpontSystemCatalog::DECIMAL || + colTypes[0].dataType.kind() == execplan::CalpontSystemCatalog::UDECIMAL)) { context->setColWidth(sizeof(T)); context->setScale(0); @@ -202,7 +202,7 @@ template mcsv1_UDAF::ReturnCode Moda_impl_T::reset(mcsv1Context* context) { ModaData* data = static_cast(context->getUserData()); - data->fReturnType = context->getResultType(); + data->fReturnType = context->getResultType().kind(); data->fColWidth = context->getColWidth(); data->clear(); return mcsv1_UDAF::SUCCESS; @@ -341,7 +341,7 @@ void ModaData::serialize(messageqcpp::ByteStream& bs) const bs << fCount; bs << fColWidth; - switch ((execplan::CalpontSystemCatalog::ColDataType)fReturnType) + switch ((execplan::CalpontSystemCatalog::Kind)fReturnType) { case execplan::CalpontSystemCatalog::TINYINT: serializeMap(bs); break; case execplan::CalpontSystemCatalog::SMALLINT: serializeMap(bs); break; @@ -381,7 +381,7 @@ void ModaData::unserialize(messageqcpp::ByteStream& bs) bs >> fCount; bs >> fColWidth; - switch ((execplan::CalpontSystemCatalog::ColDataType)fReturnType) + switch ((execplan::CalpontSystemCatalog::Kind)fReturnType) { case execplan::CalpontSystemCatalog::TINYINT: unserializeMap(bs); break; case execplan::CalpontSystemCatalog::SMALLINT: unserializeMap(bs); break; @@ -418,7 +418,7 @@ void ModaData::cleanup() { if (!fMap) return; - switch ((execplan::CalpontSystemCatalog::ColDataType)fReturnType) + switch ((execplan::CalpontSystemCatalog::Kind)fReturnType) { case execplan::CalpontSystemCatalog::TINYINT: clear(); @@ -514,7 +514,7 @@ mcsv1_UDAF::ReturnCode Moda_impl_T::init(mcsv1Context* context, ColumnDa mcsv1_UDAF::ReturnCode Moda_impl_T::reset(mcsv1Context* context) { ModaData* data = static_cast(context->getUserData()); - data->fReturnType = context->getResultType(); + data->fReturnType = context->getResultType().kind(); data->fColWidth = context->getColWidth(); data->fCs_num = context->getCharsetNumber(); data->clear(); diff --git a/utils/regr/regrmysql.cpp b/utils/regr/regrmysql.cpp index 39fed3146..acd41cba0 100644 --- a/utils/regr/regrmysql.cpp +++ b/utils/regr/regrmysql.cpp @@ -26,7 +26,7 @@ inline double cvtArgToDouble(int t, const char* v) { double d = 0.0; - switch (t) + switch(t) { case INT_RESULT: d = (double)(*((long long*)v)); break; diff --git a/utils/rowgroup/rowgroup.cpp b/utils/rowgroup/rowgroup.cpp index 2c1882245..9ef3ca939 100644 --- a/utils/rowgroup/rowgroup.cpp +++ b/utils/rowgroup/rowgroup.cpp @@ -1348,7 +1348,7 @@ void RowGroup::deserialize(ByteStream& bs) deserializeInlineVector(bs, colWidths); deserializeInlineVector(bs, oids); deserializeInlineVector(bs, keys); - deserializeInlineVector(bs, types); + deserializeVector(bs, types); deserializeInlineVector(bs, charsetNumbers); deserializeInlineVector(bs, scale); deserializeInlineVector(bs, precision); @@ -1557,9 +1557,9 @@ void applyMapping(const int* mapping, const Row& in, Row* out) for (i = 0; i < in.getColumnCount(); i++) if (mapping[i] != -1) { - if (UNLIKELY(in.getColTypes()[i] == execplan::CalpontSystemCatalog::VARBINARY || - in.getColTypes()[i] == execplan::CalpontSystemCatalog::BLOB || - in.getColTypes()[i] == execplan::CalpontSystemCatalog::TEXT)) + if (UNLIKELY(in.getColTypes()[i].kind() == execplan::CalpontSystemCatalog::VARBINARY || + in.getColTypes()[i].kind() == execplan::CalpontSystemCatalog::BLOB || + in.getColTypes()[i].kind() == execplan::CalpontSystemCatalog::TEXT)) { out->setVarBinaryField(in.getVarBinaryField(i), in.getVarBinaryLength(i), mapping[i]); } @@ -1569,7 +1569,7 @@ void applyMapping(const int* mapping, const Row& in, Row* out) } else if (UNLIKELY(in.isShortString(i))) out->setUintField(in.getUintField(i), mapping[i]); - else if (UNLIKELY(in.getColTypes()[i] == execplan::CalpontSystemCatalog::LONGDOUBLE)) + else if (UNLIKELY(in.getColTypes()[i].kind() == execplan::CalpontSystemCatalog::LONGDOUBLE)) out->setLongDoubleField(in.getLongDoubleField(i), mapping[i]); // WIP this doesn't look right b/c we can pushdown colType // Migrate to offset based methods here diff --git a/utils/rowgroup/rowgroup.h b/utils/rowgroup/rowgroup.h index 5917885b3..e507e0cd1 100644 --- a/utils/rowgroup/rowgroup.h +++ b/utils/rowgroup/rowgroup.h @@ -1002,7 +1002,7 @@ inline utils::ConstString Row::getConstString(uint32_t colIndex) const inline void Row::colUpdateHasher(datatypes::MariaDBHasher& hM, const utils::Hasher_r& h, const uint32_t col, uint32_t& intermediateHash) const { - switch (getColType(col)) + switch (getColType(col).kind()) { case execplan::CalpontSystemCatalog::CHAR: case execplan::CalpontSystemCatalog::VARCHAR: @@ -1029,7 +1029,7 @@ inline void Row::colUpdateHasherTypeless(datatypes::MariaDBHasher& h, uint32_t k { auto rowKeyColIdx = keyCols[keyColsIdx]; auto largeSideColType = getColType(rowKeyColIdx); - switch (largeSideColType) + switch (largeSideColType.kind()) { case datatypes::SystemCatalog::CHAR: case datatypes::SystemCatalog::VARCHAR: @@ -1462,10 +1462,10 @@ inline void Row::copyField(uint32_t destIndex, uint32_t srcIndex) const inline void Row::copyField(Row& out, uint32_t destIndex, uint32_t srcIndex) const { - if (UNLIKELY(types[srcIndex] == execplan::CalpontSystemCatalog::VARBINARY || - types[srcIndex] == execplan::CalpontSystemCatalog::BLOB || - types[srcIndex] == execplan::CalpontSystemCatalog::TEXT || - types[srcIndex] == execplan::CalpontSystemCatalog::CLOB)) + if (UNLIKELY(types[srcIndex].kind() == execplan::CalpontSystemCatalog::VARBINARY || + types[srcIndex].kind() == execplan::CalpontSystemCatalog::BLOB || + types[srcIndex].kind() == execplan::CalpontSystemCatalog::TEXT || + types[srcIndex].kind() == execplan::CalpontSystemCatalog::CLOB)) { out.setVarBinaryField(getVarBinaryField(srcIndex), getVarBinaryLength(srcIndex), destIndex); } @@ -1477,7 +1477,7 @@ inline void Row::copyField(Row& out, uint32_t destIndex, uint32_t srcIndex) cons { out.setUintField(getUintField(srcIndex), destIndex); } - else if (UNLIKELY(types[srcIndex] == execplan::CalpontSystemCatalog::LONGDOUBLE)) + else if (UNLIKELY(types[srcIndex].kind() == execplan::CalpontSystemCatalog::LONGDOUBLE)) { out.setLongDoubleField(getLongDoubleField(srcIndex), destIndex); } @@ -1934,18 +1934,18 @@ inline bool RowGroup::isUnsigned(uint32_t colIndex) const inline bool RowGroup::isShortString(uint32_t colIndex) const { - return ((getColumnWidth(colIndex) <= 7 && types[colIndex] == execplan::CalpontSystemCatalog::VARCHAR) || - (getColumnWidth(colIndex) <= 8 && types[colIndex] == execplan::CalpontSystemCatalog::CHAR)); + return ((getColumnWidth(colIndex) <= 7 && types[colIndex].kind() == execplan::CalpontSystemCatalog::VARCHAR) || + (getColumnWidth(colIndex) <= 8 && types[colIndex].kind() == execplan::CalpontSystemCatalog::CHAR)); } inline bool RowGroup::isLongString(uint32_t colIndex) const { - return ((getColumnWidth(colIndex) > 7 && types[colIndex] == execplan::CalpontSystemCatalog::VARCHAR) || - (getColumnWidth(colIndex) > 8 && types[colIndex] == execplan::CalpontSystemCatalog::CHAR) || - types[colIndex] == execplan::CalpontSystemCatalog::VARBINARY || - types[colIndex] == execplan::CalpontSystemCatalog::BLOB || - types[colIndex] == execplan::CalpontSystemCatalog::TEXT || - types[colIndex] == execplan::CalpontSystemCatalog::CLOB); + return ((getColumnWidth(colIndex) > 7 && types[colIndex].kind() == execplan::CalpontSystemCatalog::VARCHAR) || + (getColumnWidth(colIndex) > 8 && types[colIndex].kind() == execplan::CalpontSystemCatalog::CHAR) || + types[colIndex].kind() == execplan::CalpontSystemCatalog::VARBINARY || + types[colIndex].kind() == execplan::CalpontSystemCatalog::BLOB || + types[colIndex].kind() == execplan::CalpontSystemCatalog::TEXT || + types[colIndex].kind() == execplan::CalpontSystemCatalog::CLOB); } inline bool RowGroup::usesStringTable() const @@ -2125,10 +2125,10 @@ inline void copyRow(const Row& in, Row* out, uint32_t colCount) for (uint32_t i = 0; i < colCount; i++) { - if (UNLIKELY(in.getColTypes()[i] == execplan::CalpontSystemCatalog::VARBINARY || - in.getColTypes()[i] == execplan::CalpontSystemCatalog::BLOB || - in.getColTypes()[i] == execplan::CalpontSystemCatalog::TEXT || - in.getColTypes()[i] == execplan::CalpontSystemCatalog::CLOB)) + if (UNLIKELY(in.getColTypes()[i].kind() == execplan::CalpontSystemCatalog::VARBINARY || + in.getColTypes()[i].kind() == execplan::CalpontSystemCatalog::BLOB || + in.getColTypes()[i].kind() == execplan::CalpontSystemCatalog::TEXT || + in.getColTypes()[i].kind() == execplan::CalpontSystemCatalog::CLOB)) { out->setVarBinaryField(in.getVarBinaryField(i), in.getVarBinaryLength(i), i); } @@ -2140,11 +2140,11 @@ inline void copyRow(const Row& in, Row* out, uint32_t colCount) { out->setUintField(in.getUintField(i), i); } - else if (UNLIKELY(in.getColTypes()[i] == execplan::CalpontSystemCatalog::DOUBLE)) + else if (UNLIKELY(in.getColTypes()[i].kind() == execplan::CalpontSystemCatalog::DOUBLE)) { out->setDoubleField(in.getDoubleField(i), i); } - else if (UNLIKELY(in.getColTypes()[i] == execplan::CalpontSystemCatalog::LONGDOUBLE)) + else if (UNLIKELY(in.getColTypes()[i].kind() == execplan::CalpontSystemCatalog::LONGDOUBLE)) { out->setLongDoubleField(in.getLongDoubleField(i), i); } diff --git a/utils/udfsdk/mcsv1_udaf.cpp b/utils/udfsdk/mcsv1_udaf.cpp index f0b486e0e..587e19598 100644 --- a/utils/udfsdk/mcsv1_udaf.cpp +++ b/utils/udfsdk/mcsv1_udaf.cpp @@ -74,7 +74,7 @@ int32_t mcsv1Context::getColWidth() } // JIT initialization for types that have a defined size. - switch (fResultType) + switch (fResultType.kind()) { case execplan::CalpontSystemCatalog::BIT: case execplan::CalpontSystemCatalog::TINYINT: @@ -116,7 +116,7 @@ bool mcsv1Context::operator==(const mcsv1Context& c) const // We don't test the per row data fields. They don't determine // if it's the same Context. if (getName() != c.getName() || fRunFlags != c.fRunFlags || fContextFlags != c.fContextFlags || - fUserDataSize != c.fUserDataSize || fResultType != c.fResultType || fResultscale != c.fResultscale || + fUserDataSize != c.fUserDataSize || !(fResultType == c.fResultType) || fResultscale != c.fResultscale || fResultPrecision != c.fResultPrecision || fStartFrame != c.fStartFrame || fEndFrame != c.fEndFrame || fStartConstant != c.fStartConstant || fEndConstant != c.fEndConstant || fParamCount != c.fParamCount) return false; @@ -201,7 +201,7 @@ void mcsv1Context::serialize(messageqcpp::ByteStream& b) const b << fRunFlags; // Dont send context flags, These are set for each call b << fUserDataSize; - b << (uint32_t)fResultType; + b << fResultType; b << fColWidth; b << fResultscale; b << fResultPrecision; @@ -222,9 +222,7 @@ void mcsv1Context::unserialize(messageqcpp::ByteStream& b) b >> functionName; b >> fRunFlags; b >> fUserDataSize; - uint32_t iResultType; - b >> iResultType; - fResultType = (execplan::CalpontSystemCatalog::ColDataType)iResultType; + b >> fResultType; b >> fColWidth; b >> fResultscale; b >> fResultPrecision; diff --git a/utils/udfsdk/udfmysql.cpp b/utils/udfsdk/udfmysql.cpp index add530688..255c597bf 100644 --- a/utils/udfsdk/udfmysql.cpp +++ b/utils/udfsdk/udfmysql.cpp @@ -12,7 +12,7 @@ inline double cvtArgToDouble(int t, const char* v) { double d = 0.0; - switch (t) + switch(t) { case INT_RESULT: d = (double)(*((long long*)v)); break; diff --git a/utils/udfsdk/udfsdk.cpp b/utils/udfsdk/udfsdk.cpp index dc23837d3..6d4c22d9d 100644 --- a/utils/udfsdk/udfsdk.cpp +++ b/utils/udfsdk/udfsdk.cpp @@ -88,30 +88,30 @@ CalpontSystemCatalog::ColType MCS_add::operationType(FunctionParm& fp, { rt = fp[0]->data()->resultType(); } - else if (fp[0]->data()->resultType().colDataType == CalpontSystemCatalog::CHAR || - fp[1]->data()->resultType().colDataType == CalpontSystemCatalog::CHAR || - fp[0]->data()->resultType().colDataType == CalpontSystemCatalog::VARCHAR || - fp[1]->data()->resultType().colDataType == CalpontSystemCatalog::VARCHAR || - fp[0]->data()->resultType().colDataType == CalpontSystemCatalog::DOUBLE || - fp[1]->data()->resultType().colDataType == CalpontSystemCatalog::DOUBLE) + else if (fp[0]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::CHAR || + fp[1]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::CHAR || + fp[0]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::VARCHAR || + fp[1]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::VARCHAR || + fp[0]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::DOUBLE || + fp[1]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::DOUBLE) { rt.colDataType = CalpontSystemCatalog::DOUBLE; rt.colWidth = 8; } - else if (fp[0]->data()->resultType().colDataType == CalpontSystemCatalog::DATE || - fp[1]->data()->resultType().colDataType == CalpontSystemCatalog::DATE || - fp[0]->data()->resultType().colDataType == CalpontSystemCatalog::DATETIME || - fp[1]->data()->resultType().colDataType == CalpontSystemCatalog::DATETIME || - fp[0]->data()->resultType().colDataType == CalpontSystemCatalog::TIME || - fp[1]->data()->resultType().colDataType == CalpontSystemCatalog::TIME) + else if (fp[0]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::DATE || + fp[1]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::DATE || + fp[0]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::DATETIME || + fp[1]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::DATETIME || + fp[0]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::TIME || + fp[1]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::TIME) { rt.colDataType = CalpontSystemCatalog::BIGINT; rt.colWidth = 8; } - else if (fp[0]->data()->resultType().colDataType == CalpontSystemCatalog::DECIMAL || - fp[0]->data()->resultType().colDataType == CalpontSystemCatalog::UDECIMAL || - fp[1]->data()->resultType().colDataType == CalpontSystemCatalog::DECIMAL || - fp[1]->data()->resultType().colDataType == CalpontSystemCatalog::UDECIMAL) + else if (fp[0]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::DECIMAL || + fp[0]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::UDECIMAL || + fp[1]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::DECIMAL || + fp[1]->data()->resultType().colDataType.kind() == CalpontSystemCatalog::UDECIMAL) { rt.colDataType = CalpontSystemCatalog::DECIMAL; rt.colWidth = 8; @@ -141,7 +141,7 @@ CalpontSystemCatalog::ColType MCS_add::operationType(FunctionParm& fp, */ double MCS_add::getDoubleVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType& op_ct) { - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { // The APIs for the evaluation of the function parameters are the same getXXXval() // functions. However, only two arguments are passed in, the current @@ -285,7 +285,7 @@ CalpontSystemCatalog::ColType MCS_isnull::operationType(FunctionParm& fp, */ bool MCS_isnull::getBoolVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType& op_ct) { - switch (op_ct.colDataType) + switch (op_ct.colDataType.kind()) { // For the purpose of this function, one does not need to get the value of // the argument. One only need to know if the argument is NULL. The passed diff --git a/utils/windowfunction/frameboundrange.cpp b/utils/windowfunction/frameboundrange.cpp index 25fd1542e..2f76ae427 100644 --- a/utils/windowfunction/frameboundrange.cpp +++ b/utils/windowfunction/frameboundrange.cpp @@ -262,7 +262,7 @@ void FrameBoundExpressionRange::validate() } else { - switch (this->fRow.getColType(this->fIndex[1])) + switch (this->fRow.getColType(this->fIndex[1]).kind()) { case execplan::CalpontSystemCatalog::TINYINT: case execplan::CalpontSystemCatalog::SMALLINT: diff --git a/utils/windowfunction/idborderby.cpp b/utils/windowfunction/idborderby.cpp index b1b9849a4..8cad3c4ad 100644 --- a/utils/windowfunction/idborderby.cpp +++ b/utils/windowfunction/idborderby.cpp @@ -557,7 +557,7 @@ void CompareRule::compileRules(const std::vector& spec, const rowgr for (auto spec_el : spec) { - switch (types[spec_el.fIndex]) + switch (types[spec_el.fIndex].kind()) { case CalpontSystemCatalog::TINYINT: { @@ -804,7 +804,7 @@ bool EqualCompData::operator()(Row::Pointer a, Row::Pointer b) { CalpontSystemCatalog::ColDataType type = fRow1.getColType(*i); - switch (type) + switch (type.kind()) { case CalpontSystemCatalog::TINYINT: case CalpontSystemCatalog::SMALLINT: @@ -874,8 +874,8 @@ bool EqualCompData::operator()(Row::Pointer a, Row::Pointer b) { eq = false; uint64_t ec = ERR_WF_UNKNOWN_COL_TYPE; - cerr << IDBErrorInfo::instance()->errorMsg(ec, type) << " @" << __FILE__ << ":" << __LINE__; - throw IDBExcept(IDBErrorInfo::instance()->errorMsg(ec, type), ec); + cerr << IDBErrorInfo::instance()->errorMsg(ec, type.kind()) << " @" << __FILE__ << ":" << __LINE__; + throw IDBExcept(IDBErrorInfo::instance()->errorMsg(ec, type.kind()), ec); break; } } diff --git a/utils/windowfunction/wf_lead_lag.cpp b/utils/windowfunction/wf_lead_lag.cpp index e668fa655..592746f00 100644 --- a/utils/windowfunction/wf_lead_lag.cpp +++ b/utils/windowfunction/wf_lead_lag.cpp @@ -228,7 +228,7 @@ void WF_lead_lag::operator()(int64_t b, int64_t e, int64_t /*c*/) if (o < b || o > e || fOffsetNull) // out of bound { T* v = (fDefNull) ? NULL : &fDefault; - setValue(fRow.getColType(fFieldIndex[0]), b, e, c, v); + setValue(fRow.getColType(fFieldIndex[0]).kind(), b, e, c, v); continue; } @@ -276,7 +276,7 @@ void WF_lead_lag::operator()(int64_t b, int64_t e, int64_t /*c*/) else if (!fDefNull) v = &fDefault; - setValue(fRow.getColType(fFieldIndex[0]), b, e, c, v); + setValue(fRow.getColType(fFieldIndex[0]).kind(), b, e, c, v); } else { @@ -291,7 +291,7 @@ void WF_lead_lag::operator()(int64_t b, int64_t e, int64_t /*c*/) else if (!fDefNull) v = &fDefault; - setValue(fRow.getColType(fFieldIndex[0]), b, e, c, v); + setValue(fRow.getColType(fFieldIndex[0]).kind(), b, e, c, v); } } } diff --git a/utils/windowfunction/wf_min_max.cpp b/utils/windowfunction/wf_min_max.cpp index 906db5460..00434779e 100644 --- a/utils/windowfunction/wf_min_max.cpp +++ b/utils/windowfunction/wf_min_max.cpp @@ -169,7 +169,7 @@ void WF_min_max::operator()(int64_t b, int64_t e, int64_t c) } T* v = ((fCount > 0) ? &fValue : NULL); - setValue(fRow.getColType(fFieldIndex[0]), b, e, c, v); + setValue(fRow.getColType(fFieldIndex[0]).kind(), b, e, c, v); fPrev = c; } diff --git a/utils/windowfunction/wf_nth_value.cpp b/utils/windowfunction/wf_nth_value.cpp index 2ee196eb3..38e62453c 100644 --- a/utils/windowfunction/wf_nth_value.cpp +++ b/utils/windowfunction/wf_nth_value.cpp @@ -263,7 +263,7 @@ void WF_nth_value::operator()(int64_t b, int64_t e, int64_t c) } T* v = (isNull) ? NULL : &fValue; - setValue(fRow.getColType(fFieldIndex[0]), b, e, c, v); + setValue(fRow.getColType(fFieldIndex[0]).kind(), b, e, c, v); } } diff --git a/utils/windowfunction/wf_percentile.cpp b/utils/windowfunction/wf_percentile.cpp index 71c9728de..5475b0efd 100644 --- a/utils/windowfunction/wf_percentile.cpp +++ b/utils/windowfunction/wf_percentile.cpp @@ -251,7 +251,7 @@ void WF_percentile::operator()(int64_t b, int64_t e, int64_t c) break; fRow.setData(getPointer(fRowData->at(c))); - setValue(fRow.getColType(fFieldIndex[0]), b, e, c, (T*)NULL); + setValue(fRow.getColType(fFieldIndex[0]).kind(), b, e, c, (T*)NULL); } return; @@ -300,7 +300,7 @@ void WF_percentile::operator()(int64_t b, int64_t e, int64_t c) T* p = NULL; T v; - int ct = (fFunctionId == WF__PERCENTILE_CONT) ? CalpontSystemCatalog::DOUBLE : fRow.getColType(idx); + int ct = (fFunctionId == WF__PERCENTILE_CONT) ? CalpontSystemCatalog::DOUBLE : fRow.getColType(idx).kind(); if (b1 != -1) { diff --git a/utils/windowfunction/wf_sum_avg.cpp b/utils/windowfunction/wf_sum_avg.cpp index 8fa755020..03c5b7bac 100644 --- a/utils/windowfunction/wf_sum_avg.cpp +++ b/utils/windowfunction/wf_sum_avg.cpp @@ -297,8 +297,7 @@ void WF_sum_avg::operator()(int64_t b, int64_t e, int64_t c) v = &fSum; } - setValue(fRow.getColType(colOut), b, e, c, v); - + setValue(fRow.getColType(colOut).kind(), b, e, c, v); fPrev = c; } diff --git a/utils/windowfunction/wf_udaf.cpp b/utils/windowfunction/wf_udaf.cpp index c4b5002f0..8c46e2207 100644 --- a/utils/windowfunction/wf_udaf.cpp +++ b/utils/windowfunction/wf_udaf.cpp @@ -175,7 +175,7 @@ bool WF_udaf::dropValues(int64_t b, int64_t e) if (!bSkipIt && !(flags[k] & mcsv1sdk::PARAM_IS_NULL)) { - switch (datum.dataType) + switch (datum.dataType.kind()) { case CalpontSystemCatalog::TINYINT: case CalpontSystemCatalog::SMALLINT: @@ -492,7 +492,7 @@ bool WF_udaf::dropValues(int64_t b, int64_t e) default: { - string errStr = "(" + colType2String[(int)datum.dataType] + ")"; + string errStr = "(" + colType2String[(int)datum.dataType.kind()] + ")"; errStr = IDBErrorInfo::instance()->errorMsg(ERR_WF_INVALID_PARM_TYPE, errStr); cerr << errStr << endl; throw IDBExcept(errStr, ERR_WF_INVALID_PARM_TYPE); @@ -686,11 +686,11 @@ void WF_udaf::SetUDAFValue(static_any::any& valOut, int64_t colOut, int64_t b, i case execplan::CalpontSystemCatalog::UDECIMAL: if (valOut.empty()) { - setValue(colDataType, b, e, c, (int64_t*)NULL); + setValue(colDataType.kind(), b, e, c, (int64_t*)NULL); } else { - setValue(colDataType, b, e, c, &intOut); + setValue(colDataType.kind(), b, e, c, &intOut); } break; @@ -705,11 +705,11 @@ void WF_udaf::SetUDAFValue(static_any::any& valOut, int64_t colOut, int64_t b, i case execplan::CalpontSystemCatalog::TIME: if (valOut.empty()) { - setValue(colDataType, b, e, c, (uint64_t*)NULL); + setValue(colDataType.kind(), b, e, c, (uint64_t*)NULL); } else { - setValue(colDataType, b, e, c, &uintOut); + setValue(colDataType.kind(), b, e, c, &uintOut); } break; @@ -717,11 +717,11 @@ void WF_udaf::SetUDAFValue(static_any::any& valOut, int64_t colOut, int64_t b, i case execplan::CalpontSystemCatalog::UFLOAT: if (valOut.empty()) { - setValue(colDataType, b, e, c, (float*)NULL); + setValue(colDataType.kind(), b, e, c, (float*)NULL); } else { - setValue(colDataType, b, e, c, &floatOut); + setValue(colDataType.kind(), b, e, c, &floatOut); } break; @@ -729,22 +729,22 @@ void WF_udaf::SetUDAFValue(static_any::any& valOut, int64_t colOut, int64_t b, i case execplan::CalpontSystemCatalog::UDOUBLE: if (valOut.empty()) { - setValue(colDataType, b, e, c, (double*)NULL); + setValue(colDataType.kind(), b, e, c, (double*)NULL); } else { - setValue(colDataType, b, e, c, &doubleOut); + setValue(colDataType.kind(), b, e, c, &doubleOut); } break; case execplan::CalpontSystemCatalog::LONGDOUBLE: if (valOut.empty()) { - setValue(colDataType, b, e, c, (long double*)NULL); + setValue(colDataType.kind(), b, e, c, (long double*)NULL); } else { - setValue(colDataType, b, e, c, &longdoubleOut); + setValue(colDataType.kind(), b, e, c, &longdoubleOut); } break; @@ -756,19 +756,19 @@ void WF_udaf::SetUDAFValue(static_any::any& valOut, int64_t colOut, int64_t b, i case execplan::CalpontSystemCatalog::BLOB: if (valOut.empty()) { - setValue(colDataType, b, e, c, (utils::NullString*)NULL); + setValue(colDataType.kind(), b, e, c, (utils::NullString*)NULL); } else { utils::NullString nullStrOut(strOut); - setValue(colDataType, b, e, c, &nullStrOut); + setValue(colDataType.kind(), b, e, c, &nullStrOut); } break; default: { std::ostringstream errmsg; - errmsg << "WF_udaf: No logic for data type: " << colDataType; + errmsg << "WF_udaf: No logic for data type: " << colDataType.kind(); cerr << errmsg.str() << endl; throw runtime_error(errmsg.str().c_str()); break; @@ -859,7 +859,7 @@ void WF_udaf::operator()(int64_t b, int64_t e, int64_t c) if (!bSkipIt && !(flags[k] & mcsv1sdk::PARAM_IS_NULL)) { - switch (datum.dataType) + switch (datum.dataType.kind()) { case CalpontSystemCatalog::TINYINT: case CalpontSystemCatalog::SMALLINT: @@ -1145,7 +1145,7 @@ void WF_udaf::operator()(int64_t b, int64_t e, int64_t c) default: { - string errStr = "(" + colType2String[(int)datum.dataType] + ")"; + string errStr = "(" + colType2String[(int)datum.dataType.kind()] + ")"; errStr = IDBErrorInfo::instance()->errorMsg(ERR_WF_INVALID_PARM_TYPE, errStr); cerr << errStr << endl; throw IDBExcept(errStr, ERR_WF_INVALID_PARM_TYPE); diff --git a/utils/windowfunction/windowfunctiontype.cpp b/utils/windowfunction/windowfunctiontype.cpp index be9319306..0442b8757 100644 --- a/utils/windowfunction/windowfunctiontype.cpp +++ b/utils/windowfunction/windowfunctiontype.cpp @@ -488,7 +488,7 @@ void WindowFunctionType::setValue(int ct, int64_t b, int64_t e, int64_t c, T* v) template void WindowFunctionType::implicit2T(uint64_t i, T& t, int s) { - int ct = fRow.getColType(i); + int ct = fRow.getColType(i).kind(); switch (ct) { diff --git a/versioning/BRM/brmtypes.h b/versioning/BRM/brmtypes.h index b82f41e5d..155538f96 100644 --- a/versioning/BRM/brmtypes.h +++ b/versioning/BRM/brmtypes.h @@ -178,8 +178,25 @@ struct CPInfoMerge int64_t min_; }; }; + +inline messageqcpp::ByteStream& operator<<(messageqcpp::ByteStream &stream, const CPInfoMerge &obj) +{ + stream << obj.startLbid << obj.max << obj.min << obj.seqNum << obj.type << obj.colWidth << obj.newExtent << obj.bigMax << obj.bigMin; + + return stream; +} + +inline messageqcpp::ByteStream& operator>>(messageqcpp::ByteStream &stream, CPInfoMerge &obj) +{ + stream >> obj.startLbid >> obj.max >> obj.min >> obj.seqNum >> obj.type >> obj.colWidth >> obj.newExtent >> obj.bigMax >> obj.bigMin; + + return stream; +} + typedef std::vector CPInfoMergeList_t; + + // Used for map where lbid is the key. Data members have same meaning as // those in CPInfoMerge. struct CPMaxMinMerge @@ -325,6 +342,22 @@ struct CreateStripeColumnExtentsArgIn execplan::CalpontSystemCatalog::ColDataType colDataType; }; +inline messageqcpp::ByteStream& operator<<(messageqcpp::ByteStream &bs, const CreateStripeColumnExtentsArgIn &in) +{ + static_assert(sizeof(in.oid)==4); + bs << (int32_t)in.oid << in.width << in.colDataType; + + return bs; +} + +inline messageqcpp::ByteStream& operator>>(messageqcpp::ByteStream &bs, CreateStripeColumnExtentsArgIn &in) +{ + static_assert(sizeof(in.oid)==4); + bs >> (int32_t&)in.oid >> in.width >> in.colDataType; + + return bs; +} + /* Output Arg type for DBRM:createStripeColumnExtents() */ struct CreateStripeColumnExtentsArgOut { diff --git a/versioning/BRM/dbrm.cpp b/versioning/BRM/dbrm.cpp index f95b30825..7bf3a09db 100644 --- a/versioning/BRM/dbrm.cpp +++ b/versioning/BRM/dbrm.cpp @@ -404,7 +404,7 @@ int DBRM::markExtentInvalid(const LBID_t lbid, ByteStream command, response; uint8_t err; - command << MARKEXTENTINVALID << (uint64_t)lbid << (uint32_t)colDataType; + command << MARKEXTENTINVALID << (uint64_t)lbid << (uint32_t)colDataType.kind(); err = send_recv(command, response); if (err != ERR_OK) @@ -437,7 +437,7 @@ int DBRM::markExtentsInvalid(const vector& lbids, for (i = 0; i < size; i++) { command << (uint64_t)lbids[i]; - command << (uint32_t)colDataTypes[i]; + command << (uint32_t)colDataTypes[i].kind(); } err = send_recv(command, response); @@ -621,7 +621,7 @@ int DBRM::mergeExtentsMaxMin(const CPInfoMergeList_t& cpInfos) DBRM_THROW for (it = cpInfos.begin(); it != cpInfos.end(); it++) { command << (uint64_t)it->startLbid << (uint64_t)it->max << (uint64_t)it->min << (uint32_t)it->seqNum - << (uint32_t)it->type << (uint32_t)it->newExtent; + << (uint32_t)it->type.kind() << (uint32_t)it->newExtent; } err = send_recv(command, response); @@ -1019,7 +1019,7 @@ int DBRM::createColumnExtent_DBroot(OID_t oid, uint32_t colWidth, uint16_t dbRoo ByteStream command, response; uint8_t err; - uint32_t tmp8 = (uint8_t)colDataType; + uint32_t tmp8 = (uint8_t)colDataType.kind(); uint16_t tmp16; uint32_t tmp32; uint64_t tmp64; @@ -1096,7 +1096,7 @@ int DBRM::createColumnExtentExactFile(OID_t oid, uint32_t colWidth, uint16_t dbR uint32_t tmp32; uint64_t tmp64; - tmp8 = (uint8_t)colDataType; + tmp8 = (uint8_t)colDataType.kind(); command << CREATE_COLUMN_EXTENT_EXACT_FILE << (ByteStream::quadbyte)oid << colWidth << dbRoot << partitionNum << segmentNum << tmp8; err = send_recv(command, response); @@ -4382,7 +4382,7 @@ void DBRM::startAISequence(uint32_t OID, uint64_t firstNum, uint32_t colWidth, { ByteStream command, response; uint8_t err; - uint8_t tmp8 = colDataType; + uint8_t tmp8 = colDataType.kind(); command << START_AI_SEQUENCE << OID << firstNum << colWidth << tmp8; err = send_recv(command, response); diff --git a/versioning/BRM/masterdbrmnode.cpp b/versioning/BRM/masterdbrmnode.cpp index 4f2a32bbd..5dfc15ab9 100644 --- a/versioning/BRM/masterdbrmnode.cpp +++ b/versioning/BRM/masterdbrmnode.cpp @@ -2733,7 +2733,7 @@ void MasterDBRMNode::doStartAISequence(ByteStream& msg, ThreadParams* p) try { msg >> cmd >> oid >> firstNum >> colWidth >> tmp8; - colDataType = (execplan::CalpontSystemCatalog::ColDataType)tmp8; + colDataType = (execplan::CalpontSystemCatalog::Kind)tmp8; idbassert(msg.length() == 0); aiManager.startSequence(oid, firstNum, colWidth, colDataType); reply << (uint8_t)ERR_OK; diff --git a/versioning/BRM/slavecomm.cpp b/versioning/BRM/slavecomm.cpp index 358ff5201..4414540a5 100644 --- a/versioning/BRM/slavecomm.cpp +++ b/versioning/BRM/slavecomm.cpp @@ -392,7 +392,8 @@ void SlaveComm::do_createStripeColumnExtents(ByteStream& msg) cerr << "WorkerComm: do_createStripeColumnExtents()" << endl; #endif - deserializeInlineVector(msg, cols); + + deserializeVector(msg, cols); msg >> tmp16; dbRoot = tmp16; msg >> tmp32; @@ -465,7 +466,7 @@ void SlaveComm::do_createColumnExtent_DBroot(ByteStream& msg) msg >> tmp16; segmentNum = tmp16; msg >> tmp8; - colDataType = (execplan::CalpontSystemCatalog::ColDataType)tmp8; + colDataType = (execplan::CalpontSystemCatalog::Kind)tmp8; if (printOnly) { @@ -534,7 +535,7 @@ void SlaveComm::do_createColumnExtentExactFile(ByteStream& msg) msg >> tmp16; segmentNum = tmp16; msg >> tmp8; - colDataType = (execplan::CalpontSystemCatalog::ColDataType)tmp8; + colDataType = (execplan::CalpontSystemCatalog::Kind)tmp8; if (printOnly) { @@ -1023,7 +1024,7 @@ void SlaveComm::do_bulkSetHWMAndCP(ByteStream& msg) deserializeInlineVector(msg, hwmArgs); deserializeInlineVector(msg, setCPDataArgs); - deserializeInlineVector(msg, mergeCPDataArgs); + deserializeVector(msg, mergeCPDataArgs); msg >> tmp32; transID = tmp32; @@ -1090,7 +1091,7 @@ void SlaveComm::do_markInvalid(ByteStream& msg) return; } - err = slave->markExtentInvalid(lbid, (execplan::CalpontSystemCatalog::ColDataType)colDataType); + err = slave->markExtentInvalid(lbid, (execplan::CalpontSystemCatalog::Kind)colDataType); reply << (uint8_t)err; #ifdef BRM_VERBOSE cerr << "WorkerComm: do_markInvalid() err code is " << err << endl; @@ -1126,7 +1127,7 @@ void SlaveComm::do_markManyExtentsInvalid(ByteStream& msg) msg >> tmp64; msg >> colDataType; lbids.push_back(tmp64); - colDataTypes.push_back((execplan::CalpontSystemCatalog::ColDataType)colDataType); + colDataTypes.push_back((execplan::CalpontSystemCatalog::Kind)colDataType); if (printOnly) cout << " " << tmp64 << " " << colDataType << endl; @@ -1311,7 +1312,7 @@ void SlaveComm::do_mergeExtentsMaxMin(ByteStream& msg) cpMaxMin.seqNum = tmp32; msg >> tmp32; - cpMaxMin.type = (execplan::CalpontSystemCatalog::ColDataType)tmp32; + cpMaxMin.type = (execplan::CalpontSystemCatalog::Kind)tmp32; msg >> tmp32; cpMaxMin.newExtent = tmp32; diff --git a/writeengine/bulk/we_brmreporter.cpp b/writeengine/bulk/we_brmreporter.cpp index 7589a7070..bf6c15a00 100644 --- a/writeengine/bulk/we_brmreporter.cpp +++ b/writeengine/bulk/we_brmreporter.cpp @@ -296,7 +296,7 @@ void BRMReporter::sendCPToFile() { if (!datatypes::isWideDecimalType(fCPInfo[i].type, fCPInfo[i].colWidth)) { - fRptFile << "CP: " << fCPInfo[i].startLbid << ' ' << fCPInfo[i].seqNum << ' ' << fCPInfo[i].type + fRptFile << "CP: " << fCPInfo[i].startLbid << ' ' << fCPInfo[i].seqNum << ' ' << fCPInfo[i].type.kind() << ' ' << fCPInfo[i].colWidth << ' ' << fCPInfo[i].max << ' ' << fCPInfo[i].min << ' ' << fCPInfo[i].newExtent << std::endl; } @@ -305,7 +305,7 @@ void BRMReporter::sendCPToFile() datatypes::TSInt128 bigMin(&fCPInfo[i].bigMin); datatypes::TSInt128 bigMax(&fCPInfo[i].bigMax); - fRptFile << "CP: " << fCPInfo[i].startLbid << ' ' << fCPInfo[i].seqNum << ' ' << fCPInfo[i].type + fRptFile << "CP: " << fCPInfo[i].startLbid << ' ' << fCPInfo[i].seqNum << ' ' << fCPInfo[i].type.kind() << ' ' << fCPInfo[i].colWidth << ' ' << bigMax << ' ' << bigMin << ' ' << fCPInfo[i].newExtent << std::endl; } @@ -327,8 +327,8 @@ void BRMReporter::reportTotals( for (unsigned k = 0; k < satCounts.size(); k++) { - if (boost::get<0>(satCounts[k]) > 0) - fRptFile << "DATA: " << k << ' ' << boost::get<0>(satCounts[k]) << ' ' << boost::get<1>(satCounts[k]) + if (boost::get<0>(satCounts[k]).kind() > 0) + fRptFile << "DATA: " << k << ' ' << boost::get<0>(satCounts[k]).kind() << ' ' << boost::get<1>(satCounts[k]) << ' ' << boost::get<2>(satCounts[k]) << std::endl; } diff --git a/writeengine/server/we_ddlcommandproc.cpp b/writeengine/server/we_ddlcommandproc.cpp index 350647ab1..06404e4a9 100644 --- a/writeengine/server/we_ddlcommandproc.cpp +++ b/writeengine/server/we_ddlcommandproc.cpp @@ -1190,8 +1190,7 @@ uint8_t WE_DDLCommandProc::createtablefiles(ByteStream& bs, std::string& err) { bs >> tmp32; dataOid = tmp32; - bs >> tmp8; - colDataType = (CalpontSystemCatalog::ColDataType)tmp8; + bs >> colDataType; bs >> tmp8; tokenFlag = (tmp8 != 0); bs >> tmp32; @@ -3201,8 +3200,7 @@ uint8_t WE_DDLCommandProc::fillNewColumn(ByteStream& bs, std::string& err) dataOid = tmp32; bs >> tmp32; dictOid = tmp32; - bs >> tmp8; - dataType = (CalpontSystemCatalog::ColDataType)tmp8; + bs >> dataType; bs >> tmp8; autoincrement = (tmp8 != 0); bs >> tmp32; @@ -3216,8 +3214,7 @@ uint8_t WE_DDLCommandProc::fillNewColumn(ByteStream& bs, std::string& err) compressionType = tmp8; bs >> tmp32; refColOID = tmp32; - bs >> tmp8; - refColDataType = (CalpontSystemCatalog::ColDataType)tmp8; + bs >> refColDataType; bs >> tmp32; refColWidth = tmp32; bs >> tmp8; diff --git a/writeengine/server/we_dmlcommandproc.cpp b/writeengine/server/we_dmlcommandproc.cpp index fff5ece08..ba9f959c3 100644 --- a/writeengine/server/we_dmlcommandproc.cpp +++ b/writeengine/server/we_dmlcommandproc.cpp @@ -1862,7 +1862,7 @@ uint8_t WE_DMLCommandProc::processBatchInsertBinary(messageqcpp::ByteStream& bs, NullString valStr; bool valZero = false; // Needed for autoinc check - switch (colType.colDataType) + switch (colType.colDataType.kind()) { case execplan::CalpontSystemCatalog::TINYINT: case execplan::CalpontSystemCatalog::UTINYINT: diff --git a/writeengine/shared/we_bulkrollbackmgr.cpp b/writeengine/shared/we_bulkrollbackmgr.cpp index 9c02a81b5..eb99beae8 100644 --- a/writeengine/shared/we_bulkrollbackmgr.cpp +++ b/writeengine/shared/we_bulkrollbackmgr.cpp @@ -725,7 +725,7 @@ void BulkRollbackMgr::deleteColumn1ExtentsV4(const char* inBuf) // Read meta-data record int numFields = sscanf(inBuf, "%s %u %u %u %u %u %d %s %u %d", recType, &columnOID, &dbRootHwm, &partNumHwm, &segNumHwm, &lastLocalHwm, &colTypeInt, colTypeName, &colWidth, &compressionType); - colType = (CalpontSystemCatalog::ColDataType)colTypeInt; + colType = (CalpontSystemCatalog::Kind)colTypeInt; if (numFields < 9) // compressionType is optional { diff --git a/writeengine/shared/we_convertor.cpp b/writeengine/shared/we_convertor.cpp index 3da8803ee..bd2abfe84 100644 --- a/writeengine/shared/we_convertor.cpp +++ b/writeengine/shared/we_convertor.cpp @@ -470,7 +470,7 @@ void Convertor::convertColType(CalpontSystemCatalog::ColDataType dataType, int c return; } - switch (dataType) + switch (dataType.kind()) { // Map BIT and TINYINT to WR_BYTE case CalpontSystemCatalog::BIT: @@ -643,7 +643,7 @@ void Convertor::convertColType(ColStruct* curStruct) bTokenFlag = curStruct->tokenFlag; width = &(curStruct->colWidth); - switch (dataType) + switch (dataType.kind()) { // Map BIT and TINYINT to WR_BYTE case CalpontSystemCatalog::BIT: @@ -746,7 +746,7 @@ int Convertor::getCorrectRowWidth(CalpontSystemCatalog::ColDataType dataType, in { int offset, newWidth = 4; - switch (dataType) + switch (dataType.kind()) { case CalpontSystemCatalog::TINYINT: case CalpontSystemCatalog::UTINYINT: newWidth = 1; break; diff --git a/writeengine/shared/we_rbmetawriter.cpp b/writeengine/shared/we_rbmetawriter.cpp index 1993d2149..5c866da21 100644 --- a/writeengine/shared/we_rbmetawriter.cpp +++ b/writeengine/shared/we_rbmetawriter.cpp @@ -213,7 +213,7 @@ void RBMetaWriter::saveBulkRollbackMetaData(const std::vector& columns, // Save column meta-data info to support bulk rollback writeColumnMetaData(metaFileName, bExtentWithData, columns[i].dataFile.oid, dbRoot, partition, - segment, localHWM, columns[i].colDataType, ColDataTypeStr[columns[i].colDataType], + segment, localHWM, columns[i].colDataType, ColDataTypeStr[columns[i].colDataType.kind()], columns[i].colWidth, columns[i].compressionType); // Save dctnry store meta-data info to support bulk rollback @@ -519,12 +519,12 @@ void RBMetaWriter::writeColumnMetaData(const std::string& metaFileName, bool wit if (withHWM) { fMetaDataStream << "COLUM1: " << columnOID << ' ' << dbRoot << ' ' << partition << ' ' << segment << ' ' - << lastLocalHwm << ' ' << colType << ' ' << colTypeName << ' ' << colWidth; + << lastLocalHwm << ' ' << colType.kind() << ' ' << colTypeName << ' ' << colWidth; } else { fMetaDataStream << "COLUM2: " << columnOID << ' ' << dbRoot << ' ' << partition << ' ' << segment << ' ' - << colType << ' ' << colTypeName << ' ' << colWidth; + << colType.kind() << ' ' << colTypeName << ' ' << colWidth; } if (compressionType) diff --git a/writeengine/splitter/we_brmupdater.cpp b/writeengine/splitter/we_brmupdater.cpp index a7be2c0df..a368d334c 100644 --- a/writeengine/splitter/we_brmupdater.cpp +++ b/writeengine/splitter/we_brmupdater.cpp @@ -312,7 +312,7 @@ bool WEBrmUpdater::prepareCasualPartitionInfo() pTok = strtok(NULL, " "); if (pTok) - cpInfoMerge.type = (execplan::CalpontSystemCatalog::ColDataType)atoi(pTok); + cpInfoMerge.type = (execplan::CalpontSystemCatalog::Kind)atoi(pTok); else { // cout << "CP Entry : " << aEntry << endl; @@ -570,7 +570,7 @@ bool WEBrmUpdater::prepareColumnOutOfRangeInfo(std::string Entry, int& ColNum, if (pTok) { - ColType = (execplan::CalpontSystemCatalog::ColDataType)atoi(pTok); + ColType = (execplan::CalpontSystemCatalog::Kind)atoi(pTok); } else { diff --git a/writeengine/wrapper/we_colop.cpp b/writeengine/wrapper/we_colop.cpp index 68624d346..52399cf25 100644 --- a/writeengine/wrapper/we_colop.cpp +++ b/writeengine/wrapper/we_colop.cpp @@ -1329,7 +1329,7 @@ bool ColumnOp::getColDataType(const char* name, CalpontSystemCatalog::ColDataTyp for (int i = 0; i < CalpontSystemCatalog::NUM_OF_COL_DATA_TYPE; i++) if (strcmp(name, ColDataTypeStr[i]) == 0) { - colDataType = static_cast(i); + colDataType = static_cast(i); bFound = true; break; } diff --git a/writeengine/wrapper/writeengine.cpp b/writeengine/wrapper/writeengine.cpp index 41524aa0b..0e3901e37 100644 --- a/writeengine/wrapper/writeengine.cpp +++ b/writeengine/wrapper/writeengine.cpp @@ -4185,7 +4185,7 @@ void WriteEngineWrapper::printInputValue(const ColStructList& colStructList, con std::cerr << "Column[" << i << "]"; std::cerr << "Data file OID : " << curColStruct.dataOid << "\t"; std::cerr << "Width : " << curColStruct.colWidth << "\t" - << " Type: " << curColStruct.colDataType << std::endl; + << " Type: " << curColStruct.colDataType.kind() << std::endl; std::cerr << "Total values : " << curTupleList.size() << std::endl; for (j = 0; j < curTupleList.size(); j++) diff --git a/writeengine/xml/we_xmlgenproc.cpp b/writeengine/xml/we_xmlgenproc.cpp index de4d5771a..ebc4e0533 100644 --- a/writeengine/xml/we_xmlgenproc.cpp +++ b/writeengine/xml/we_xmlgenproc.cpp @@ -304,7 +304,7 @@ bool XMLGenProc::makeColumnData(const CalpontSystemCatalog::TableName& table) { xmlTextWriterWriteFormatAttribute(fWriter, BAD_CAST xmlTagTable[TAG_COL_OID], "%d", col->oid); xmlTextWriterWriteAttribute(fWriter, BAD_CAST xmlTagTable[TAG_DATA_TYPE], - BAD_CAST ColDataTypeStr[col->colType.colDataType]); + BAD_CAST ColDataTypeStr[col->colType.colDataType.kind()]); if (col->colType.compressionType != CalpontSystemCatalog::NO_COMPRESSION) xmlTextWriterWriteFormatAttribute(fWriter, BAD_CAST xmlTagTable[TAG_COMPRESS_TYPE], "%d", diff --git a/writeengine/xml/we_xmljob.cpp b/writeengine/xml/we_xmljob.cpp index fd7bd85d6..986877f28 100644 --- a/writeengine/xml/we_xmljob.cpp +++ b/writeengine/xml/we_xmljob.cpp @@ -876,7 +876,7 @@ void XMLJob::fillInXMLDataAsLoaded(execplan::CalpontSystemCatalog::RIDList& colR col.scale = colType.scale; } - col.typeName = ColDataTypeStr[colType.colDataType]; + col.typeName = ColDataTypeStr[colType.colDataType.kind()]; col.compressionType = colType.compressionType; col.dctnry.fCompressionType = colType.compressionType; @@ -951,7 +951,7 @@ void XMLJob::fillInXMLDataNotNullDefault(const std::string& fullTblName, // but we don't do complete validation (like checking to see // if the default is too large for the given integer type), // because we assume DDL is fully validating the default value. - switch (colType.colDataType) + switch (colType.colDataType.kind()) { case execplan::CalpontSystemCatalog::BIT: case execplan::CalpontSystemCatalog::TINYINT: