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,executor: fix DIV() as partition expression behavior under ERROR_FOR_DIVISION_BY_ZERO sql_mode (#17302) #17314

Merged
merged 3 commits into from
May 20, 2020

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented May 20, 2020

cherry-pick #17302 to release-4.0


What problem does this PR solve?

Problem Summary:

Currently, the function expression "enclosure" the session context, causing the
creating time context differ from using time context.
If the sql mode change, the behavior is incorrect.

set @@sql_mode='';
create table t1 (a int) partition by range (10 div a) (
    partition p0 values less than (10),
    partition p1 values less than maxvalue
);
insert into t1 values (NULL), (0), (1);   // No error
set @@sql_mode='STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO';
insert into t1 values (NULL), (0), (1);  // Should report Error, but TiDB doesn't.

What is changed and how it works?

What's Changed:

Implement evalIntWithCtx method for IntDIVInt function signature.

How it Works:

Use the correct session context.

Related changes

Check List

Tests

  • Unit test

Release note

  • when DIV() is used as partition expression, fix the behavior of insert operation under different sql_mode, handle ERROR_FOR_DIVISION_BY_ZERO correctly.

Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot sre-bot requested a review from a team as a code owner May 20, 2020 09:07
@sre-bot
Copy link
Contributor Author

sre-bot commented May 20, 2020

/run-all-tests

@ghost ghost requested a review from wshwsh12 May 20, 2020 09:07
@sre-bot sre-bot added sig/execution SIG execution component/expression priority/release-blocker This issue blocks a release. Please solve it ASAP. type/4.0-cherry-pick type/bugfix This PR fixes a bug. labels May 20, 2020
@ghost ghost removed their request for review May 20, 2020 09:07
@sre-bot sre-bot requested review from imtbkcat and XuHuaiyu May 20, 2020 09:07
@sre-bot sre-bot added this to the v4.0.0-ga milestone May 20, 2020
Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@jebter
Copy link

jebter commented May 20, 2020

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 20, 2020
@sre-bot
Copy link
Contributor Author

sre-bot commented May 20, 2020

/run-all-tests

@sre-bot sre-bot merged commit 70c4fae into pingcap:release-4.0 May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression priority/release-blocker This issue blocks a release. Please solve it ASAP. sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. type/bugfix This PR fixes a bug. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants