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

Merged
merged 3 commits into from
May 20, 2020

Conversation

tiancaiamao
Copy link
Contributor

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.

@tiancaiamao tiancaiamao requested a review from a team as a code owner May 20, 2020 03:29
@ghost ghost requested review from XuHuaiyu and removed request for a team May 20, 2020 03:29
@tiancaiamao
Copy link
Contributor Author

PTAL @XuHuaiyu

@github-actions github-actions bot added the sig/execution SIG execution label 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

@XuHuaiyu XuHuaiyu added the priority/release-blocker This issue blocks a release. Please solve it ASAP. label May 20, 2020
@XuHuaiyu XuHuaiyu requested a review from imtbkcat May 20, 2020 07:40
imtbkcat
imtbkcat previously approved these changes May 20, 2020
Copy link

@imtbkcat imtbkcat 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

@imtbkcat imtbkcat left a comment

Choose a reason for hiding this comment

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

LGTM

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

sre-bot commented May 20, 2020

/run-all-tests

@sre-bot sre-bot merged commit 313ed01 into pingcap:master May 20, 2020
@tiancaiamao tiancaiamao deleted the err-divide-zero branch May 20, 2020 09:05
sre-bot pushed a commit to sre-bot/tidb that referenced this pull request May 20, 2020
Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor

sre-bot commented May 20, 2020

cherry pick to release-4.0 in PR #17314

sre-bot added a commit that referenced this pull request 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants