From 9778fcf9963d3724c91077f195cfd7c1ee4d9793 Mon Sep 17 00:00:00 2001 From: likzn <1020193211@qq.com> Date: Fri, 24 Jun 2022 13:46:34 +0800 Subject: [PATCH] add extra flag to determine to buildPattern or not --- planner/core/logical_plans.go | 3 ++- planner/core/planbuilder.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/planner/core/logical_plans.go b/planner/core/logical_plans.go index 48b4da2e96cd6..93528c93716e2 100644 --- a/planner/core/logical_plans.go +++ b/planner/core/logical_plans.go @@ -1838,7 +1838,8 @@ type LogicalShow struct { logicalSchemaProducer ShowContents - Extractor ShowPredicateExtractor + Extractor ShowPredicateExtractor + buildPattern bool // It depends on ShowPredicateExtractor now } // LogicalShowDDLJobs is for showing DDL job list. diff --git a/planner/core/planbuilder.go b/planner/core/planbuilder.go index b568f614d7836..267e0ee973d2d 100644 --- a/planner/core/planbuilder.go +++ b/planner/core/planbuilder.go @@ -2928,6 +2928,7 @@ 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 @@ -2939,6 +2940,7 @@ func (b *PlanBuilder) buildShow(ctx context.Context, show *ast.ShowStmt) (Plan, } if extractor := newShowBaseExtractor(*show); extractor.Extract() { p.Extractor = extractor + p.buildPattern = false } case ast.ShowCreateTable, ast.ShowCreateSequence, ast.ShowPlacementForTable, ast.ShowPlacementForPartition: var err error @@ -3010,7 +3012,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.Extractor == nil { + if show.Pattern != nil && p.buildPattern { show.Pattern.Expr = &ast.ColumnNameExpr{ Name: &ast.ColumnName{Name: p.OutputNames()[0].ColName}, }