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

*: speed up the operation of "admin check table" (#11568, #8572) #11547

Merged
merged 5 commits into from
Aug 5, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'release-3.0' into zimuxia/check-table-3
  • Loading branch information
zimulala committed Aug 2, 2019
commit 8fb0799959c86250dbb5ac387daf8fec85454b18
22 changes: 11 additions & 11 deletions planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ func (b *PlanBuilder) buildPrepare(x *ast.PrepareStmt) Plan {
return p
}

func (b *PlanBuilder) buildCheckIndex(dbName model.CIStr, as *ast.AdminStmt) (Plan, error) {
func (b *PlanBuilder) buildCheckIndex(ctx context.Context, dbName model.CIStr, as *ast.AdminStmt) (Plan, error) {
tblName := as.Tables[0]
tbl, err := b.is.TableByName(dbName, tblName.Name)
if err != nil {
Expand All @@ -567,7 +567,7 @@ func (b *PlanBuilder) buildCheckIndex(dbName model.CIStr, as *ast.AdminStmt) (Pl
return nil, errors.Errorf("index %s state %s isn't public", as.Index, idx.State)
}

return b.buildPhysicalIndexLookUpReader(dbName, tbl, idx, 1)
return b.buildPhysicalIndexLookUpReader(ctx, dbName, tbl, idx, 1)
}

func (b *PlanBuilder) buildAdmin(ctx context.Context, as *ast.AdminStmt) (Plan, error) {
Expand All @@ -581,7 +581,7 @@ func (b *PlanBuilder) buildAdmin(ctx context.Context, as *ast.AdminStmt) (Plan,
}
case ast.AdminCheckIndex:
dbName := as.Tables[0].Schema
readerPlan, err := b.buildCheckIndex(dbName, as)
readerPlan, err := b.buildCheckIndex(ctx, dbName, as)
if err != nil {
return ret, err
}
Expand Down Expand Up @@ -652,7 +652,7 @@ func (b *PlanBuilder) buildAdmin(ctx context.Context, as *ast.AdminStmt) (Plan,
}

// getGenExprs gets generated expressions map.
func (b *PlanBuilder) getGenExprs(dbName model.CIStr, tbl table.Table, idx *model.IndexInfo) (
func (b *PlanBuilder) getGenExprs(ctx context.Context, dbName model.CIStr, tbl table.Table, idx *model.IndexInfo) (
map[model.TableColumnID]expression.Expression, error) {
tblInfo := tbl.Meta()
genExprsMap := make(map[model.TableColumnID]expression.Expression)
Expand All @@ -666,7 +666,7 @@ func (b *PlanBuilder) getGenExprs(dbName model.CIStr, tbl table.Table, idx *mode
expr = colExpr
if col.IsGenerated() && !col.GeneratedStored {
var err error
expr, _, err = b.rewrite(col.GeneratedExpr, mockTablePlan, nil, true)
expr, _, err = b.rewrite(ctx, col.GeneratedExpr, mockTablePlan, nil, true)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down Expand Up @@ -696,8 +696,8 @@ func (b *PlanBuilder) getGenExprs(dbName model.CIStr, tbl table.Table, idx *mode
return genExprsMap, nil
}

func (b *PlanBuilder) buildPhysicalIndexLookUpReader(dbName model.CIStr, tbl table.Table, idx *model.IndexInfo, id int) (Plan, error) {
genExprsMap, err := b.getGenExprs(dbName, tbl, idx)
func (b *PlanBuilder) buildPhysicalIndexLookUpReader(ctx context.Context, dbName model.CIStr, tbl table.Table, idx *model.IndexInfo, id int) (Plan, error) {
genExprsMap, err := b.getGenExprs(ctx, dbName, tbl, idx)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down Expand Up @@ -785,7 +785,7 @@ func (b *PlanBuilder) buildPhysicalIndexLookUpReader(dbName model.CIStr, tbl tab
return rootT.p, nil
}

func (b *PlanBuilder) buildPhysicalIndexLookUpReaders(dbName model.CIStr, tbl table.Table) ([]Plan, []table.Index, error) {
func (b *PlanBuilder) buildPhysicalIndexLookUpReaders(ctx context.Context, dbName model.CIStr, tbl table.Table) ([]Plan, []table.Index, error) {
tblInfo := tbl.Meta()
// get index information
indices := make([]table.Index, 0, len(tblInfo.Indices))
Expand All @@ -798,7 +798,7 @@ func (b *PlanBuilder) buildPhysicalIndexLookUpReaders(dbName model.CIStr, tbl ta
continue
}
indices = append(indices, idx)
reader, err := b.buildPhysicalIndexLookUpReader(dbName, tbl, idxInfo, i)
reader, err := b.buildPhysicalIndexLookUpReader(ctx, dbName, tbl, idxInfo, i)
if err != nil {
return nil, nil, err
}
Expand All @@ -810,7 +810,7 @@ func (b *PlanBuilder) buildPhysicalIndexLookUpReaders(dbName model.CIStr, tbl ta
return indexLookUpReaders, indices, nil
}

func (b *PlanBuilder) buildAdminCheckTable(as *ast.AdminStmt) (*CheckTable, error) {
func (b *PlanBuilder) buildAdminCheckTable(ctx context.Context, as *ast.AdminStmt) (*CheckTable, error) {
tbl := as.Tables[0]
p := &CheckTable{
DBName: tbl.Schema.O,
Expand All @@ -823,7 +823,7 @@ func (b *PlanBuilder) buildAdminCheckTable(as *ast.AdminStmt) (*CheckTable, erro
return nil, infoschema.ErrTableNotExists.GenWithStackByArgs(tbl.DBInfo.Name.O, tableInfo.Name.O)
}

readerPlans, indices, err := b.buildPhysicalIndexLookUpReaders(tbl.Schema, table)
readerPlans, indices, err := b.buildPhysicalIndexLookUpReaders(ctx, tbl.Schema, table)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.