From 1a25e102d189a97a10e107a9a32ae26fc04edb08 Mon Sep 17 00:00:00 2001 From: likzn <1020193211@qq.com> Date: Fri, 24 Jun 2022 13:59:52 +0800 Subject: [PATCH] refactor --- planner/core/logical_plans.go | 3 +-- planner/core/planbuilder.go | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/planner/core/logical_plans.go b/planner/core/logical_plans.go index 93528c93716e2..48b4da2e96cd6 100644 --- a/planner/core/logical_plans.go +++ b/planner/core/logical_plans.go @@ -1838,8 +1838,7 @@ type LogicalShow struct { logicalSchemaProducer ShowContents - Extractor ShowPredicateExtractor - buildPattern bool // It depends on ShowPredicateExtractor now + Extractor ShowPredicateExtractor } // LogicalShowDDLJobs is for showing DDL job list. diff --git a/planner/core/planbuilder.go b/planner/core/planbuilder.go index 267e0ee973d2d..cc77ebbab918a 100644 --- a/planner/core/planbuilder.go +++ b/planner/core/planbuilder.go @@ -2928,10 +2928,11 @@ func (b *PlanBuilder) buildShow(ctx context.Context, show *ast.ShowStmt) (Plan, GlobalScope: show.GlobalScope, Extended: show.Extended, }, - buildPattern: true, }.Init(b.ctx) isView := false isSequence := false + // It depends on ShowPredicateExtractor now + buildPattern := true switch show.Tp { case ast.ShowDatabases, ast.ShowVariables, ast.ShowTables, ast.ShowColumns, ast.ShowTableStatus, ast.ShowCollation: @@ -2940,7 +2941,7 @@ func (b *PlanBuilder) buildShow(ctx context.Context, show *ast.ShowStmt) (Plan, } if extractor := newShowBaseExtractor(*show); extractor.Extract() { p.Extractor = extractor - p.buildPattern = false + buildPattern = false } case ast.ShowCreateTable, ast.ShowCreateSequence, ast.ShowPlacementForTable, ast.ShowPlacementForPartition: var err error @@ -3012,7 +3013,7 @@ func (b *PlanBuilder) buildShow(ctx context.Context, show *ast.ShowStmt) (Plan, var np LogicalPlan np = p // If we have ShowPredicateExtractor, we do not buildSelection with Pattern - if show.Pattern != nil && p.buildPattern { + if show.Pattern != nil && buildPattern { show.Pattern.Expr = &ast.ColumnNameExpr{ Name: &ast.ColumnName{Name: p.OutputNames()[0].ColName}, }