Skip to content
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

expression:process flag overflow_as_warning #2901

Merged
merged 16 commits into from
Apr 13, 2018

Conversation

AndreMouche
Copy link
Member

@AndreMouche AndreMouche commented Apr 1, 2018

  • dev

  • test

@hicqu @breeswish @XuHuaiyu PTAL

@AndreMouche AndreMouche changed the title [WIP] expression:process flag overflow_as_warning expression:process flag overflow_as_warning Apr 2, 2018
@@ -101,61 +101,72 @@ pub fn bytes_to_int_without_context(bytes: &[u8]) -> Result<i64> {
// trim
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment "Note that it does NOT handle overflow.".

vec![b"9223372036854775809", b"-9223372036854775810"];
for bs in invalid_cases {
let t = super::bytes_to_int_without_context(bs);
if !t.is_err() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you also check whether it is indeed an overflow error?

let invalid_cases: Vec<&'static [u8]> = vec![b"18446744073709551616"];
for bs in invalid_cases {
let t = super::bytes_to_uint_without_context(bs);
if !t.is_err() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

}

impl Error {
pub fn gen_overflow(data: &str, range: String) -> Error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can move these two parameters to the definition in quick_error so that Error::Overflow(data, range) will act as your Error::gen_overflow(data, range) directly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

address comments

Error::Overflow(msg)
}

pub fn gen_truncated_wrong_val(data_type: &str, val: String) -> Error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Error::Eval(msg.into(), ERR_UNKNOWN)
}

pub fn unknown_timezone(tz: i64) -> Error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing prefix gen_

@AndreMouche
Copy link
Member Author

friendly ping @XuHuaiyu @hicqu @hicqu

@breezewish
Copy link
Member

As described previously, Error::gen_overflow is no longer needed, which can be replaced by Error::Overflow(..) directly. Rest LGTM.

@AndreMouche
Copy link
Member Author

address comments @breeswish

@AndreMouche
Copy link
Member Author

@hicqu @XuHuaiyu PTAL

@@ -164,6 +177,36 @@ impl EvalContext {
Err(err)
}

/// handle_over_flow treats ErrOverflow as warnings or returns the error
/// based on the cfg.handle_over_flow state.
pub fn handle_over_flow(&mut self, err: Error) -> Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why handle_over_flow instead of handle_overflow?

orig_err: Error,
negitive: bool,
) -> Result<i64> {
if !self.cfg.in_select_stmt | !self.cfg.overflow_as_warning {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use || instead of |.

}

impl Error {
pub fn overflow(data: &str, range: String) -> Error {
Copy link
Contributor

@hicqu hicqu Apr 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer range: &str to keep in same style with data.
And I think it should be expr instead of range.

@hicqu
Copy link
Contributor

hicqu commented Apr 11, 2018

rest LGTM.

@zz-jason
Copy link
Member

@AndreMouche ci failed.

@AndreMouche
Copy link
Member Author

It's not caused by current PR @zz-jason

@AndreMouche
Copy link
Member Author

/run-integration-tests

@breezewish
Copy link
Member

LGTM

@hicqu
Copy link
Contributor

hicqu commented Apr 12, 2018

LGTM.

@AndreMouche
Copy link
Member Author

/run-integration-tests

@XuHuaiyu
Copy link
Contributor

LGTM

@AndreMouche AndreMouche merged commit 0b6c13f into tikv:master Apr 13, 2018
sticnarf pushed a commit to sticnarf/tikv that referenced this pull request Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants