本文整理汇总了Golang中github.com/pingcap/tidb/ast.ShowStmt.GetResultFields方法的典型用法代码示例。如果您正苦于以下问题:Golang ShowStmt.GetResultFields方法的具体用法?Golang ShowStmt.GetResultFields怎么用?Golang ShowStmt.GetResultFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pingcap/tidb/ast.ShowStmt
的用法示例。
在下文中一共展示了ShowStmt.GetResultFields方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: buildShow
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
}
示例2: buildShow
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
}
示例3: buildShow
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
}