diff --git a/dbcon/ddlpackage/ddl.l b/dbcon/ddlpackage/ddl.l index bb65715da..edc962a10 100644 --- a/dbcon/ddlpackage/ddl.l +++ b/dbcon/ddlpackage/ddl.l @@ -187,6 +187,7 @@ MEDIUMTEXT {return MEDIUMTEXT;} LONGTEXT {return LONGTEXT;} BOOL {return BOOL;} BOOLEAN {return BOOLEAN;} +MEDIUMINT {return MEDIUMINT;} \n { lineno++;} diff --git a/dbcon/ddlpackage/ddl.y b/dbcon/ddlpackage/ddl.y index 2b35c8392..cdd439927 100644 --- a/dbcon/ddlpackage/ddl.y +++ b/dbcon/ddlpackage/ddl.y @@ -112,7 +112,7 @@ MIN_ROWS MODIFY NO NOT NULL_TOK NUMBER NUMERIC ON PARTIAL PRECISION PRIMARY REFERENCES RENAME RESTRICT SET SMALLINT TABLE TEXT TINYBLOB TINYTEXT TINYINT TO UNIQUE UNSIGNED UPDATE USER SESSION_USER SYSTEM_USER VARCHAR VARBINARY VARYING WITH ZONE DOUBLE IDB_FLOAT REAL CHARSET IDB_IF EXISTS CHANGE TRUNCATE -BOOL BOOLEAN +BOOL BOOLEAN MEDIUMINT %token DQ_IDENT IDENT FCONST SCONST CP_SEARCH_CONDITION_TEXT ICONST DATE TIME @@ -1054,6 +1054,16 @@ exact_numeric_type: $$->fLength = DDLDatatypeLength[DDL_TINYINT]; $$->fPrecision = 1; } + | MEDIUMINT opt_display_width + { + $$ = new ColumnType(DDL_MEDINT); + $$->fLength = DDLDatatypeLength[DDL_MEDINT]; + } + | MEDIUMINT opt_display_width UNSIGNED + { + $$ = new ColumnType(DDL_UNSIGNED_MEDINT); + $$->fLength = DDLDatatypeLength[DDL_UNSIGNED_MEDINT]; + } ; /* Bug 1570, change default scale to 0 from -1 */ opt_precision_scale: diff --git a/dbcon/ddlpackage/ddlpkg.cpp b/dbcon/ddlpackage/ddlpkg.cpp index 1edb909ad..03794a304 100644 --- a/dbcon/ddlpackage/ddlpkg.cpp +++ b/dbcon/ddlpackage/ddlpkg.cpp @@ -115,9 +115,16 @@ ColumnType::ColumnType(int type) : fPrecision = 5; break; + case DDL_MEDINT: + fPrecision = 7; + break; + + case DDL_UNSIGNED_MEDINT: + fPrecision = 8; + break; + case DDL_INT: case DDL_UNSIGNED_INT: - case DDL_MEDINT: fPrecision = 10; break; @@ -202,7 +209,12 @@ void ColumnDef::convertDecimal() fType->fType = DDL_SMALLINT; fType->fLength = 2; } - else if (fType->fPrecision > 4 && fType->fPrecision < 10) + else if (fType->fPrecision > 4 && fType->fPrecision < 7) + { + fType->fType = DDL_MEDINT; + fType->fLength = 4; + } + else if (fType->fPrecision > 6 && fType->fPrecision < 10) { //dataType = CalpontSystemCatalog::INT; fType->fType = DDL_INT; diff --git a/dbcon/ddlpackageproc/altertableprocessor.cpp b/dbcon/ddlpackageproc/altertableprocessor.cpp index a398e656f..cc14424e2 100644 --- a/dbcon/ddlpackageproc/altertableprocessor.cpp +++ b/dbcon/ddlpackageproc/altertableprocessor.cpp @@ -139,7 +139,6 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType break; - // Don't think there can be such a type in syscat right now... case (CalpontSystemCatalog::MEDINT): if (newType.fType == DDL_MEDINT && colType.precision == newType.fPrecision && colType.scale == newType.fScale) return true; @@ -149,6 +148,12 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType // colType.scale == newType.fScale) return true; break; + case (CalpontSystemCatalog::UMEDINT): + if (newType.fType == DDL_UNSIGNED_MEDINT && colType.precision == newType.fPrecision && + colType.scale == newType.fScale) return true; + + break; + case (CalpontSystemCatalog::INT): if (newType.fType == DDL_INT && colType.precision == newType.fPrecision && colType.scale == newType.fScale) return true; @@ -2103,7 +2108,6 @@ void AlterTableProcessor::tableComment(uint32_t sessionID, execplan::CalpontSyst break; case CalpontSystemCatalog::INT: - case CalpontSystemCatalog::MEDINT: if (static_cast(nextVal) > MAX_INT) validated = false; @@ -2113,12 +2117,26 @@ void AlterTableProcessor::tableComment(uint32_t sessionID, execplan::CalpontSyst break; case CalpontSystemCatalog::UINT: - case CalpontSystemCatalog::UMEDINT: if (nextVal > MAX_UINT) validated = false; break; + case CalpontSystemCatalog::MEDINT: + if (static_cast(nextVal) > MAX_MEDINT) + validated = false; + + if (static_cast(nextVal) < 1) + negative = true; + + break; + + case CalpontSystemCatalog::UMEDINT: + if (nextVal > MAX_UMEDINT) + validated = false; + + break; + case CalpontSystemCatalog::SMALLINT: if (static_cast(nextVal) > MAX_SMALLINT) validated = false; diff --git a/dbcon/execplan/calpontsystemcatalog.h b/dbcon/execplan/calpontsystemcatalog.h index 7b828a297..debf7dd07 100644 --- a/dbcon/execplan/calpontsystemcatalog.h +++ b/dbcon/execplan/calpontsystemcatalog.h @@ -58,6 +58,8 @@ const int64_t MIN_TINYINT __attribute__ ((unused)) = std::numeric_limits const int64_t MAX_TINYINT __attribute__ ((unused)) = std::numeric_limits::max(); //127; const int64_t MIN_SMALLINT __attribute__ ((unused)) = std::numeric_limits::min() + 2; //-32766; const int64_t MAX_SMALLINT __attribute__ ((unused)) = std::numeric_limits::max(); //32767; +const int64_t MIN_MEDINT __attribute__ ((unused)) = -(1ULL << 23); //-8388608; +const int64_t MAX_MEDINT __attribute__ ((unused)) = (1ULL << 23) - 1; //8388607; const int64_t MIN_INT __attribute__ ((unused)) = std::numeric_limits::min() + 2; //-2147483646; const int64_t MAX_INT __attribute__ ((unused)) = std::numeric_limits::max(); //2147483647; const int64_t MIN_BIGINT __attribute__ ((unused)) = std::numeric_limits::min() + 2; //-9223372036854775806LL; @@ -66,10 +68,12 @@ const int64_t MAX_BIGINT __attribute__ ((unused)) = std::numeric_limits::max() - 2; //4294967293 const uint64_t MAX_UTINYINT __attribute__ ((unused)) = std::numeric_limits::max() - 2; //253; const uint64_t MAX_USMALLINT __attribute__ ((unused)) = std::numeric_limits::max() - 2; //65533; +const uint64_t MAX_UMEDINT __attribute__ ((unused)) = (1ULL << 24) - 1; //16777215 const uint64_t MAX_UBIGINT __attribute__ ((unused)) = std::numeric_limits::max() - 2; //18446744073709551613 const float MAX_FLOAT __attribute__ ((unused)) = std::numeric_limits::max(); //3.402823466385289e+38 @@ -969,8 +973,8 @@ inline bool isCharType(const execplan::CalpontSystemCatalog::ColDataType type) execplan::CalpontSystemCatalog::TEXT == type); } -/** convenience function to determine if column type is an - * unsigned type +/** convenience function to determine if column type is a + * numeric type */ inline bool isNumeric(const execplan::CalpontSystemCatalog::ColDataType type) { @@ -999,6 +1003,9 @@ inline bool isNumeric(const execplan::CalpontSystemCatalog::ColDataType type) } } +/** convenience function to determine if column type is an + * unsigned type + */ inline bool isUnsigned(const execplan::CalpontSystemCatalog::ColDataType type) { switch (type) diff --git a/dbcon/joblist/tupleunion.cpp b/dbcon/joblist/tupleunion.cpp index d0892e45f..3b7232c62 100644 --- a/dbcon/joblist/tupleunion.cpp +++ b/dbcon/joblist/tupleunion.cpp @@ -1068,6 +1068,7 @@ void TupleUnion::writeNull(Row* out, uint32_t col) out->setUintField<4>(joblist::INTNULL, col); break; + case CalpontSystemCatalog::UMEDINT: case CalpontSystemCatalog::UINT: out->setUintField<4>(joblist::UINTNULL, col); break; diff --git a/dbcon/mysql/ha_calpont_ddl.cpp b/dbcon/mysql/ha_calpont_ddl.cpp index 487e0d4f8..dd6206869 100644 --- a/dbcon/mysql/ha_calpont_ddl.cpp +++ b/dbcon/mysql/ha_calpont_ddl.cpp @@ -198,6 +198,10 @@ uint32_t convertDataType(int dataType) calpontDataType = CalpontSystemCatalog::USMALLINT; break; + case ddlpackage::DDL_UNSIGNED_MEDINT: + calpontDataType = CalpontSystemCatalog::UMEDINT; + break; + case ddlpackage::DDL_UNSIGNED_INT: calpontDataType = CalpontSystemCatalog::UINT; break; @@ -323,21 +327,33 @@ bool validateNextValue( int type, int64_t value ) case ddlpackage::DDL_INT: case ddlpackage::DDL_INTEGER: - case ddlpackage::DDL_MEDINT: { if (value > MAX_INT) validValue = false; } break; + case ddlpackage::DDL_MEDINT: + { + if (value > MAX_MEDINT) + validValue = false; + } + break; + case ddlpackage::DDL_UNSIGNED_INT: - case ddlpackage::DDL_UNSIGNED_MEDINT: { if (static_cast(value) > MAX_UINT) validValue = false; } break; + case ddlpackage::DDL_UNSIGNED_MEDINT: + { + if (static_cast(value) > MAX_UMEDINT) + validValue = false; + } + break; + case ddlpackage::DDL_SMALLINT: { if (value > MAX_SMALLINT) diff --git a/dbcon/mysql/ha_calpont_dml.cpp b/dbcon/mysql/ha_calpont_dml.cpp index 43bdc8cd6..b5bbe57aa 100644 --- a/dbcon/mysql/ha_calpont_dml.cpp +++ b/dbcon/mysql/ha_calpont_dml.cpp @@ -1062,6 +1062,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ } case CalpontSystemCatalog::INT: + case CalpontSystemCatalog::MEDINT: { if (nullVal && (ci.columnTypes[colpos].constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT)) fprintf(ci.filePtr, "%c", ci.delimiter); @@ -1073,6 +1074,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_ } case CalpontSystemCatalog::UINT: + case CalpontSystemCatalog::UMEDINT: { if (nullVal && (ci.columnTypes[colpos].constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT)) fprintf(ci.filePtr, "%c", ci.delimiter); diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 3be44d2b8..c3a4cfd02 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -220,6 +220,14 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType& break; } + case MYSQL_TYPE_INT24: //MEDINT type + { + Field_medium* f2 = (Field_medium*)*f; + longlong int_val = (longlong)value; + f2->store(int_val, f2->unsigned_flag); + break; + } + case MYSQL_TYPE_LONG: //INT type { Field_long* f2 = (Field_long*)*f; @@ -592,6 +600,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h } case CalpontSystemCatalog::INT: + case CalpontSystemCatalog::MEDINT: { intColVal = row.getIntField<4>(s); storeNumericField(f, intColVal, colType); @@ -599,6 +608,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h } case CalpontSystemCatalog::UINT: + case CalpontSystemCatalog::UMEDINT: { uintColVal = row.getUintField<4>(s); storeNumericField(f, uintColVal, colType); diff --git a/primitives/linux-port/column.cpp b/primitives/linux-port/column.cpp index 2b4450d2c..8832a6448 100644 --- a/primitives/linux-port/column.cpp +++ b/primitives/linux-port/column.cpp @@ -325,6 +325,7 @@ inline bool isEmptyVal<4>(uint8_t type, const uint8_t* ival) return (joblist::CHAR4EMPTYROW == *val); case CalpontSystemCatalog::UINT: + case CalpontSystemCatalog::UMEDINT: return (joblist::UINTEMPTYROW == *val); default: @@ -445,6 +446,7 @@ inline bool isNullVal<4>(uint8_t type, const uint8_t* ival) return (joblist::DATENULL == *val); case CalpontSystemCatalog::UINT: + case CalpontSystemCatalog::UMEDINT: return (joblist::UINTNULL == *val); default: @@ -550,6 +552,7 @@ inline bool isMinMaxValid(const NewColRequestHeader* in) case CalpontSystemCatalog::TINYINT: case CalpontSystemCatalog::SMALLINT: + case CalpontSystemCatalog::MEDINT: case CalpontSystemCatalog::INT: case CalpontSystemCatalog::DATE: case CalpontSystemCatalog::BIGINT: @@ -557,6 +560,7 @@ inline bool isMinMaxValid(const NewColRequestHeader* in) case CalpontSystemCatalog::TIME: case CalpontSystemCatalog::UTINYINT: case CalpontSystemCatalog::USMALLINT: + case CalpontSystemCatalog::UMEDINT: case CalpontSystemCatalog::UINT: case CalpontSystemCatalog::UBIGINT: return true; diff --git a/utils/dataconvert/dataconvert.cpp b/utils/dataconvert/dataconvert.cpp index 1d196a436..6566646da 100644 --- a/utils/dataconvert/dataconvert.cpp +++ b/utils/dataconvert/dataconvert.cpp @@ -330,6 +330,19 @@ int64_t number_int_value(const string& data, break; case CalpontSystemCatalog::MEDINT: + if (intVal < MIN_MEDINT) + { + intVal = MIN_MEDINT; + pushwarning = true; + } + else if (intVal > MAX_MEDINT) + { + intVal = MAX_MEDINT; + pushwarning = true; + } + + break; + case CalpontSystemCatalog::INT: if (intVal < MIN_INT) { @@ -559,6 +572,14 @@ uint64_t number_uint_value(const string& data, break; case CalpontSystemCatalog::UMEDINT: + if (uintVal > MAX_UMEDINT) + { + uintVal = MAX_UMEDINT; + pushwarning = true; + } + + break; + case CalpontSystemCatalog::UINT: if (uintVal > MAX_UINT) { diff --git a/utils/rowgroup/rowaggregation.cpp b/utils/rowgroup/rowaggregation.cpp index 8a80ca683..d6aa253a6 100644 --- a/utils/rowgroup/rowaggregation.cpp +++ b/utils/rowgroup/rowaggregation.cpp @@ -2757,7 +2757,6 @@ void RowAggregationUM::SetUDAFValue(static_any::any& valOut, int64_t colOut) break; case execplan::CalpontSystemCatalog::SMALLINT: - case execplan::CalpontSystemCatalog::MEDINT: if (valOut.compatible(shortTypeId)) { intOut = valOut.cast(); @@ -2767,6 +2766,7 @@ void RowAggregationUM::SetUDAFValue(static_any::any& valOut, int64_t colOut) break; + case execplan::CalpontSystemCatalog::MEDINT: case execplan::CalpontSystemCatalog::INT: if (valOut.compatible(uintTypeId)) { @@ -2809,7 +2809,6 @@ void RowAggregationUM::SetUDAFValue(static_any::any& valOut, int64_t colOut) break; case execplan::CalpontSystemCatalog::USMALLINT: - case execplan::CalpontSystemCatalog::UMEDINT: if (valOut.compatible(ushortTypeId)) { uintOut = valOut.cast(); @@ -2819,6 +2818,7 @@ void RowAggregationUM::SetUDAFValue(static_any::any& valOut, int64_t colOut) break; + case execplan::CalpontSystemCatalog::UMEDINT: case execplan::CalpontSystemCatalog::UINT: if (valOut.compatible(uintTypeId)) { @@ -3030,10 +3030,10 @@ void RowAggregationUM::SetUDAFAnyValue(static_any::any& valOut, int64_t colOut) break; case execplan::CalpontSystemCatalog::SMALLINT: - case execplan::CalpontSystemCatalog::MEDINT: fRow.setIntField<2>(intOut, colOut); break; + case execplan::CalpontSystemCatalog::MEDINT: case execplan::CalpontSystemCatalog::INT: fRow.setIntField<4>(intOut, colOut); break; @@ -3049,10 +3049,10 @@ void RowAggregationUM::SetUDAFAnyValue(static_any::any& valOut, int64_t colOut) break; case execplan::CalpontSystemCatalog::USMALLINT: - case execplan::CalpontSystemCatalog::UMEDINT: fRow.setUintField<2>(uintOut, colOut); break; + case execplan::CalpontSystemCatalog::UMEDINT: case execplan::CalpontSystemCatalog::UINT: fRow.setUintField<4>(uintOut, colOut); break; diff --git a/writeengine/bulk/we_bulkloadbuffer.cpp b/writeengine/bulk/we_bulkloadbuffer.cpp index da568f9a6..f0336d79d 100644 --- a/writeengine/bulk/we_bulkloadbuffer.cpp +++ b/writeengine/bulk/we_bulkloadbuffer.cpp @@ -1224,8 +1224,9 @@ void BulkLoadBuffer::convert(char* field, int fieldLength, } //---------------------------------------------------------------------- - // UNSIGNED INTEGER + // UNSIGNED MEDIUM INTEGER AND UNSIGNED INTEGER //---------------------------------------------------------------------- + case WriteEngine::WR_UMEDINT : case WriteEngine::WR_UINT : { int64_t origVal; @@ -1306,8 +1307,9 @@ void BulkLoadBuffer::convert(char* field, int fieldLength, } //---------------------------------------------------------------------- - // INTEGER + // MEDIUM INTEGER AND INTEGER //---------------------------------------------------------------------- + case WriteEngine::WR_MEDINT : case WriteEngine::WR_INT : default : { diff --git a/writeengine/bulk/we_columninfo.cpp b/writeengine/bulk/we_columninfo.cpp index 9c1a1a9e2..4c66e35ff 100644 --- a/writeengine/bulk/we_columninfo.cpp +++ b/writeengine/bulk/we_columninfo.cpp @@ -197,10 +197,12 @@ ColumnInfo::ColumnInfo(Log* logger, case WriteEngine::WR_SHORT: case WriteEngine::WR_BYTE: case WriteEngine::WR_LONGLONG: + case WriteEngine::WR_MEDINT: case WriteEngine::WR_INT: case WriteEngine::WR_USHORT: case WriteEngine::WR_UBYTE: case WriteEngine::WR_ULONGLONG: + case WriteEngine::WR_UMEDINT: case WriteEngine::WR_UINT: default: { diff --git a/writeengine/index/we_indextree.cpp b/writeengine/index/we_indextree.cpp index a2dd97789..0b927c9e6 100644 --- a/writeengine/index/we_indextree.cpp +++ b/writeengine/index/we_indextree.cpp @@ -1182,6 +1182,7 @@ const int IndexTree::setBitsetColumn( void* val, const int pos, const int width, break; case WriteEngine::WR_INT : + case WriteEngine::WR_MEDINT : default : memcpy( m_multiColKey.keyBuf + m_multiColKey.totalBit / 8, (int*) val, copyLen ); m_multiColKey.curBitset = *((int*) val); diff --git a/writeengine/server/we_ddlcommon.h b/writeengine/server/we_ddlcommon.h index 1d482b442..b1e4e48f1 100644 --- a/writeengine/server/we_ddlcommon.h +++ b/writeengine/server/we_ddlcommon.h @@ -464,6 +464,10 @@ inline int convertDataType(int dataType) calpontDataType = CalpontSystemCatalog::USMALLINT; break; + case ddlpackage::DDL_UNSIGNED_MEDINT: + calpontDataType = CalpontSystemCatalog::UMEDINT; + break; + case ddlpackage::DDL_UNSIGNED_INT: calpontDataType = CalpontSystemCatalog::UINT; break; diff --git a/writeengine/server/we_dmlcommandproc.cpp b/writeengine/server/we_dmlcommandproc.cpp index 057ef2504..63cf70092 100644 --- a/writeengine/server/we_dmlcommandproc.cpp +++ b/writeengine/server/we_dmlcommandproc.cpp @@ -3027,6 +3027,8 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs, case CalpontSystemCatalog::UBIGINT: case CalpontSystemCatalog::INT: case CalpontSystemCatalog::UINT: + case CalpontSystemCatalog::MEDINT: + case CalpontSystemCatalog::UMEDINT: case CalpontSystemCatalog::SMALLINT: case CalpontSystemCatalog::USMALLINT: case CalpontSystemCatalog::TINYINT: @@ -3362,6 +3364,8 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs, case CalpontSystemCatalog::UBIGINT: case CalpontSystemCatalog::INT: case CalpontSystemCatalog::UINT: + case CalpontSystemCatalog::MEDINT: + case CalpontSystemCatalog::UMEDINT: case CalpontSystemCatalog::SMALLINT: case CalpontSystemCatalog::USMALLINT: case CalpontSystemCatalog::TINYINT: diff --git a/writeengine/shared/we_convertor.cpp b/writeengine/shared/we_convertor.cpp index 8050426f3..73340ff13 100644 --- a/writeengine/shared/we_convertor.cpp +++ b/writeengine/shared/we_convertor.cpp @@ -404,8 +404,12 @@ void Convertor::convertColType(CalpontSystemCatalog::ColDataType dataType, internalType = WriteEngine::WR_SHORT; break; - // Map MEDINT, INT, and DATE to WR_INT + // Map MEDINT to WR_MEDINT case CalpontSystemCatalog::MEDINT : + internalType = WriteEngine::WR_MEDINT; + break; + + // Map INT, and DATE to WR_INT case CalpontSystemCatalog::INT : case CalpontSystemCatalog::DATE : internalType = WriteEngine::WR_INT; @@ -469,8 +473,12 @@ void Convertor::convertColType(CalpontSystemCatalog::ColDataType dataType, internalType = WriteEngine::WR_USHORT; break; - // Map UMEDINT and UINT to WR_UINT + // Map UMEDINT to WR_UMEDINT case CalpontSystemCatalog::UMEDINT: + internalType = WriteEngine::WR_UMEDINT; + break; + + // Map UINT to WR_UINT case CalpontSystemCatalog::UINT: internalType = WriteEngine::WR_UINT; break; @@ -512,7 +520,12 @@ void Convertor::convertWEColType(ColType internalType, dataType = CalpontSystemCatalog::SMALLINT; break; - // Map MEDINT, INT, and DATE to WR_INT + // Map MEDINT to WR_MEDINT + case WriteEngine::WR_MEDINT : + dataType = CalpontSystemCatalog::MEDINT; + break; + + // Map INT, and DATE to WR_INT case WriteEngine::WR_INT : dataType = CalpontSystemCatalog::INT; break; @@ -562,7 +575,12 @@ void Convertor::convertWEColType(ColType internalType, dataType = CalpontSystemCatalog::USMALLINT; break; - // Map UMEDINT and UINT to WR_UINT + // Map UMEDINT to WR_UMEDINT + case WriteEngine::WR_UMEDINT: + dataType = CalpontSystemCatalog::UMEDINT; + break; + + // Map UINT to WR_UINT case WriteEngine::WR_UINT: dataType = CalpontSystemCatalog::UINT; break; @@ -614,8 +632,12 @@ void Convertor::convertColType(ColStruct* curStruct) *internalType = WriteEngine::WR_SHORT; break; - // Map MEDINT, INT, and DATE to WR_INT + // Map MEDINT to WR_MEDINT case CalpontSystemCatalog::MEDINT : + *internalType = WriteEngine::WR_MEDINT; + break; + + // Map INT, and DATE to WR_INT case CalpontSystemCatalog::INT : case CalpontSystemCatalog::DATE : *internalType = WriteEngine::WR_INT; @@ -698,8 +720,12 @@ void Convertor::convertColType(ColStruct* curStruct) *internalType = WriteEngine::WR_USHORT; break; - // Map UMEDINT and UINT to WR_UINT + // Map UMEDINT to WR_UMEDINT case CalpontSystemCatalog::UMEDINT: + *internalType = WriteEngine::WR_UMEDINT; + break; + + // Map UINT to WR_UINT case CalpontSystemCatalog::UINT: *internalType = WriteEngine::WR_UINT; break; diff --git a/writeengine/shared/we_type.h b/writeengine/shared/we_type.h index 06a367ecb..8a8cae5a9 100644 --- a/writeengine/shared/we_type.h +++ b/writeengine/shared/we_type.h @@ -108,7 +108,9 @@ enum ColType /** @brief Column type enumeration*/ WR_USHORT = 14, /** @brief Unsigned Short */ WR_UINT = 15, /** @brief Unsigned Int */ WR_ULONGLONG = 16, /** @brief Unsigned Long long*/ - WR_TEXT = 17 /** @brief TEXT */ + WR_TEXT = 17, /** @brief TEXT */ + WR_MEDINT = 18, /** @brief Medium Int */ + WR_UMEDINT = 19 /** @brief Unsigned Medium Int */ }; // Describes relation of field to column for a bulk load diff --git a/writeengine/wrapper/we_colop.cpp b/writeengine/wrapper/we_colop.cpp index ffd01df2e..4f0e6a0d2 100644 --- a/writeengine/wrapper/we_colop.cpp +++ b/writeengine/wrapper/we_colop.cpp @@ -1618,6 +1618,7 @@ int ColumnOp::writeRow(Column& curCol, uint64_t totalRow, const RID* rowIdArray, break; case WriteEngine::WR_INT : + case WriteEngine::WR_MEDINT : if (!bDelete) pVal = &((int*) valArray)[i]; //pOldVal = &((int *) oldValArray)[i]; @@ -1636,6 +1637,7 @@ int ColumnOp::writeRow(Column& curCol, uint64_t totalRow, const RID* rowIdArray, break; case WriteEngine::WR_UINT : + case WriteEngine::WR_UMEDINT : if (!bDelete) pVal = &((uint32_t*) valArray)[i]; //pOldVal = &((uint8_t *) oldValArray)[i]; @@ -1789,6 +1791,7 @@ int ColumnOp::writeRows(Column& curCol, uint64_t totalRow, const RIDList& ridLis break; case WriteEngine::WR_INT : + case WriteEngine::WR_MEDINT : if (!bDelete) pVal = &((int*) valArray)[0]; //pOldVal = &((int *) oldValArray)[i]; @@ -1813,6 +1816,7 @@ int ColumnOp::writeRows(Column& curCol, uint64_t totalRow, const RIDList& ridLis break; case WriteEngine::WR_UINT : + case WriteEngine::WR_UMEDINT : if (!bDelete) pVal = &((uint32_t*) valArray)[0]; //pOldVal = &((uint32_t *) oldValArray)[i]; @@ -1944,6 +1948,7 @@ int ColumnOp::writeRowsValues(Column& curCol, uint64_t totalRow, const RIDList& break; case WriteEngine::WR_INT : + case WriteEngine::WR_MEDINT : pVal = &((int*) valArray)[i]; break; @@ -1960,6 +1965,7 @@ int ColumnOp::writeRowsValues(Column& curCol, uint64_t totalRow, const RIDList& break; case WriteEngine::WR_UINT : + case WriteEngine::WR_UMEDINT : pVal = &((uint32_t*) valArray)[i]; break; diff --git a/writeengine/wrapper/writeengine.cpp b/writeengine/wrapper/writeengine.cpp index 6386d70c4..62842da0d 100644 --- a/writeengine/wrapper/writeengine.cpp +++ b/writeengine/wrapper/writeengine.cpp @@ -261,6 +261,7 @@ void WriteEngineWrapper::convertValue(const ColType colType, void* value, boost: switch (colType) { case WriteEngine::WR_INT : + case WriteEngine::WR_MEDINT : if (data.type() == typeid(int)) { int val = boost::any_cast(data); @@ -277,6 +278,7 @@ void WriteEngineWrapper::convertValue(const ColType colType, void* value, boost: break; case WriteEngine::WR_UINT : + case WriteEngine::WR_UMEDINT : { uint32_t val = boost::any_cast(data); size = sizeof(uint32_t); @@ -410,6 +412,7 @@ void WriteEngineWrapper::convertValue(const ColType colType, void* valArray, con switch (colType) { case WriteEngine::WR_INT : + case WriteEngine::WR_MEDINT : if (data.type() == typeid(long)) ((int*)valArray)[pos] = static_cast(boost::any_cast(data)); else if (data.type() == typeid(int)) @@ -420,6 +423,7 @@ void WriteEngineWrapper::convertValue(const ColType colType, void* valArray, con break; case WriteEngine::WR_UINT : + case WriteEngine::WR_UMEDINT : ((uint32_t*)valArray)[pos] = boost::any_cast(data); break; @@ -495,10 +499,12 @@ void WriteEngineWrapper::convertValue(const ColType colType, void* valArray, con switch (colType) { case WriteEngine::WR_INT : + case WriteEngine::WR_MEDINT : data = ((int*)valArray)[pos]; break; case WriteEngine::WR_UINT : + case WriteEngine::WR_UMEDINT : data = ((uint64_t*)valArray)[pos]; break; @@ -814,10 +820,12 @@ int WriteEngineWrapper::deleteBadRows(const TxnID& txnid, ColStructList& colStru switch (colStructs[i].colType) { case WriteEngine::WR_INT: + case WriteEngine::WR_MEDINT: valArray = (int*) calloc(sizeof(int), 1); break; case WriteEngine::WR_UINT: + case WriteEngine::WR_UMEDINT: valArray = (uint32_t*) calloc(sizeof(uint32_t), 1); break; @@ -4484,10 +4492,12 @@ int WriteEngineWrapper::writeColumnRecords(const TxnID& txnid, switch (curColStruct.colType) { case WriteEngine::WR_INT: + case WriteEngine::WR_MEDINT: valArray = (int*) calloc(sizeof(int), totalRow); break; case WriteEngine::WR_UINT: + case WriteEngine::WR_UMEDINT: valArray = (uint32_t*) calloc(sizeof(uint32_t), totalRow); break; @@ -4721,10 +4731,12 @@ int WriteEngineWrapper::writeColumnRec(const TxnID& txnid, switch (colStructList[i].colType) { case WriteEngine::WR_INT: + case WriteEngine::WR_MEDINT: valArray = (int*) calloc(sizeof(int), totalRow1); break; case WriteEngine::WR_UINT: + case WriteEngine::WR_UMEDINT: valArray = (uint32_t*) calloc(sizeof(uint32_t), totalRow1); break; @@ -4894,10 +4906,12 @@ int WriteEngineWrapper::writeColumnRec(const TxnID& txnid, switch (newColStructList[i].colType) { case WriteEngine::WR_INT: + case WriteEngine::WR_MEDINT: valArray = (int*) calloc(sizeof(int), totalRow2); break; case WriteEngine::WR_UINT: + case WriteEngine::WR_UMEDINT: valArray = (uint32_t*) calloc(sizeof(uint32_t), totalRow2); break; @@ -5065,10 +5079,12 @@ int WriteEngineWrapper::writeColumnRec(const TxnID& txnid, switch (colStructList[i].colType) { case WriteEngine::WR_INT: + case WriteEngine::WR_MEDINT: valArray = (int*) calloc(sizeof(int), totalRow1); break; case WriteEngine::WR_UINT: + case WriteEngine::WR_UMEDINT: valArray = (uint32_t*) calloc(sizeof(uint32_t), totalRow1); break; @@ -5308,6 +5324,8 @@ int WriteEngineWrapper::writeColumnRecBinary(const TxnID& txnid, case WriteEngine::WR_INT: case WriteEngine::WR_UINT: + case WriteEngine::WR_MEDINT: + case WriteEngine::WR_UMEDINT: case WriteEngine::WR_FLOAT: tmp32 = curValue; ((uint32_t*)valArray)[j] = tmp32; @@ -5449,6 +5467,8 @@ int WriteEngineWrapper::writeColumnRecBinary(const TxnID& txnid, case WriteEngine::WR_INT: case WriteEngine::WR_UINT: + case WriteEngine::WR_MEDINT: + case WriteEngine::WR_UMEDINT: case WriteEngine::WR_FLOAT: tmp32 = curValue; ((uint32_t*)valArray)[j] = tmp32; @@ -5704,10 +5724,12 @@ int WriteEngineWrapper::writeColumnRec(const TxnID& txnid, switch (curColStruct.colType) { case WriteEngine::WR_INT: + case WriteEngine::WR_MEDINT: valArray = (int*) calloc(sizeof(int), 1); break; case WriteEngine::WR_UINT: + case WriteEngine::WR_UMEDINT: valArray = (uint32_t*) calloc(sizeof(uint32_t), 1); break; diff --git a/writeengine/xml/we_xmljob.cpp b/writeengine/xml/we_xmljob.cpp index 8d755b824..4dd923172 100644 --- a/writeengine/xml/we_xmljob.cpp +++ b/writeengine/xml/we_xmljob.cpp @@ -719,6 +719,18 @@ void XMLJob::initSatLimits( JobColumn& curColumn ) const curColumn.fMinIntSat = MIN_UBIGINT; curColumn.fMaxIntSat = MAX_UBIGINT; } + else if ( curColumn.typeName == + ColDataTypeStr[CalpontSystemCatalog::MEDINT] ) + { + curColumn.fMinIntSat = MIN_MEDINT; + curColumn.fMaxIntSat = MAX_MEDINT; + } + else if ( curColumn.typeName == + ColDataTypeStr[CalpontSystemCatalog::UMEDINT] ) + { + curColumn.fMinIntSat = MIN_UMEDINT; + curColumn.fMaxIntSat = MAX_UMEDINT; + } else if ( curColumn.typeName == ColDataTypeStr[CalpontSystemCatalog::SMALLINT] ) {