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

planner: reimplement DEFAULT function to make the behavior consistent with MySQL when looking up the corresponding column (#19709) #21316

Merged
merged 8 commits into from
Nov 30, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #19709 to release-4.0


What problem does this PR solve?

Issue Number: close #17807

Problem Summary:

The previous Default function parsed to generate ast.ColumnName, and then further parsed the corresponding column. But in fact, the Default function does not need to obtain the value of the corresponding column from the storage, so it should not be further parsed by ast.ColumnName.

The previous implementation produced many incompatibility issues with MySQL, such as:

Have to merge pingcap/parser#1027 first.

What is changed and how it works?

Proposal: xxx

What's Changed:

  • Modify the parser so that DEFAULT function is not generated ast.ColumnName.
  • Add new field allNames for PlanBuilder and expressionRewriter to record the set of columns that can be used to find in evalDefaultExpr.
  • Find the corresponding column in evalDefaultExpr. And frist, it will look for allNames. If it is not found, it will search in expressionRewrite.names.

Check List

Tests

  • Unit test

Side effects

Release note

  • reimplement DEFAULT function to make the behavior consistent with MySQL when looking up the corresponding column

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

/run-all-tests

@ti-srebot
Copy link
Contributor Author

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

@rebelice
Copy link
Contributor

PTAL @qw4990 @lzmhhh123

planner/core/planbuilder.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ichn-hu ichn-hu 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 Nov 30, 2020
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 status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 30, 2020
@qw4990 qw4990 merged commit b1363f9 into pingcap:release-4.0 Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants