• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang ast.Node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/pingcap/tidb/ast.Node的典型用法代码示例。如果您正苦于以下问题:Golang Node类的具体用法?Golang Node怎么用?Golang Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Node类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: mockResolve

func mockResolve(node ast.Node) {
	indices := []*model.IndexInfo{
		{
			Name: model.NewCIStr("b"),
			Columns: []*model.IndexColumn{
				{
					Name: model.NewCIStr("b"),
				},
			},
		},
		{
			Name: model.NewCIStr("c_d"),
			Columns: []*model.IndexColumn{
				{
					Name: model.NewCIStr("c"),
				},
				{
					Name: model.NewCIStr("d"),
				},
			},
		},
	}
	pkColumn := &model.ColumnInfo{
		Name: model.NewCIStr("a"),
	}
	pkColumn.Flag = mysql.PriKeyFlag
	table := &model.TableInfo{
		Columns:    []*model.ColumnInfo{pkColumn},
		Indices:    indices,
		Name:       model.NewCIStr("t"),
		PKIsHandle: true,
	}
	resolver := mockResolver{table: table}
	node.Accept(&resolver)
}
开发者ID:AkihiroSuda,项目名称:tidb,代码行数:35,代码来源:plan_test.go


示例2: InferType

// InferType infers result type for ast.ExprNode.
func InferType(node ast.Node) error {
	var inferrer typeInferrer
	// TODO: get the default charset from ctx
	inferrer.defaultCharset = "utf8"
	node.Accept(&inferrer)
	return inferrer.err
}
开发者ID:yuanfeng0905,项目名称:tidb,代码行数:8,代码来源:typeinferer.go


示例3: mockJoinResolve

// mockJoinResolve resolves multi talbe and column name for join statement.
func mockJoinResolve(c *C, node ast.Node) {
	resolver := &mockJoinResolver{
		c:      c,
		tables: map[string]*ast.TableName{},
		refers: map[*model.ColumnInfo]*ast.ResultField{},
	}
	node.Accept(resolver)
}
开发者ID:yubobo,项目名称:tidb,代码行数:9,代码来源:plan_test.go


示例4: InferType

// InferType infers result type for ast.ExprNode.
func InferType(sc *variable.StatementContext, node ast.Node) error {
	var inferrer typeInferrer
	inferrer.sc = sc
	// TODO: get the default charset from ctx
	inferrer.defaultCharset = "utf8"
	node.Accept(&inferrer)
	return inferrer.err
}
开发者ID:pingcap,项目名称:tidb,代码行数:9,代码来源:typeinferer.go


示例5: buildSubquery

func (b *planBuilder) buildSubquery(n ast.Node) {
	sv := &subqueryVisitor{
		builder: b,
	}
	_, ok := n.Accept(sv)
	if !ok {
		log.Errorf("Extract subquery error")
	}
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:9,代码来源:planbuilder.go


示例6: IsSupported

// IsSupported checks if the node is supported to use new plan.
// We first support single table select statement without group by clause or aggregate functions.
// TODO: 1. insert/update/delete. 2. join tables. 3. subquery. 4. group by and aggregate function.
func IsSupported(node ast.Node) bool {
	switch node.(type) {
	case *ast.SelectStmt, *ast.PrepareStmt, *ast.ExecuteStmt, *ast.DeallocateStmt:
	default:
		return false
	}

	var checker supportChecker
	node.Accept(&checker)
	return !checker.unsupported
}
开发者ID:lovedboy,项目名称:tidb,代码行数:14,代码来源:optimizer.go


示例7: Validate

// Validate checkes whether the node is valid.
func Validate(node ast.Node, inPrepare bool) error {
	v := validator{inPrepare: inPrepare}
	node.Accept(&v)
	return v.err
}
开发者ID:MDistribuntedSystem,项目名称:tidb,代码行数:6,代码来源:validator.go


示例8: preEvaluate

// preEvaluate evaluates preEvaluable expression and rewrites constant expression to value expression.
func preEvaluate(ctx context.Context, node ast.Node) error {
	pe := preEvaluator{ctx: ctx}
	node.Accept(&pe)
	return pe.err
}
开发者ID:AkihiroSuda,项目名称:tidb,代码行数:6,代码来源:logic.go


示例9: ResolveName

// ResolveName resolves table name and column name.
// It generates ResultFields for ResultSetNode and resolves ColumnNameExpr to a ResultField.
func ResolveName(node ast.Node, info infoschema.InfoSchema, ctx context.Context) error {
	defaultSchema := db.GetCurrentSchema(ctx)
	resolver := nameResolver{Info: info, Ctx: ctx, DefaultSchema: model.NewCIStr(defaultSchema)}
	node.Accept(&resolver)
	return errors.Trace(resolver.Err)
}
开发者ID:youprofit,项目名称:tidb,代码行数:8,代码来源:resolver.go


示例10: MockResolveName

// MockResolveName only serves for test.
func MockResolveName(node ast.Node, info infoschema.InfoSchema, defaultSchema string, ctx context.Context) error {
	resolver := nameResolver{Info: info, Ctx: ctx, DefaultSchema: model.NewCIStr(defaultSchema)}
	node.Accept(&resolver)
	return resolver.Err
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:6,代码来源:resolver.go


示例11: InferType

// InferType infers result type for ast.ExprNode.
func InferType(node ast.Node) error {
	var inferrer typeInferrer
	node.Accept(&inferrer)
	return inferrer.err
}
开发者ID:AkihiroSuda,项目名称:tidb,代码行数:6,代码来源:typeinferer.go


示例12: Compile

// Compile compiles a ast.Node into an executable statement.
func (com *Compiler) Compile(node ast.Node) (stmt.Statement, error) {
	validator := &validator{}
	if _, ok := node.Accept(validator); !ok {
		return nil, errors.Trace(validator.err)
	}

	//	binder := &InfoBinder{}
	//	if _, ok := node.Accept(validator); !ok {
	//		return nil, errors.Trace(binder.Err)
	//	}

	tpComputer := &typeComputer{}
	if _, ok := node.Accept(tpComputer); !ok {
		return nil, errors.Trace(tpComputer.err)
	}
	c := newExpressionConverter()
	com.converter = c
	switch v := node.(type) {
	case *ast.InsertStmt:
		return convertInsert(c, v)
	case *ast.DeleteStmt:
		return convertDelete(c, v)
	case *ast.UpdateStmt:
		return convertUpdate(c, v)
	case *ast.SelectStmt:
		return convertSelect(c, v)
	case *ast.UnionStmt:
		return convertUnion(c, v)
	case *ast.CreateDatabaseStmt:
		return convertCreateDatabase(c, v)
	case *ast.DropDatabaseStmt:
		return convertDropDatabase(c, v)
	case *ast.CreateTableStmt:
		return convertCreateTable(c, v)
	case *ast.DropTableStmt:
		return convertDropTable(c, v)
	case *ast.CreateIndexStmt:
		return convertCreateIndex(c, v)
	case *ast.DropIndexStmt:
		return convertDropIndex(c, v)
	case *ast.AlterTableStmt:
		return convertAlterTable(c, v)
	case *ast.TruncateTableStmt:
		return convertTruncateTable(c, v)
	case *ast.ExplainStmt:
		return convertExplain(c, v)
	case *ast.PrepareStmt:
		return convertPrepare(c, v)
	case *ast.DeallocateStmt:
		return convertDeallocate(c, v)
	case *ast.ExecuteStmt:
		return convertExecute(c, v)
	case *ast.ShowStmt:
		return convertShow(c, v)
	case *ast.BeginStmt:
		return convertBegin(c, v)
	case *ast.CommitStmt:
		return convertCommit(c, v)
	case *ast.RollbackStmt:
		return convertRollback(c, v)
	case *ast.UseStmt:
		return convertUse(c, v)
	case *ast.SetStmt:
		return convertSet(c, v)
	case *ast.SetCharsetStmt:
		return convertSetCharset(c, v)
	case *ast.SetPwdStmt:
		return convertSetPwd(c, v)
	case *ast.CreateUserStmt:
		return convertCreateUser(c, v)
	case *ast.DoStmt:
		return convertDo(c, v)
	case *ast.GrantStmt:
		return convertGrant(c, v)
	}
	return nil, nil
}
开发者ID:yzl11,项目名称:vessel,代码行数:78,代码来源:compiler.go



注:本文中的github.com/pingcap/tidb/ast.Node类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang ast.ParenthesesExpr类代码示例发布时间:2022-05-28
下一篇:
Golang ast.IsTruthExpr类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap