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) #21711

Merged
merged 6 commits into from
Jan 27, 2021

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #21132 to release-4.0


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

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

@wshwsh12 you're already a collaborator in bot's repo.

@@ -7282,6 +7282,75 @@ func (s *testIntegrationSuite) TestIssue20860(c *C) {
c.Assert(tk.ExecToErr("update t set d = adddate(d, interval 1 day) where id < 10"), NotNil)
}

<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

conflicts

@jebter jebter modified the milestones: 4.0.0, v4.0.10 Jan 7, 2021
@jebter jebter modified the milestones: v4.0.10, v4.0.11 Jan 18, 2021
@wshwsh12
Copy link
Contributor

@lzmhhh123 @XuHuaiyu PTAL

Copy link
Contributor

@qw4990 qw4990 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 Jan 26, 2021
@qw4990
Copy link
Contributor

qw4990 commented Jan 26, 2021

@wshwsh12 Please resolve conflicts again...

Copy link
Member

@zz-jason zz-jason 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 status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 27, 2021
@zz-jason
Copy link
Member

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 27, 2021
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

@ti-srebot merge failed.

@zz-jason
Copy link
Member

/merge

@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot ti-srebot merged commit 8d00a11 into pingcap:release-4.0 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. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants