New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coprocessor, dag: support decode Time from tipb.Expr #2199

Merged
merged 43 commits into from Aug 28, 2017
Commits
Jump to file or symbol
Failed to load files and symbols.
+20 −4
Diff settings

Always

Just for now

Viewing a subset of changes. View all

fix

  • Loading branch information...
hicqu committed Aug 23, 2017
commit 87a9cd557b27db61cf377405803acc80ce72ca5b
@@ -142,11 +142,16 @@ impl FnCall {
r = opp_neg!(rhs);
}
let res = try!(l.checked_mul(r).ok_or(Error::Overflow));
let us = mysql::has_unsigned_flag(self.tp.get_flag());
if a_neg != b_neg {
if (i64::MAX as u64) < res {
if us || (i64::MAX as u64 + 1 < res) {
return Err(Error::Overflow);
}
let res = try!((res as i64).checked_neg().ok_or(Error::Overflow));
let mut res = res as i64;
if res >= 0 {
// The number equals to i64::MAX as u64 + 1.
res = try!(res.checked_neg().ok_or(Error::Overflow));
}
Ok(Some(res))
} else {
Ok(Some(res as i64))
@@ -224,6 +229,12 @@ mod test {
Datum::I64(1),
Datum::I64(12),
),
(
ScalarFuncSig::MultiplyInt,
Datum::I64(i64::MIN),
Datum::I64(1),
Datum::I64(i64::MIN),
),
];
let ctx = StatementContext::default();
for tt in tests {
@@ -321,7 +332,7 @@ mod test {
}
#[test]
fn test_arithmetic_int_overflow() {
fn test_arithmetic_overflow_int() {
let tests = vec![
(
ScalarFuncSig::PlusInt,
@@ -357,6 +368,11 @@ mod test {
Datum::U64(u64::MAX),
Datum::I64(i64::MAX),
),
(
ScalarFuncSig::MultiplyInt,
Datum::I64(i64::MIN),
Datum::U64(1),
),
];
let ctx = StatementContext::default();
for tt in tests {
@@ -379,7 +395,7 @@ mod test {
}
#[test]
fn test_arithmetic_real_overflow() {
fn test_arithmetic_overflow_real() {
let tests = vec![
(
ScalarFuncSig::PlusReal,
ProTip! Use n and p to navigate between commits in a pull request.