func (b *planBuilder) buildShow(show *ast.ShowStmt) Plan { var resultPlan Plan p := &Show{ Tp: show.Tp, DBName: show.DBName, Table: show.Table, Column: show.Column, Flag: show.Flag, Full: show.Full, User: show.User, baseLogicalPlan: newBaseLogicalPlan("Show", b.allocator), } resultPlan = p p.initIDAndContext(b.ctx) p.self = p switch show.Tp { case ast.ShowProcedureStatus: p.SetSchema(buildShowProcedureSchema()) case ast.ShowTriggers: p.SetSchema(buildShowTriggerSchema()) case ast.ShowEvents: p.SetSchema(buildShowEventsSchema()) default: p.SetSchema(expression.ResultFieldsToSchema(show.GetResultFields())) } for i, col := range p.schema { col.Position = i } var conditions []expression.Expression if show.Pattern != nil { expr, _, err := b.rewrite(show.Pattern, p, nil, false) if err != nil { b.err = errors.Trace(err) return nil } conditions = append(conditions, expr) } if show.Where != nil { conds := splitWhere(show.Where) for _, cond := range conds { expr, _, err := b.rewrite(cond, p, nil, false) if err != nil { b.err = errors.Trace(err) return nil } conditions = append(conditions, expr) } } if len(conditions) != 0 { sel := &Selection{ baseLogicalPlan: newBaseLogicalPlan(Sel, b.allocator), Conditions: conditions, } sel.initIDAndContext(b.ctx) sel.self = sel addChild(sel, p) resultPlan = sel } return resultPlan }
func (b *planBuilder) buildShow(show *ast.ShowStmt) Plan { var p Plan p = &Show{ Tp: show.Tp, DBName: show.DBName, Table: show.Table, Column: show.Column, Flag: show.Flag, Full: show.Full, User: show.User, } switch show.Tp { case ast.ShowProcedureStatus: p.SetFields(buildShowProcedureFields()) case ast.ShowTriggers: p.SetFields(buildShowTriggerFields()) default: p.SetFields(show.GetResultFields()) } var conditions []ast.ExprNode if show.Pattern != nil { conditions = append(conditions, show.Pattern) } if show.Where != nil { conditions = append(conditions, show.Where) } if len(conditions) != 0 { filter := &Filter{Conditions: conditions} addChild(filter, p) p = filter } return p }
func (b *planBuilder) buildShow(show *ast.ShowStmt) Plan { var p Plan p = &Show{ Tp: show.Tp, DBName: show.DBName, Table: show.Table, Column: show.Column, Flag: show.Flag, Full: show.Full, User: show.User, } p.SetFields(show.GetResultFields()) var conditions []ast.ExprNode if show.Pattern != nil { conditions = append(conditions, show.Pattern) } if show.Where != nil { conditions = append(conditions, show.Where) } if len(conditions) != 0 { filter := &Filter{Conditions: conditions} filter.SetSrc(p) p = filter } return p }