You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-4377 Split DataConvert::convertColumnData()
This commit is contained in:
committed by
Roman Nozdrin
parent
c00daa93bd
commit
3d7f5c6fd1
@ -1045,13 +1045,12 @@ class SimpleConverter: public boost::any
|
||||
bool m_pushWarning;
|
||||
public:
|
||||
SimpleConverter(const SessionParam &sp,
|
||||
SystemCatalog::ColDataType typeCode,
|
||||
const TypeHandler *h,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str)
|
||||
:boost::any(DataConvert::convertColumnData(typeCode, attr,
|
||||
str, initPushWarning(),
|
||||
sp.tzname(),
|
||||
false, true, false))
|
||||
:boost::any(h->convertFromString(attr,
|
||||
ConvertFromStringParam(sp.tzname(), true, false),
|
||||
str, initPushWarning()))
|
||||
{ }
|
||||
round_style_t roundStyle() const
|
||||
{
|
||||
@ -1084,11 +1083,11 @@ class SimpleConverterSNumeric: public SimpleConverter
|
||||
{
|
||||
public:
|
||||
SimpleConverterSNumeric(const SessionParam &sp,
|
||||
SystemCatalog::ColDataType typeCode,
|
||||
const TypeHandler *h,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str,
|
||||
round_style_t &rf)
|
||||
:SimpleConverter(sp, typeCode, attr, str)
|
||||
:SimpleConverter(sp, h, attr, str)
|
||||
{
|
||||
rf = roundStyle(str);
|
||||
}
|
||||
@ -1098,12 +1097,12 @@ public:
|
||||
template<typename T>
|
||||
SimpleValue
|
||||
toSimpleValueSInt(const SessionParam &sp,
|
||||
SystemCatalog::ColDataType typeCode,
|
||||
const TypeHandler *h,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str, round_style_t & rf)
|
||||
{
|
||||
idbassert(attr.colWidth <= SystemCatalog::EIGHT_BYTE);
|
||||
SimpleConverterSNumeric anyVal(sp, typeCode, attr, str, rf);
|
||||
SimpleConverterSNumeric anyVal(sp, h, attr, str, rf);
|
||||
return SimpleValueSInt64(static_cast<int64_t>(boost::any_cast<T>(anyVal)));
|
||||
}
|
||||
|
||||
@ -1113,7 +1112,7 @@ TypeHandlerSInt8::toSimpleValue(const SessionParam &sp,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
return toSimpleValueSInt<char>(sp, SystemCatalog::TINYINT, attr, str, rf);
|
||||
return toSimpleValueSInt<char>(sp, this, attr, str, rf);
|
||||
}
|
||||
|
||||
|
||||
@ -1122,7 +1121,7 @@ TypeHandlerSInt16::toSimpleValue(const SessionParam &sp,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
return toSimpleValueSInt<int16_t>(sp, SystemCatalog::SMALLINT, attr, str, rf);
|
||||
return toSimpleValueSInt<int16_t>(sp, this, attr, str, rf);
|
||||
}
|
||||
|
||||
|
||||
@ -1131,7 +1130,7 @@ TypeHandlerSInt24::toSimpleValue(const SessionParam &sp,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
return toSimpleValueSInt<mcs_sint32_t>(sp, SystemCatalog::MEDINT, attr, str, rf);
|
||||
return toSimpleValueSInt<mcs_sint32_t>(sp, this, attr, str, rf);
|
||||
}
|
||||
|
||||
|
||||
@ -1140,7 +1139,7 @@ TypeHandlerSInt32::toSimpleValue(const SessionParam &sp,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
return toSimpleValueSInt<mcs_sint32_t>(sp, SystemCatalog::INT, attr, str, rf);
|
||||
return toSimpleValueSInt<mcs_sint32_t>(sp, this, attr, str, rf);
|
||||
}
|
||||
|
||||
|
||||
@ -1149,18 +1148,18 @@ TypeHandlerSInt64::toSimpleValue(const SessionParam &sp,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
return toSimpleValueSInt<long long>(sp, SystemCatalog::BIGINT, attr, str, rf);
|
||||
return toSimpleValueSInt<long long>(sp, this, attr, str, rf);
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
SimpleValue toSimpleValueUInt(const SessionParam &sp,
|
||||
SystemCatalog::ColDataType typeCode,
|
||||
const TypeHandler *h,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str)
|
||||
{
|
||||
idbassert(attr.colWidth <= SystemCatalog::EIGHT_BYTE);
|
||||
SimpleConverter anyVal(sp, typeCode, attr, str);
|
||||
SimpleConverter anyVal(sp, h, attr, str);
|
||||
return SimpleValueSInt64(static_cast<int64_t>(boost::any_cast<T>(anyVal)));
|
||||
}
|
||||
|
||||
@ -1170,7 +1169,7 @@ TypeHandlerUInt8::toSimpleValue(const SessionParam &sp,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
return toSimpleValueUInt<uint8_t>(sp, SystemCatalog::UTINYINT, attr, str);
|
||||
return toSimpleValueUInt<uint8_t>(sp, this, attr, str);
|
||||
}
|
||||
|
||||
|
||||
@ -1179,7 +1178,7 @@ TypeHandlerUInt16::toSimpleValue(const SessionParam &sp,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
return toSimpleValueUInt<uint16_t>(sp, SystemCatalog::USMALLINT, attr, str);
|
||||
return toSimpleValueUInt<uint16_t>(sp, this, attr, str);
|
||||
}
|
||||
|
||||
|
||||
@ -1188,7 +1187,7 @@ TypeHandlerUInt24::toSimpleValue(const SessionParam &sp,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
return toSimpleValueUInt<uint32_t>(sp, SystemCatalog::UMEDINT, attr, str);
|
||||
return toSimpleValueUInt<uint32_t>(sp, this, attr, str);
|
||||
}
|
||||
|
||||
|
||||
@ -1197,7 +1196,7 @@ TypeHandlerUInt32::toSimpleValue(const SessionParam &sp,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
return toSimpleValueUInt<uint32_t>(sp, SystemCatalog::UINT, attr, str);
|
||||
return toSimpleValueUInt<uint32_t>(sp, this, attr, str);
|
||||
}
|
||||
|
||||
|
||||
@ -1206,7 +1205,7 @@ TypeHandlerUInt64::toSimpleValue(const SessionParam &sp,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
return toSimpleValueUInt<uint64_t>(sp, SystemCatalog::UBIGINT, attr, str);
|
||||
return toSimpleValueUInt<uint64_t>(sp, this, attr, str);
|
||||
}
|
||||
|
||||
|
||||
@ -1216,7 +1215,7 @@ TypeHandlerDate::toSimpleValue(const SessionParam &sp,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
idbassert(attr.colWidth <= SystemCatalog::EIGHT_BYTE);
|
||||
SimpleConverter anyVal(sp, SystemCatalog::DATE, attr, str);
|
||||
SimpleConverter anyVal(sp, this, attr, str);
|
||||
return SimpleValueSInt64(static_cast<int64_t>(anyVal.to_uint32()));
|
||||
}
|
||||
|
||||
@ -1227,7 +1226,7 @@ TypeHandlerDatetime::toSimpleValue(const SessionParam &sp,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
idbassert(attr.colWidth <= SystemCatalog::EIGHT_BYTE);
|
||||
SimpleConverter anyVal(sp, SystemCatalog::DATETIME, attr, str);
|
||||
SimpleConverter anyVal(sp, this, attr, str);
|
||||
return SimpleValueSInt64(static_cast<int64_t>(anyVal.to_uint64()));
|
||||
}
|
||||
|
||||
@ -1238,7 +1237,7 @@ TypeHandlerTimestamp::toSimpleValue(const SessionParam &sp,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
idbassert(attr.colWidth <= SystemCatalog::EIGHT_BYTE);
|
||||
SimpleConverter anyVal(sp, SystemCatalog::TIMESTAMP, attr, str);
|
||||
SimpleConverter anyVal(sp, this, attr, str);
|
||||
return SimpleValueTimestamp(anyVal.to_uint64(), sp.tzname());
|
||||
}
|
||||
|
||||
@ -1249,7 +1248,7 @@ TypeHandlerTime::toSimpleValue(const SessionParam &sp,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
idbassert(attr.colWidth <= SystemCatalog::EIGHT_BYTE);
|
||||
SimpleConverter anyVal(sp, SystemCatalog::TIME, attr, str);
|
||||
SimpleConverter anyVal(sp, this, attr, str);
|
||||
return SimpleValueSInt64(anyVal.to_sint64());
|
||||
}
|
||||
|
||||
@ -1261,7 +1260,7 @@ TypeHandlerXDecimal::toSimpleValue(const SessionParam &sp,
|
||||
{
|
||||
if (attr.colWidth <= SystemCatalog::EIGHT_BYTE)
|
||||
{
|
||||
SimpleConverterSNumeric anyVal(sp, code(), attr, str, rf);
|
||||
SimpleConverterSNumeric anyVal(sp, this, attr, str, rf);
|
||||
int64_t v;
|
||||
if (attr.colWidth == SystemCatalog::ONE_BYTE)
|
||||
v = boost::any_cast<char>(anyVal);
|
||||
@ -1281,7 +1280,7 @@ TypeHandlerXDecimal::toSimpleValue(const SessionParam &sp,
|
||||
else
|
||||
{
|
||||
idbassert(attr.colWidth == datatypes::MAXDECIMALWIDTH);
|
||||
SimpleConverterSNumeric anyVal(sp, code(), attr, str, rf);
|
||||
SimpleConverterSNumeric anyVal(sp, this, attr, str, rf);
|
||||
return SimpleValueSInt128(anyVal.to_sint128());
|
||||
}
|
||||
}
|
||||
@ -1292,7 +1291,7 @@ TypeHandlerStr::toSimpleValue(const SessionParam &sp,
|
||||
const SystemCatalog::TypeAttributesStd &attr,
|
||||
const char *str, round_style_t & rf) const
|
||||
{
|
||||
SimpleConverter anyVal(sp, code(), attr, str);
|
||||
SimpleConverter anyVal(sp, this, attr, str);
|
||||
rf= anyVal.roundStyle();
|
||||
string i = boost::any_cast<string>(anyVal);
|
||||
// bug 1932, pad nulls up to the size of v
|
||||
@ -1758,6 +1757,321 @@ TypeHandlerVarbinary::getNullValueForType(const SystemCatalog::TypeAttributesStd
|
||||
return value;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
boost::any
|
||||
TypeHandlerBit::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToBit(colType, prm, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerSInt8::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
int64_t val64;
|
||||
dataconvert::number_int_value(data, SystemCatalog::TINYINT, colType, pushWarning, prm.noRoundup(), val64);
|
||||
boost::any value = (char) val64;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerSInt16::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
int64_t val64;
|
||||
dataconvert::number_int_value(data, SystemCatalog::SMALLINT, colType, pushWarning, prm.noRoundup(), val64);
|
||||
boost::any value = (short) val64;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerSInt24::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
int64_t val64;
|
||||
dataconvert::number_int_value(data, SystemCatalog::MEDINT, colType, pushWarning, prm.noRoundup(), val64);
|
||||
boost::any value = (int) val64;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerSInt32::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
int64_t val64;
|
||||
dataconvert::number_int_value(data, SystemCatalog::INT, colType, pushWarning, prm.noRoundup(), val64);
|
||||
boost::any value = (int) val64;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerSInt64::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
int64_t val64;
|
||||
dataconvert::number_int_value(data, SystemCatalog::BIGINT, colType, pushWarning, prm.noRoundup(), val64);
|
||||
boost::any value = (long long) val64;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerUInt8::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
|
||||
{
|
||||
boost::any value = (uint8_t)dataconvert::number_uint_value(data, SystemCatalog::UTINYINT, colType, pushWarning, prm.noRoundup());
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerUInt16::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
boost::any value = (uint16_t)dataconvert::number_uint_value(data, SystemCatalog::USMALLINT, colType, pushWarning, prm.noRoundup());
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerUInt24::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
boost::any value = (uint32_t)dataconvert::number_uint_value(data, SystemCatalog::UMEDINT, colType, pushWarning, prm.noRoundup());
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerUInt32::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
boost::any value = (uint32_t)dataconvert::number_uint_value(data, SystemCatalog::UINT, colType, pushWarning, prm.noRoundup());
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerUInt64::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
boost::any value = (uint64_t)dataconvert::number_uint_value(data, SystemCatalog::UBIGINT, colType, pushWarning, prm.noRoundup());
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerSFloat::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToFloat(SystemCatalog::FLOAT, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerUFloat::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToFloat(SystemCatalog::UFLOAT, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerSDouble::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToDouble(SystemCatalog::DOUBLE, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerUDouble::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToDouble(SystemCatalog::UDOUBLE, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerDate::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToDate(data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerDatetime::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToDatetime(data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerTime::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToTime(colType, data, pushWarning);
|
||||
}
|
||||
|
||||
boost::any
|
||||
TypeHandlerTimestamp::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToTimestamp(prm, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerChar::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToString(colType, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerVarchar::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToString(colType, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerText::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToString(colType, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerClob::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
boost::any value = data;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerBlob::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
boost::any value = data;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerVarbinary::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
boost::any value = data;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerSDecimal64::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToSDecimal(colType, prm, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerUDecimal64::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToUDecimal(colType, prm, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerSDecimal128::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToSDecimal(colType, prm, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
TypeHandlerUDecimal128::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning) const
|
||||
{
|
||||
return dataconvert::DataConvert::StringToUDecimal(colType, prm, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
} // end of namespace datatypes
|
||||
|
@ -427,6 +427,24 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class ConvertFromStringParam
|
||||
{
|
||||
const std::string& m_timeZone;
|
||||
const bool m_noRoundup;
|
||||
const bool m_isUpdate;
|
||||
public:
|
||||
ConvertFromStringParam(const std::string& timeZone,
|
||||
bool noRoundup, bool isUpdate)
|
||||
:m_timeZone(timeZone),
|
||||
m_noRoundup(noRoundup),
|
||||
m_isUpdate(isUpdate)
|
||||
{ }
|
||||
const std::string& timeZone() const { return m_timeZone; }
|
||||
bool noRoundup() const { return m_noRoundup; }
|
||||
bool isUpdate() const { return m_isUpdate; }
|
||||
};
|
||||
|
||||
|
||||
class SimpleValue
|
||||
{
|
||||
int64_t m_sint64;
|
||||
@ -855,6 +873,11 @@ public:
|
||||
}
|
||||
virtual boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const = 0;
|
||||
|
||||
virtual boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -913,6 +936,10 @@ class TypeHandlerBit: public TypeHandler
|
||||
//TODO: How to communicate with write engine?
|
||||
return boost::any();
|
||||
}
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -980,6 +1007,10 @@ public:
|
||||
const char *str, round_style_t & rf) const override;
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1032,6 +1063,10 @@ public:
|
||||
const char *str, round_style_t & rf) const override;
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1086,6 +1121,10 @@ class TypeHandlerSInt24: public TypeHandlerInt
|
||||
const char *str, round_style_t & rf) const override;
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1140,6 +1179,10 @@ class TypeHandlerSInt32: public TypeHandlerInt
|
||||
const char *str, round_style_t & rf) const override;
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1191,6 +1234,10 @@ class TypeHandlerSInt64: public TypeHandlerInt
|
||||
const char *str, round_style_t & rf) const override;
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1269,6 +1316,10 @@ class TypeHandlerUInt8: public TypeHandlerInt
|
||||
}
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1346,6 +1397,10 @@ class TypeHandlerUInt16: public TypeHandlerInt
|
||||
}
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1426,6 +1481,10 @@ class TypeHandlerUInt24: public TypeHandlerInt
|
||||
}
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1506,6 +1565,10 @@ class TypeHandlerUInt32: public TypeHandlerInt
|
||||
}
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1583,6 +1646,10 @@ class TypeHandlerUInt64: public TypeHandlerInt
|
||||
}
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1719,6 +1786,10 @@ public:
|
||||
{
|
||||
return part.isSuitableSInt64(startVal, rfMin, endVal, rfMax);
|
||||
}
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1795,6 +1866,10 @@ public:
|
||||
{
|
||||
return part.isSuitableSInt64(startVal, rfMin, endVal, rfMax);
|
||||
}
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1873,6 +1948,10 @@ public:
|
||||
{
|
||||
return part.isSuitableSInt128(startVal, rfMin, endVal, rfMax);
|
||||
}
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -1947,6 +2026,10 @@ public:
|
||||
{
|
||||
return part.isSuitableSInt128(startVal, rfMin, endVal, rfMax);
|
||||
}
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2002,6 +2085,10 @@ class TypeHandlerSFloat: public TypeHandlerReal
|
||||
}
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2032,6 +2119,10 @@ class TypeHandlerSDouble: public TypeHandlerReal
|
||||
}
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2062,6 +2153,10 @@ class TypeHandlerUFloat: public TypeHandlerReal
|
||||
}
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2092,6 +2187,10 @@ class TypeHandlerUDouble: public TypeHandlerReal
|
||||
}
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2124,6 +2223,14 @@ class TypeHandlerSLongDouble: public TypeHandlerReal
|
||||
// QQ: DDLPackageProcessor::getNullValueForType() did not handle LONGDOUBLE
|
||||
return boost::any();
|
||||
}
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override
|
||||
{
|
||||
throw logging::QueryDataExcept("convertColumnData: unknown column data type.", logging::dataTypeErr);
|
||||
return boost::any();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2170,6 +2277,10 @@ class TypeHandlerDate: public TypeHandlerTemporal
|
||||
const char *str, round_style_t & rf) const override;
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2200,6 +2311,10 @@ class TypeHandlerDatetime: public TypeHandlerTemporal
|
||||
const char *str, round_style_t & rf) const override;
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2230,6 +2345,10 @@ class TypeHandlerTime: public TypeHandlerTemporal
|
||||
const char *str, round_style_t & rf) const override;
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2260,6 +2379,10 @@ class TypeHandlerTimestamp: public TypeHandlerTemporal
|
||||
const char *str, round_style_t & rf) const override;
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2334,6 +2457,10 @@ class TypeHandlerChar: public TypeHandlerStr
|
||||
int *state) const override;
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2380,6 +2507,10 @@ class TypeHandlerVarchar: public TypeHandlerStr
|
||||
{
|
||||
return getNullValueForTypeVarcharText(attr);
|
||||
}
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2403,6 +2534,10 @@ class TypeHandlerVarbinary: public TypeHandlerStr
|
||||
const SystemCatalog::TypeAttributesStd &attr) const override;
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2432,6 +2567,10 @@ class TypeHandlerBlob: public TypeHandlerStr
|
||||
}
|
||||
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
|
||||
const override;
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2464,6 +2603,10 @@ class TypeHandlerText: public TypeHandlerStr
|
||||
{
|
||||
return getNullValueForTypeVarcharText(attr);
|
||||
}
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -2498,6 +2641,10 @@ class TypeHandlerClob: public TypeHandlerStr
|
||||
{
|
||||
return boost::any(); // QQ
|
||||
}
|
||||
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||
const ConvertFromStringParam& prm,
|
||||
const std::string& str,
|
||||
bool& pushWarning) const override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -6146,16 +6146,23 @@ const string CalpontSystemCatalog::ColType::toString() const
|
||||
|
||||
|
||||
boost::any
|
||||
CalpontSystemCatalog::ColType::convertColumnData(const std::string& dataOrig,
|
||||
bool& bSaturate,
|
||||
CalpontSystemCatalog::ColType::convertColumnData(const std::string& data,
|
||||
bool& pushWarning,
|
||||
const std::string& timeZone,
|
||||
bool nulFlag,
|
||||
bool noRoundup,
|
||||
bool isUpdate) const
|
||||
{
|
||||
return dataconvert::DataConvert::convertColumnData(colDataType, *this,
|
||||
dataOrig, bSaturate, timeZone,
|
||||
nulFlag, noRoundup, isUpdate);
|
||||
pushWarning = false;
|
||||
const datatypes::TypeHandler *h= typeHandler();
|
||||
if (!h)
|
||||
throw QueryDataExcept("convertColumnData: unknown column data type.", dataTypeErr);
|
||||
|
||||
if (nulFlag)
|
||||
return h->getNullValueForType(*this);
|
||||
|
||||
const datatypes::ConvertFromStringParam prm(timeZone, noRoundup, isUpdate);
|
||||
return h->convertFromString(*this, prm, data, pushWarning);
|
||||
}
|
||||
|
||||
|
||||
|
@ -243,7 +243,17 @@ public:
|
||||
b >> charsetNumber;
|
||||
}
|
||||
|
||||
boost::any convertColumnData(const std::string& dataOrig,
|
||||
/**
|
||||
* @brief convert a columns data, represnted as a string,
|
||||
* to its native format
|
||||
* @param data - the string representation
|
||||
* @param [OUT] bSaturate - the value was truncated/adjusted
|
||||
* @param timeZone - the time zone name, for TIMESTAMP conversion
|
||||
* @param nullFlag - SQL NULL flag
|
||||
* @param nRoundtrip
|
||||
* @param isUpdate
|
||||
*/
|
||||
boost::any convertColumnData(const std::string& data,
|
||||
bool& bSaturate,
|
||||
const std::string& timeZone,
|
||||
bool nulFlag = false,
|
||||
|
@ -1372,452 +1372,426 @@ void DataConvert::decimalToString(int128_t* dec,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
DataConvert::convertColumnData(cscDataType typeCode,
|
||||
const datatypes::SystemCatalog::TypeAttributesStd& colType,
|
||||
const std::string& dataOrig, bool& pushWarning,
|
||||
const std::string& timeZone, bool nulFlag,
|
||||
bool noRoundup, bool isUpdate)
|
||||
DataConvert::StringToBit(const datatypes::SystemCatalog::TypeAttributesStd& colType,
|
||||
const datatypes::ConvertFromStringParam &prm,
|
||||
const std::string& dataOrig,
|
||||
bool& pushWarning)
|
||||
{
|
||||
boost::any value;
|
||||
int64_t val64;
|
||||
// WIP
|
||||
std::string data( dataOrig );
|
||||
pushWarning = false;
|
||||
std::string data(dataOrig);
|
||||
unsigned int x = data.find("(");
|
||||
|
||||
//if ( !data.empty() )
|
||||
if (!nulFlag)
|
||||
if (x <= data.length())
|
||||
{
|
||||
switch (typeCode)
|
||||
data.replace ( x, 1, " ");
|
||||
}
|
||||
|
||||
x = data.find(")");
|
||||
|
||||
if (x <= data.length())
|
||||
{
|
||||
data.replace (x, 1, " ");
|
||||
}
|
||||
|
||||
int64_t tmp = 0;
|
||||
|
||||
number_int_value (data, datatypes::SystemCatalog::BIT, colType, pushWarning, prm.noRoundup(), tmp);
|
||||
|
||||
if (tmp)
|
||||
{
|
||||
bool bitvalue;
|
||||
|
||||
if (from_string<bool>(bitvalue, data, std::dec ))
|
||||
{
|
||||
case datatypes::SystemCatalog::BIT:
|
||||
{
|
||||
unsigned int x = data.find("(");
|
||||
|
||||
if (x <= data.length())
|
||||
{
|
||||
data.replace ( x, 1, " ");
|
||||
}
|
||||
|
||||
x = data.find(")");
|
||||
|
||||
if (x <= data.length())
|
||||
{
|
||||
data.replace (x, 1, " ");
|
||||
}
|
||||
|
||||
int64_t tmp = 0;
|
||||
|
||||
number_int_value (data, typeCode, colType, pushWarning, noRoundup, tmp);
|
||||
|
||||
if (tmp)
|
||||
{
|
||||
bool bitvalue;
|
||||
|
||||
if (from_string<bool>(bitvalue, data, std::dec ))
|
||||
{
|
||||
value = bitvalue;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw QueryDataExcept("range, valid value or conversion error on BIT type.", formatErr);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::TINYINT:
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val64);
|
||||
value = (char) val64;
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::SMALLINT:
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val64);
|
||||
value = (short) val64;
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::MEDINT:
|
||||
case datatypes::SystemCatalog::INT:
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val64);
|
||||
value = (int) val64;
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::BIGINT:
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val64);
|
||||
value = (long long) val64;
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::DECIMAL:
|
||||
if (LIKELY(colType.colWidth == 16))
|
||||
{
|
||||
int128_t val128;
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val128);
|
||||
value = (int128_t) val128;
|
||||
}
|
||||
else if (colType.colWidth == 8)
|
||||
{
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val64);
|
||||
value = (long long) val64;
|
||||
}
|
||||
else if (colType.colWidth == 4)
|
||||
{
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val64);
|
||||
value = (int) val64;
|
||||
}
|
||||
else if (colType.colWidth == 2)
|
||||
{
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val64);
|
||||
value = (short) val64;
|
||||
}
|
||||
else if (colType.colWidth == 1)
|
||||
{
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val64);
|
||||
value = (char) val64;
|
||||
}
|
||||
//else if (colType.colWidth == 32)
|
||||
// value = data;
|
||||
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::UDECIMAL:
|
||||
|
||||
// UDECIMAL numbers may not be negative
|
||||
if (LIKELY(colType.colWidth == 16))
|
||||
{
|
||||
int128_t val128;
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val128);
|
||||
|
||||
if (val128 < 0 &&
|
||||
!datatypes::Decimal::isWideDecimalNullValue(val128) &&
|
||||
!datatypes::Decimal::isWideDecimalEmptyValue(val128))
|
||||
{
|
||||
val128 = 0;
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
value = val128;
|
||||
}
|
||||
else if (colType.colWidth == 8)
|
||||
{
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val64);
|
||||
long long ival = static_cast<long long>(val64);
|
||||
|
||||
if (ival < 0 &&
|
||||
ival != static_cast<long long>(joblist::BIGINTEMPTYROW) &&
|
||||
ival != static_cast<long long>(joblist::BIGINTNULL))
|
||||
{
|
||||
ival = 0;
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
value = ival;
|
||||
}
|
||||
else if (colType.colWidth == 4)
|
||||
{
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val64);
|
||||
int ival = static_cast<int>(val64);
|
||||
|
||||
if (ival < 0 &&
|
||||
ival != static_cast<int>(joblist::INTEMPTYROW) &&
|
||||
ival != static_cast<int>(joblist::INTNULL))
|
||||
{
|
||||
ival = 0;
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
value = ival;
|
||||
}
|
||||
else if (colType.colWidth == 2)
|
||||
{
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val64);
|
||||
short ival = (short) val64;
|
||||
|
||||
if (ival < 0 &&
|
||||
ival != static_cast<int16_t>(joblist::SMALLINTEMPTYROW) &&
|
||||
ival != static_cast<int16_t>(joblist::SMALLINTNULL))
|
||||
{
|
||||
ival = 0;
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
value = ival;
|
||||
}
|
||||
else if (colType.colWidth == 1)
|
||||
{
|
||||
number_int_value(data, typeCode, colType, pushWarning, noRoundup, val64);
|
||||
char ival = (char) val64;
|
||||
|
||||
if (ival < 0 &&
|
||||
ival != static_cast<int8_t>(joblist::TINYINTEMPTYROW) &&
|
||||
ival != static_cast<int8_t>(joblist::TINYINTNULL))
|
||||
{
|
||||
ival = 0;
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
value = ival;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::FLOAT:
|
||||
case datatypes::SystemCatalog::UFLOAT:
|
||||
{
|
||||
string::size_type x = data.find('(');
|
||||
|
||||
if (x < string::npos)
|
||||
data.erase(x, 1);
|
||||
|
||||
x = data.find(')');
|
||||
|
||||
if (x < string::npos)
|
||||
data.erase(x, 1);
|
||||
|
||||
if ( number_value ( data ) )
|
||||
{
|
||||
float floatvalue;
|
||||
errno = 0;
|
||||
#ifdef _MSC_VER
|
||||
double dval = strtod(data.c_str(), 0);
|
||||
|
||||
if (dval > MAX_FLOAT)
|
||||
{
|
||||
pushWarning = true;
|
||||
floatvalue = MAX_FLOAT;
|
||||
}
|
||||
else if (dval < MIN_FLOAT)
|
||||
{
|
||||
pushWarning = true;
|
||||
floatvalue = MIN_FLOAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
floatvalue = (float)dval;
|
||||
}
|
||||
|
||||
#else
|
||||
floatvalue = strtof(data.c_str(), 0);
|
||||
#endif
|
||||
|
||||
if (errno == ERANGE)
|
||||
{
|
||||
pushWarning = true;
|
||||
#ifdef _MSC_VER
|
||||
|
||||
if ( abs(floatvalue) == HUGE_VAL )
|
||||
#else
|
||||
if ( abs(floatvalue) == HUGE_VALF )
|
||||
#endif
|
||||
{
|
||||
if ( floatvalue > 0 )
|
||||
floatvalue = MAX_FLOAT;
|
||||
else
|
||||
floatvalue = MIN_FLOAT;
|
||||
}
|
||||
else
|
||||
floatvalue = 0;
|
||||
}
|
||||
|
||||
if (floatvalue < 0.0 &&
|
||||
typeCode == datatypes::SystemCatalog::UFLOAT &&
|
||||
floatvalue != joblist::FLOATEMPTYROW &&
|
||||
floatvalue != joblist::FLOATNULL)
|
||||
{
|
||||
value = 0.0;
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
value = floatvalue;
|
||||
}
|
||||
else
|
||||
throw QueryDataExcept("range, valid value or conversion error on FLOAT type.", formatErr);
|
||||
}
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::DOUBLE:
|
||||
case datatypes::SystemCatalog::UDOUBLE:
|
||||
{
|
||||
string::size_type x = data.find('(');
|
||||
|
||||
if (x < string::npos)
|
||||
data.erase(x, 1);
|
||||
|
||||
x = data.find(')');
|
||||
|
||||
if (x < string::npos)
|
||||
data.erase(x, 1);
|
||||
|
||||
if ( number_value ( data ) )
|
||||
{
|
||||
double doublevalue;
|
||||
errno = 0;
|
||||
doublevalue = strtod(data.c_str(), 0);
|
||||
|
||||
if (errno == ERANGE)
|
||||
{
|
||||
pushWarning = true;
|
||||
#ifdef _MSC_VER
|
||||
|
||||
if ( abs(doublevalue) == HUGE_VAL )
|
||||
#else
|
||||
if ( abs(doublevalue) == HUGE_VALL )
|
||||
#endif
|
||||
{
|
||||
if ( doublevalue > 0 )
|
||||
value = MAX_DOUBLE;
|
||||
else
|
||||
value = MIN_DOUBLE;
|
||||
}
|
||||
else
|
||||
value = 0;
|
||||
}
|
||||
else
|
||||
value = doublevalue;
|
||||
|
||||
if (doublevalue < 0.0 &&
|
||||
typeCode == datatypes::SystemCatalog::UDOUBLE &&
|
||||
doublevalue != joblist::DOUBLEEMPTYROW &&
|
||||
doublevalue != joblist::DOUBLENULL)
|
||||
{
|
||||
doublevalue = 0.0;
|
||||
pushWarning = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw QueryDataExcept("range, valid value or conversion error on DOUBLE type.", formatErr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::UTINYINT:
|
||||
value = (uint8_t)number_uint_value(data, typeCode, colType, pushWarning, noRoundup);
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::USMALLINT:
|
||||
value = (uint16_t)number_uint_value(data, typeCode, colType, pushWarning, noRoundup);
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::UMEDINT:
|
||||
case datatypes::SystemCatalog::UINT:
|
||||
value = (uint32_t)number_uint_value(data, typeCode, colType, pushWarning, noRoundup);
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::UBIGINT:
|
||||
value = (uint64_t)number_uint_value(data, typeCode, colType, pushWarning, noRoundup);
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::CHAR:
|
||||
case datatypes::SystemCatalog::VARCHAR:
|
||||
case datatypes::SystemCatalog::TEXT:
|
||||
{
|
||||
//check data length
|
||||
if ( data.length() > (unsigned int)colType.colWidth )
|
||||
{
|
||||
data = data.substr(0, colType.colWidth);
|
||||
pushWarning = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (unsigned int)colType.colWidth > data.length())
|
||||
{
|
||||
//Pad null character to the string
|
||||
data.resize(colType.colWidth, 0);
|
||||
}
|
||||
}
|
||||
|
||||
value = data;
|
||||
}
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::DATE:
|
||||
{
|
||||
Date aDay;
|
||||
|
||||
if (stringToDateStruct(data, aDay))
|
||||
{
|
||||
value = (*(reinterpret_cast<uint32_t*> (&aDay)));
|
||||
}
|
||||
else
|
||||
{
|
||||
value = (uint32_t) 0;
|
||||
pushWarning = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::DATETIME:
|
||||
{
|
||||
DateTime aDatetime;
|
||||
|
||||
if (stringToDatetimeStruct(data, aDatetime, 0))
|
||||
{
|
||||
value = *(reinterpret_cast<uint64_t*>(&aDatetime));
|
||||
}
|
||||
else
|
||||
{
|
||||
value = (uint64_t) 0;
|
||||
pushWarning = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::TIME:
|
||||
{
|
||||
Time aTime;
|
||||
|
||||
if (!stringToTimeStruct(data, aTime, colType.precision))
|
||||
{
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
value = (int64_t) * (reinterpret_cast<int64_t*>(&aTime));
|
||||
}
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::TIMESTAMP:
|
||||
{
|
||||
TimeStamp aTimestamp;
|
||||
|
||||
if (!stringToTimestampStruct(data, aTimestamp, timeZone))
|
||||
{
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
value = (uint64_t) *(reinterpret_cast<uint64_t*>(&aTimestamp));
|
||||
}
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::BLOB:
|
||||
case datatypes::SystemCatalog::CLOB:
|
||||
value = data;
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::VARBINARY:
|
||||
value = data;
|
||||
break;
|
||||
|
||||
case datatypes::SystemCatalog::BINARY:
|
||||
value = data;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw QueryDataExcept("convertColumnData: unknown column data type.", dataTypeErr);
|
||||
break;
|
||||
boost::any value = bitvalue;
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw QueryDataExcept("range, valid value or conversion error on BIT type.", formatErr);
|
||||
}
|
||||
}
|
||||
else //null
|
||||
{
|
||||
const datatypes::TypeHandler *h= datatypes::TypeHandler::find(typeCode, colType);
|
||||
if (!h)
|
||||
throw QueryDataExcept("convertColumnData: unknown column data type.", dataTypeErr);
|
||||
else
|
||||
return h->getNullValueForType(colType);
|
||||
}
|
||||
return boost::any();
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
DataConvert::StringToSDecimal(const datatypes::SystemCatalog::TypeAttributesStd& colType,
|
||||
const datatypes::ConvertFromStringParam &prm,
|
||||
const std::string& data, bool& pushWarning)
|
||||
{
|
||||
const cscDataType typeCode= datatypes::SystemCatalog::DECIMAL;
|
||||
if (LIKELY(colType.colWidth == 16))
|
||||
{
|
||||
int128_t val128;
|
||||
number_int_value(data, typeCode, colType, pushWarning, prm.noRoundup(), val128);
|
||||
boost::any value = (int128_t) val128;
|
||||
return value;
|
||||
}
|
||||
else if (colType.colWidth == 8)
|
||||
{
|
||||
int64_t val64;
|
||||
number_int_value(data, typeCode, colType, pushWarning, prm.noRoundup(), val64);
|
||||
boost::any value = (long long) val64;
|
||||
return value;
|
||||
}
|
||||
else if (colType.colWidth == 4)
|
||||
{
|
||||
int64_t val64;
|
||||
number_int_value(data, typeCode, colType, pushWarning, prm.noRoundup(), val64);
|
||||
boost::any value = (int) val64;
|
||||
return value;
|
||||
}
|
||||
else if (colType.colWidth == 2)
|
||||
{
|
||||
int64_t val64;
|
||||
number_int_value(data, typeCode, colType, pushWarning, prm.noRoundup(), val64);
|
||||
boost::any value = (short) val64;
|
||||
return value;
|
||||
}
|
||||
else if (colType.colWidth == 1)
|
||||
{
|
||||
int64_t val64;
|
||||
number_int_value(data, typeCode, colType, pushWarning, prm.noRoundup(), val64);
|
||||
boost::any value = (char) val64;
|
||||
return value;
|
||||
}
|
||||
//else if (colType.colWidth == 32)
|
||||
// value = data;
|
||||
return boost::any();
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
DataConvert::StringToUDecimal(const datatypes::SystemCatalog::TypeAttributesStd& colType,
|
||||
const datatypes::ConvertFromStringParam &prm,
|
||||
const std::string& data, bool& pushWarning)
|
||||
{
|
||||
const cscDataType typeCode= datatypes::SystemCatalog::UDECIMAL;
|
||||
|
||||
// UDECIMAL numbers may not be negative
|
||||
if (LIKELY(colType.colWidth == 16))
|
||||
{
|
||||
int128_t val128;
|
||||
number_int_value(data, typeCode, colType, pushWarning, prm.noRoundup(), val128);
|
||||
|
||||
if (val128 < 0 &&
|
||||
!datatypes::Decimal::isWideDecimalNullValue(val128) &&
|
||||
!datatypes::Decimal::isWideDecimalEmptyValue(val128))
|
||||
{
|
||||
val128 = 0;
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
boost::any value = val128;
|
||||
return value;
|
||||
}
|
||||
else if (colType.colWidth == 8)
|
||||
{
|
||||
int64_t val64;
|
||||
number_int_value(data, typeCode, colType, pushWarning, prm.noRoundup(), val64);
|
||||
long long ival = static_cast<long long>(val64);
|
||||
|
||||
if (ival < 0 &&
|
||||
ival != static_cast<long long>(joblist::BIGINTEMPTYROW) &&
|
||||
ival != static_cast<long long>(joblist::BIGINTNULL))
|
||||
{
|
||||
ival = 0;
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
boost::any value = ival;
|
||||
return value;
|
||||
}
|
||||
else if (colType.colWidth == 4)
|
||||
{
|
||||
int64_t val64;
|
||||
number_int_value(data, typeCode, colType, pushWarning, prm.noRoundup(), val64);
|
||||
int ival = static_cast<int>(val64);
|
||||
|
||||
if (ival < 0 &&
|
||||
ival != static_cast<int>(joblist::INTEMPTYROW) &&
|
||||
ival != static_cast<int>(joblist::INTNULL))
|
||||
{
|
||||
ival = 0;
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
boost::any value = ival;
|
||||
return value;
|
||||
}
|
||||
else if (colType.colWidth == 2)
|
||||
{
|
||||
int64_t val64;
|
||||
number_int_value(data, typeCode, colType, pushWarning, prm.noRoundup(), val64);
|
||||
short ival = (short) val64;
|
||||
|
||||
if (ival < 0 &&
|
||||
ival != static_cast<int16_t>(joblist::SMALLINTEMPTYROW) &&
|
||||
ival != static_cast<int16_t>(joblist::SMALLINTNULL))
|
||||
{
|
||||
ival = 0;
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
boost::any value = ival;
|
||||
return value;
|
||||
}
|
||||
else if (colType.colWidth == 1)
|
||||
{
|
||||
int64_t val64;
|
||||
number_int_value(data, typeCode, colType, pushWarning, prm.noRoundup(), val64);
|
||||
char ival = (char) val64;
|
||||
|
||||
if (ival < 0 &&
|
||||
ival != static_cast<int8_t>(joblist::TINYINTEMPTYROW) &&
|
||||
ival != static_cast<int8_t>(joblist::TINYINTNULL))
|
||||
{
|
||||
ival = 0;
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
boost::any value = ival;
|
||||
return value;
|
||||
}
|
||||
return boost::any();
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
DataConvert::StringToFloat(cscDataType typeCode,
|
||||
const std::string& dataOrig,
|
||||
bool& pushWarning)
|
||||
{
|
||||
boost::any value;
|
||||
std::string data(dataOrig);
|
||||
|
||||
string::size_type x = data.find('(');
|
||||
|
||||
if (x < string::npos)
|
||||
data.erase(x, 1);
|
||||
|
||||
x = data.find(')');
|
||||
|
||||
if (x < string::npos)
|
||||
data.erase(x, 1);
|
||||
|
||||
if ( number_value ( data ) )
|
||||
{
|
||||
float floatvalue;
|
||||
errno = 0;
|
||||
#ifdef _MSC_VER
|
||||
double dval = strtod(data.c_str(), 0);
|
||||
|
||||
if (dval > MAX_FLOAT)
|
||||
{
|
||||
pushWarning = true;
|
||||
floatvalue = MAX_FLOAT;
|
||||
}
|
||||
else if (dval < MIN_FLOAT)
|
||||
{
|
||||
pushWarning = true;
|
||||
floatvalue = MIN_FLOAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
floatvalue = (float)dval;
|
||||
}
|
||||
#else
|
||||
floatvalue = strtof(data.c_str(), 0);
|
||||
#endif
|
||||
|
||||
if (errno == ERANGE)
|
||||
{
|
||||
pushWarning = true;
|
||||
#ifdef _MSC_VER
|
||||
|
||||
if ( abs(floatvalue) == HUGE_VAL )
|
||||
#else
|
||||
if ( abs(floatvalue) == HUGE_VALF )
|
||||
#endif
|
||||
{
|
||||
if ( floatvalue > 0 )
|
||||
floatvalue = MAX_FLOAT;
|
||||
else
|
||||
floatvalue = MIN_FLOAT;
|
||||
}
|
||||
else
|
||||
floatvalue = 0;
|
||||
}
|
||||
|
||||
if (floatvalue < 0.0 &&
|
||||
typeCode == datatypes::SystemCatalog::UFLOAT &&
|
||||
floatvalue != joblist::FLOATEMPTYROW &&
|
||||
floatvalue != joblist::FLOATNULL)
|
||||
{
|
||||
value = 0.0; // QQ: should it assign floatvalue?
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
value = floatvalue;
|
||||
}
|
||||
else
|
||||
throw QueryDataExcept("range, valid value or conversion error on FLOAT type.", formatErr);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
boost::any
|
||||
DataConvert::StringToDouble(cscDataType typeCode,
|
||||
const std::string& dataOrig,
|
||||
bool& pushWarning)
|
||||
{
|
||||
boost::any value;
|
||||
std::string data(dataOrig);
|
||||
|
||||
string::size_type x = data.find('(');
|
||||
|
||||
if (x < string::npos)
|
||||
data.erase(x, 1);
|
||||
|
||||
x = data.find(')');
|
||||
|
||||
if (x < string::npos)
|
||||
data.erase(x, 1);
|
||||
|
||||
if ( number_value ( data ) )
|
||||
{
|
||||
double doublevalue;
|
||||
errno = 0;
|
||||
doublevalue = strtod(data.c_str(), 0);
|
||||
|
||||
if (errno == ERANGE)
|
||||
{
|
||||
pushWarning = true;
|
||||
#ifdef _MSC_VER
|
||||
|
||||
if ( abs(doublevalue) == HUGE_VAL )
|
||||
#else
|
||||
if ( abs(doublevalue) == HUGE_VALL )
|
||||
#endif
|
||||
{
|
||||
if ( doublevalue > 0 )
|
||||
value = MAX_DOUBLE;
|
||||
else
|
||||
value = MIN_DOUBLE;
|
||||
}
|
||||
else
|
||||
value = 0;
|
||||
}
|
||||
else
|
||||
value = doublevalue;
|
||||
|
||||
if (doublevalue < 0.0 &&
|
||||
typeCode == datatypes::SystemCatalog::UDOUBLE &&
|
||||
doublevalue != joblist::DOUBLEEMPTYROW &&
|
||||
doublevalue != joblist::DOUBLENULL)
|
||||
{
|
||||
doublevalue = 0.0; // QQ: should it assign "value" ?
|
||||
pushWarning = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw QueryDataExcept("range, valid value or conversion error on DOUBLE type.", formatErr);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
DataConvert::StringToString(const datatypes::SystemCatalog::TypeAttributesStd& colType,
|
||||
const std::string& dataOrig,
|
||||
bool& pushWarning)
|
||||
|
||||
{
|
||||
std::string data(dataOrig);
|
||||
//check data length
|
||||
if ( data.length() > (unsigned int)colType.colWidth )
|
||||
{
|
||||
data = data.substr(0, colType.colWidth);
|
||||
pushWarning = true;
|
||||
boost::any value = data;
|
||||
return value;
|
||||
}
|
||||
if ( (unsigned int)colType.colWidth > data.length())
|
||||
{
|
||||
//Pad null character to the string
|
||||
data.resize(colType.colWidth, 0);
|
||||
}
|
||||
boost::any value = data;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
DataConvert::StringToDate(const std::string& data, bool& pushWarning)
|
||||
{
|
||||
Date aDay;
|
||||
|
||||
if (stringToDateStruct(data, aDay))
|
||||
{
|
||||
boost::any value = (*(reinterpret_cast<uint32_t*> (&aDay)));
|
||||
return value;
|
||||
}
|
||||
boost::any value = (uint32_t) 0;
|
||||
pushWarning = true;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
DataConvert::StringToDatetime(const std::string& data, bool& pushWarning)
|
||||
{
|
||||
DateTime aDatetime;
|
||||
|
||||
if (stringToDatetimeStruct(data, aDatetime, 0)) // QQ: why 0?
|
||||
{
|
||||
boost::any value = *(reinterpret_cast<uint64_t*>(&aDatetime));
|
||||
return value;
|
||||
}
|
||||
boost::any value = (uint64_t) 0;
|
||||
pushWarning = true;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
DataConvert::StringToTime(const datatypes::SystemCatalog::TypeAttributesStd& colType,
|
||||
const std::string& data,
|
||||
bool& pushWarning)
|
||||
{
|
||||
Time aTime;
|
||||
|
||||
if (!stringToTimeStruct(data, aTime, colType.precision))
|
||||
{
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
boost::any value = (int64_t) * (reinterpret_cast<int64_t*>(&aTime));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
boost::any
|
||||
DataConvert::StringToTimestamp(const datatypes::ConvertFromStringParam &prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning)
|
||||
{
|
||||
TimeStamp aTimestamp;
|
||||
|
||||
if (!stringToTimestampStruct(data, aTimestamp, prm.timeZone()))
|
||||
{
|
||||
pushWarning = true;
|
||||
}
|
||||
|
||||
boost::any value = (uint64_t) *(reinterpret_cast<uint64_t*>(&aTimestamp));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Convert date string to binary date. Used by BulkLoad.
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -884,25 +884,18 @@ void number_int_value(const std::string& data,
|
||||
bool noRoundup,
|
||||
T& intVal);
|
||||
|
||||
uint64_t number_uint_value(const string& data,
|
||||
cscDataType typeCode,
|
||||
const datatypes::SystemCatalog::TypeAttributesStd& ct,
|
||||
bool& pushwarning,
|
||||
bool noRoundup);
|
||||
|
||||
/** @brief DataConvert is a component for converting string data to Calpont format
|
||||
*/
|
||||
class DataConvert
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief convert a columns data, represnted as a string, to it's native
|
||||
* format
|
||||
*
|
||||
* @param type the columns data type
|
||||
* @param data the columns string representation of it's data
|
||||
*/
|
||||
EXPORT static boost::any convertColumnData(
|
||||
cscDataType typecode,
|
||||
const datatypes::SystemCatalog::TypeAttributesStd& attr,
|
||||
const std::string& dataOrig, bool& bSaturate, const std::string& timeZone,
|
||||
bool nulFlag = false, bool noRoundup = false, bool isUpdate = false);
|
||||
|
||||
/**
|
||||
* @brief convert a columns data from native format to a string
|
||||
*
|
||||
@ -1082,6 +1075,47 @@ public:
|
||||
// bug4388, union type conversion
|
||||
EXPORT static void joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd &unionedType,
|
||||
const datatypes::SystemCatalog::TypeHolderStd &type);
|
||||
|
||||
static boost::any StringToBit(const datatypes::SystemCatalog::TypeAttributesStd& colType,
|
||||
const datatypes::ConvertFromStringParam &prm,
|
||||
const std::string& dataOrig,
|
||||
bool& pushWarning);
|
||||
|
||||
static boost::any StringToSDecimal(const datatypes::SystemCatalog::TypeAttributesStd& colType,
|
||||
const datatypes::ConvertFromStringParam &prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning);
|
||||
|
||||
static boost::any StringToUDecimal(const datatypes::SystemCatalog::TypeAttributesStd& colType,
|
||||
const datatypes::ConvertFromStringParam &prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning);
|
||||
|
||||
static boost::any StringToFloat(cscDataType typeCode,
|
||||
const std::string& dataOrig,
|
||||
bool& pushWarning);
|
||||
|
||||
static boost::any StringToDouble(cscDataType typeCode,
|
||||
const std::string& dataOrig,
|
||||
bool& pushWarning);
|
||||
|
||||
static boost::any StringToString(const datatypes::SystemCatalog::TypeAttributesStd& colType,
|
||||
const std::string& dataOrig,
|
||||
bool& pushWarning);
|
||||
|
||||
static boost::any StringToDate(const std::string& data,
|
||||
bool& pushWarning);
|
||||
|
||||
static boost::any StringToDatetime(const std::string& data,
|
||||
bool& pushWarning);
|
||||
|
||||
static boost::any StringToTime(const datatypes::SystemCatalog::TypeAttributesStd& colType,
|
||||
const std::string& data,
|
||||
bool& pushWarning);
|
||||
|
||||
static boost::any StringToTimestamp(const datatypes::ConvertFromStringParam &prm,
|
||||
const std::string& data,
|
||||
bool& pushWarning);
|
||||
};
|
||||
|
||||
inline void DataConvert::dateToString( int datevalue, char* buf, unsigned int buflen)
|
||||
|
Reference in New Issue
Block a user