fix error in judging overflow of unsigned integer multiplication
This commit is contained in:
@ -479,7 +479,8 @@ struct ObIntIntBatchMulRaw : public ObArithOpRawType<int64_t, int64_t, int64_t>
|
|||||||
static int raw_check(const int64_t, const int64_t l, const int64_t r)
|
static int raw_check(const int64_t, const int64_t l, const int64_t r)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (OB_UNLIKELY(is_multi_overflow64(l, r))) {
|
long long res;
|
||||||
|
if (OB_UNLIKELY(ObExprMul::is_mul_out_of_range(l, r, res))) {
|
||||||
char expr_str[OB_MAX_TWO_OPERATOR_EXPR_LENGTH];
|
char expr_str[OB_MAX_TWO_OPERATOR_EXPR_LENGTH];
|
||||||
ret = OB_OPERATE_OVERFLOW;
|
ret = OB_OPERATE_OVERFLOW;
|
||||||
int64_t pos = 0;
|
int64_t pos = 0;
|
||||||
|
|||||||
@ -150,22 +150,10 @@ public:
|
|||||||
}
|
}
|
||||||
OB_INLINE static bool is_uint_uint_mul_out_of_range(uint64_t val1, uint64_t val2)
|
OB_INLINE static bool is_uint_uint_mul_out_of_range(uint64_t val1, uint64_t val2)
|
||||||
{
|
{
|
||||||
int ret = false;
|
int overflow = false;
|
||||||
uint64_t tmp = val1;
|
unsigned long long res;
|
||||||
if (val1 > val2) {
|
overflow = __builtin_umulll_overflow(val1, val2, &res);
|
||||||
tmp = val1;
|
return overflow;
|
||||||
val1 = val2;
|
|
||||||
val2 = tmp;
|
|
||||||
}
|
|
||||||
if (val1 > UINT32_MAX) {
|
|
||||||
ret = true;
|
|
||||||
} else {
|
|
||||||
uint64_t c = val2 >> SHIFT_OFFSET;
|
|
||||||
uint64_t r = val1 * c;
|
|
||||||
if (r > UINT32_MAX)
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
static ObArithFunc mul_funcs_[common::ObMaxTC];
|
static ObArithFunc mul_funcs_[common::ObMaxTC];
|
||||||
|
|||||||
Reference in New Issue
Block a user