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: Fix unexpected panic when using IF function. #21132

Merged
merged 13 commits into from
Dec 14, 2020

Conversation

wshwsh12
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #15847

Problem Summary:
When rewrite expression, IF(null column,null,null) will get an evalTp TpString. And it will wrap arg0 with isTruth.
Above IF function, there has a CastToReal function.
So the final expression is CastStringToReal(IFString(isTruth(null column), null , null))
In other optimization, maybe it will refactor the expression.
IFString(isTruth(null column), null, null) will be refactored to IFINT(isTruth(null column), null, null)
(See InferType4ControlFuncs and typeInferForNull)
It will cause panic, since CastStringToReal will try to call evalString().

What is changed and how it works?

Proposal: xxx

What's Changed:

How it Works:

Related changes

  • Need to cherry-pick to the release branch 4.0

Check List

Tests

  • Unit test
  • Integration test

Side effects

Release note

  • Fix unexpected panic when using IF function

@wshwsh12 wshwsh12 requested review from a team as code owners November 19, 2020 03:44
@wshwsh12 wshwsh12 requested review from qw4990, hanfei1991 and XuHuaiyu and removed request for a team November 19, 2020 03:44
@ichn-hu ichn-hu mentioned this pull request Dec 11, 2020
@wshwsh12
Copy link
Contributor Author

/run-all-tests

@XuHuaiyu XuHuaiyu changed the title expresssion: Fix unexpected panic when using IF function. expression: Fix unexpected panic when using IF function. Dec 14, 2020
@XuHuaiyu XuHuaiyu requested a review from lzmhhh123 December 14, 2020 05:57
@wshwsh12 wshwsh12 requested a review from XuHuaiyu December 14, 2020 08:18
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

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 14, 2020
Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot removed the status/LGT1 Indicates that a PR has LGTM 1. label Dec 14, 2020
@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Dec 14, 2020
@XuHuaiyu
Copy link
Contributor

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 14, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 3eaa63d into pingcap:master Dec 14, 2020
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Dec 14, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #21711

ti-srebot added a commit that referenced this pull request Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query results in "baseBuiltinFunc.vecEvalString() should never be called" error
4 participants