You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
Merge pull request #1614 from drrtuy/fix_UTs
Fixes for Decimal multiplication overflow check and RowGroup UTs
This commit is contained in:
@ -735,6 +735,4 @@ namespace datatypes
|
||||
os << dec.toString();
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
} // end of namespace
|
||||
|
@ -386,28 +386,26 @@ struct DivisionOverflowCheck {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@brief The structure contains an overflow check for int128
|
||||
and int64_t multiplication.
|
||||
*/
|
||||
//
|
||||
// @brief The structure contains an overflow check for int128
|
||||
// and int64_t multiplication.
|
||||
//
|
||||
struct MultiplicationOverflowCheck {
|
||||
void operator()(const int128_t& x, const int128_t& y)
|
||||
{
|
||||
if (x * y / y != x)
|
||||
{
|
||||
throw logging::OperationOverflowExcept(
|
||||
"Decimal::multiplication<int128_t> or scale multiplication \
|
||||
produces an overflow.");
|
||||
}
|
||||
int128_t tempR = 0;
|
||||
this->operator()(x, y, tempR);
|
||||
}
|
||||
bool operator()(const int128_t& x, const int128_t& y, int128_t& r)
|
||||
{
|
||||
if ((r = x * y) / y != x)
|
||||
volatile int128_t z = x * y;
|
||||
if (z / y != x)
|
||||
{
|
||||
throw logging::OperationOverflowExcept(
|
||||
"Decimal::multiplication<int128_t> or scale multiplication \
|
||||
produces an overflow.");
|
||||
}
|
||||
r = z;
|
||||
return true;
|
||||
}
|
||||
void operator()(const int64_t x, const int64_t y)
|
||||
@ -838,6 +836,7 @@ class VDecimal: public TSInt128
|
||||
// STRICTLY for unit tests!!!
|
||||
void setTSInt64Value(const int64_t x) { value = x; }
|
||||
void setTSInt128Value(const int128_t& x) { s128Value = x; }
|
||||
void setScale(const uint8_t x) { scale = x; }
|
||||
|
||||
private:
|
||||
uint8_t writeIntPart(const int128_t& x,
|
||||
|
Reference in New Issue
Block a user