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: fix unexpected NotNullFlag in case when expr ret type (#23102) #23340

Conversation

ti-srebot
Copy link
Contributor

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

cherry-pick #23102 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/23340

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

git push [email protected]:ti-srebot/tidb.git pr/23340:release-5.0-rc-e83a8f656332

Signed-off-by: guo-shaoge [email protected]

What problem does this PR solve?

Issue Number: close #23036

Problem Summary:

drop table if exists t1;
create table t1(c1 int not null);
insert into t1 values(1);
select (case when null then c1 end) is null from t1;

Output should be empty set, but TiDB output "1". Because when we fold constant for IsNull expr, optimizer found the result type of CaseWhen expr has NotNullFlag, which is unexpected. So rewriter return false directly

What is changed and how it works?

What's Changed:

  1. Erase NotNullFlag from the result type of CaseWhen expr. Because we don't know will any when clause be true until runtime.
  2. make types.setTypeFlag() public. (types.setTypeFlag() -> types.SetTypeFlag())

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Integration test: Add cases in expression.TestBuiltin()

Side effects: no

Release note

  • fix unexpected NotNullFlag in case when expr ret type

@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 16, 2021 07:05
@ti-srebot ti-srebot requested review from XuHuaiyu and removed request for a team March 16, 2021 07:05
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot ti-srebot added component/expression sig/planner SIG: Planner size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/5.0-rc-cherry-pick type/bugfix This PR fixes a bug. labels Mar 16, 2021
@ti-srebot
Copy link
Contributor Author

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

@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 sig/planner SIG: Planner 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.

4 participants