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

executor: wrong result of nullif expr when used with is null expr. (#23170) #23278

Conversation

ti-srebot
Copy link
Contributor

@ti-srebot ti-srebot commented Mar 12, 2021

cherry-pick #23170 to release-5.0-rc
You can switch your code base to this Pull Request by using git-extras:

# In tidb repo:
git pr https://github.com/pingcap/tidb/pull/23278

After apply modifications, you can push your change to this PR via:

git push git@github.com:ti-srebot/tidb.git pr/23278:release-5.0-rc-f3c64ceecefd

Signed-off-by: guo-shaoge shaoge1994@163.com

What problem does this PR solve?

Issue Number: close #23157

Problem Summary:

drop table t;
create table t(a int primary key);
insert into t values(1),(2);
select * from t where nullif(a,a) is null;

The result of Nullif expr is unexpected, same reason as #23102 .

What is changed and how it works?

Proposal: xxx

What's Changed: In TiDB, we rewrite Nullif(e1, e2) as If(e1 = e2, NULL, e2), so we need to change InferType4ControlFuncs()(which will be call in ifFunctionClass::getFunction), unset NotNullFlag if any argument is NULL.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Integration test: TestNullifWithIsNull()

Side effects:no

Release note

  • wrong result of nullif expr when used with is null expr

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-srebot ti-srebot requested a review from a team as a code owner March 12, 2021 07:41
@ti-srebot ti-srebot requested review from XuHuaiyu and removed request for a team March 12, 2021 07:41
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

@guo-shaoge you're already a collaborator in bot's repo.

@XuHuaiyu XuHuaiyu added the type/bugfix This PR fixes a bug. label Mar 12, 2021
@guo-shaoge
Copy link
Collaborator

depend this pr: #23135

@zz-jason zz-jason closed this Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants