1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

Fixes of bugs from ASAN warnings, part one (#2796)

This commit is contained in:
Leonid Fedorov
2023-03-30 18:29:04 +03:00
committed by GitHub
parent a1d20d82d5
commit 2f153184c3
71 changed files with 591 additions and 2038 deletions

View File

@ -48,26 +48,6 @@ using namespace logging;
namespace
{
const int64_t columnstore_precision[19] = {0,
9,
99,
999,
9999,
99999,
999999,
9999999,
99999999,
999999999,
9999999999LL,
99999999999LL,
999999999999LL,
9999999999999LL,
99999999999999LL,
999999999999999LL,
9999999999999999LL,
99999999999999999LL,
999999999999999999LL};
template <class T>
bool from_string(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&))
{
@ -475,25 +455,16 @@ void number_int_value(const string& data, cscDataType typeCode,
if ((typeCode == datatypes::SystemCatalog::DECIMAL) || (typeCode == datatypes::SystemCatalog::UDECIMAL) ||
(ct.scale > 0))
{
T rangeUp, rangeLow;
if (ct.precision < 19)
auto precision =
ct.precision == rowgroup::MagicPrecisionForCountAgg ? datatypes::INT128MAXPRECISION : ct.precision;
if (precision > datatypes::INT128MAXPRECISION || precision < 0)
{
rangeUp = (T)columnstore_precision[ct.precision];
}
else
{
auto precision =
ct.precision == rowgroup::MagicPrecisionForCountAgg ? datatypes::INT128MAXPRECISION : ct.precision;
if (precision > datatypes::INT128MAXPRECISION || precision < 0)
{
throw QueryDataExcept("Unsupported precision " + std::to_string(precision) + " converting DECIMAL ",
dataTypeErr);
}
rangeUp = datatypes::ConversionRangeMaxValue[ct.precision - 19];
throw QueryDataExcept("Unsupported precision " + std::to_string(precision) + " converting DECIMAL ",
dataTypeErr);
}
rangeLow = -rangeUp;
T rangeUp = dataconvert::decimalRangeUp<T>(precision);
T rangeLow = -rangeUp;
if (intVal > rangeUp)
{
@ -2802,7 +2773,8 @@ int64_t DataConvert::stringToTime(const string& data)
{
if (!hasDate)
{
day = strtol(data.substr(0, pos).c_str(), &end, 10);
std::string tmpDataSegment = data.substr(0, pos);
day = strtol(tmpDataSegment.c_str(), &end, 10);
if (*end != '\0')
return -1;

View File

@ -102,6 +102,7 @@ const int64_t IDB_pow[19] = {1,
100000000000000000LL,
1000000000000000000LL};
const int32_t SECS_PER_MIN = 60;
const int32_t MINS_PER_HOUR = 60;
const int32_t HOURS_PER_DAY = 24;
@ -1545,6 +1546,20 @@ inline int128_t strtoll128(const char* data, bool& saturate, char** ep)
return res;
}
template <class T>
T decimalRangeUp(int32_t precision)
{
if (precision < 19)
{
return (T)datatypes::columnstore_precision[precision];
}
else
{
return datatypes::ConversionRangeMaxValue[precision - 19];
}
}
template <>
inline int128_t string_to_ll<int128_t>(const std::string& data, bool& bSaturate)
{