當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ShowStmt.GetResultFields方法代碼示例

本文整理匯總了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
}
開發者ID:pingcap,項目名稱:tidb,代碼行數:60,代碼來源:planbuilder.go

示例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
}
開發者ID:XuHuaiyu,項目名稱:tidb,代碼行數:33,代碼來源:planbuilder.go

示例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
}
開發者ID:astaxie,項目名稱:tidb,代碼行數:26,代碼來源:planbuilder.go


注:本文中的github.com/pingcap/tidb/ast.ShowStmt.GetResultFields方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。