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

*: fix a bug causes indexed virtual generated column return wrong value and refine admin check table #18408

Merged
merged 23 commits into from
Jul 24, 2020

Conversation

wjhuang2016
Copy link
Member

@wjhuang2016 wjhuang2016 commented Jul 7, 2020

What problem does this PR solve?

Issue Number: close #17989

Problem Summary:

  1. Previously, we try to use column substitution to decode a multi-level virtual generated column, which is buggy.
  2. Since admin check table uses tableReader, and tableReader can output rows with a virtual generated column already, we don't need to compute it again. Besides, the previous implementation also suffered the above problem.
    I’m

What is changed and how it works?

  1. Build virtual expression for virtual generated column in ColumnInfos2ColumnsAndNames.
  2. Remove genExprs in checkIndexValue.
  3. In compareData, don't compute the virtual generated column again.
  4. Export a function rewriteAstExpr, so that we can use rewrite in package expression.
  5. Refine buildPhysicalIndexLookUpReader, make it simple.
  6. Move table/tables/gen_expr_test.go → util/generatedexpr/gen_expr_test.go. to avoid circular reference.

What's Changed:

How it Works:

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Side effects

Release note

  • Fix a bug causes indexed virtual generated column return wrong value and refine admin check table

@wjhuang2016 wjhuang2016 requested review from a team as code owners July 7, 2020 07:15
@wjhuang2016 wjhuang2016 requested review from qw4990 and XuHuaiyu and removed request for a team July 7, 2020 07:15
Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
util/admin/admin.go Show resolved Hide resolved
util/rowDecoder/decoder.go Show resolved Hide resolved
@wjhuang2016
Copy link
Member Author

/run-all-tests

@codecov
Copy link

codecov bot commented Jul 15, 2020

Codecov Report

Merging #18408 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #18408   +/-   ##
===========================================
  Coverage   79.6853%   79.6853%           
===========================================
  Files           543        543           
  Lines        148922     148922           
===========================================
  Hits         118669     118669           
  Misses        20916      20916           
  Partials       9337       9337           

Signed-off-by: wjhuang2016 <[email protected]>
@wjhuang2016
Copy link
Member Author

/run-all-tests

expression/expression.go Outdated Show resolved Hide resolved
Comment on lines +792 to +796
save := ctx.GetSessionVars().StmtCtx.IgnoreTruncate
defer func() {
ctx.GetSessionVars().StmtCtx.IgnoreTruncate = save
}()
ctx.GetSessionVars().StmtCtx.IgnoreTruncate = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment for this.

@@ -46,17 +46,30 @@ func evalAstExpr(sctx sessionctx.Context, expr ast.ExprNode) (types.Datum, error
if val, ok := expr.(*driver.ValueExpr); ok {
return val.Datum, nil
}
NewExpr, err := rewriteAstExpr(sctx, expr, nil, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NewExpr, err := rewriteAstExpr(sctx, expr, nil, nil)
newExpr, err := rewriteAstExpr(sctx, expr, nil, nil)

planner/core/expression_rewriter.go Outdated Show resolved Hide resolved
planner/core/planbuilder.go Show resolved Hide resolved
planner/core/planbuilder.go Show resolved Hide resolved
util/rowDecoder/decoder.go Outdated Show resolved Hide resolved
Copy link
Contributor

@djshow832 djshow832 left a comment

Choose a reason for hiding this comment

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

Please address comments and involve a member from executor SIG. Rest LGTM.

@bb7133
Copy link
Member

bb7133 commented Jul 24, 2020

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 24, 2020
@bb7133
Copy link
Member

bb7133 commented Jul 24, 2020

/run-all-tests

Signed-off-by: wjhuang2016 <[email protected]>
@bb7133 bb7133 added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 24, 2020
Copy link
Contributor

@djshow832 djshow832 left a comment

Choose a reason for hiding this comment

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

LGTM

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/LGT3 The PR has already had 3 LGTM. and removed status/LGT2 Indicates that a PR has LGTM 2. labels Jul 24, 2020
@qw4990
Copy link
Contributor

qw4990 commented Jul 24, 2020

/merge

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

/run-all-tests

@ti-srebot
Copy link
Contributor

@wjhuang2016 merge failed.

@bb7133
Copy link
Member

bb7133 commented Jul 24, 2020

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@bb7133 bb7133 merged commit baf6c99 into pingcap:master Jul 24, 2020
jebter pushed a commit that referenced this pull request Aug 11, 2020
…ue and refine admin check table (#18408) (#19062)

* save

Signed-off-by: wjhuang2016 <[email protected]>

* done

Signed-off-by: wjhuang2016 <[email protected]>

* 1

Signed-off-by: wjhuang2016 <[email protected]>

* 1

Signed-off-by: wjhuang2016 <[email protected]>

Co-authored-by: ti-srebot <[email protected]>
@wjhuang2016 wjhuang2016 deleted the fix_index_vgc branch November 17, 2022 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression sig/execution SIG execution sig/sql-infra SIG: SQL Infra status/can-merge Indicates a PR has been approved by a committer. status/LGT3 The PR has already had 3 LGTM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create index with multi-layer virtual generated column return wrong result
6 participants