本文整理汇总了Golang中github.com/pingcap/tidb/ast.ResultSetNode类的典型用法代码示例。如果您正苦于以下问题:Golang ResultSetNode类的具体用法?Golang ResultSetNode怎么用?Golang ResultSetNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ResultSetNode类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: resolveColumnInTableSources
func (nr *nameResolver) resolveColumnInTableSources(cn *ast.ColumnNameExpr, tableSources []*ast.TableSource) (done bool) {
var matchedResultField *ast.ResultField
tableNameL := cn.Name.Table.L
columnNameL := cn.Name.Name.L
if tableNameL != "" {
var matchedTable ast.ResultSetNode
for _, ts := range tableSources {
if tableNameL == ts.AsName.L {
// different table name.
matchedTable = ts
break
} else if ts.AsName.L != "" {
// Table as name shadows table real name.
continue
}
if tn, ok := ts.Source.(*ast.TableName); ok {
if cn.Name.Schema.L != "" && cn.Name.Schema.L != tn.Schema.L {
continue
}
if tableNameL == tn.Name.L {
matchedTable = ts
}
}
}
if matchedTable != nil {
resultFields := matchedTable.GetResultFields()
for _, rf := range resultFields {
if rf.ColumnAsName.L == columnNameL || rf.Column.Name.L == columnNameL {
// resolve column.
matchedResultField = rf
break
}
}
}
} else {
for _, ts := range tableSources {
rfs := ts.GetResultFields()
for _, rf := range rfs {
matchAsName := rf.ColumnAsName.L != "" && rf.ColumnAsName.L == columnNameL
matchColumnName := rf.ColumnAsName.L == "" && rf.Column.Name.L == columnNameL
if matchAsName || matchColumnName {
if matchedResultField != nil {
nr.Err = errors.Errorf("column %s is ambiguous.", cn.Name.Name.O)
return true
}
matchedResultField = rf
}
}
}
}
if matchedResultField != nil {
// Bind column.
cn.Refer = matchedResultField
matchedResultField.Referenced = true
return true
}
return false
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:58,代码来源:resolver.go
示例2: bindColumnInTableSources
func (sb *InfoBinder) bindColumnInTableSources(cn *ast.ColumnName, tableSources []*ast.TableSource) (done bool) {
var matchedResultField *ast.ResultField
if cn.Table.L != "" {
var matchedTable ast.ResultSetNode
for _, ts := range tableSources {
if cn.Table.L == ts.AsName.L {
// different table name.
matchedTable = ts
break
}
if tn, ok := ts.Source.(*ast.TableName); ok {
if cn.Table.L == tn.Name.L {
matchedTable = ts
}
}
}
if matchedTable != nil {
resultFields := matchedTable.GetResultFields()
for _, rf := range resultFields {
if rf.ColumnAsName.L == cn.Name.L || rf.Column.Name.L == cn.Name.L {
// bind column.
matchedResultField = rf
break
}
}
}
} else {
for _, ts := range tableSources {
rfs := ts.GetResultFields()
for _, rf := range rfs {
matchAsName := rf.ColumnAsName.L != "" && rf.ColumnAsName.L == cn.Name.L
matchColumnName := rf.ColumnAsName.L == "" && rf.Column.Name.L == cn.Name.L
if matchAsName || matchColumnName {
if matchedResultField != nil {
sb.Err = errors.Errorf("column %s is ambiguous.", cn.Name.O)
return true
}
matchedResultField = rf
}
}
}
}
if matchedResultField != nil {
// bind column.
cn.ColumnInfo = matchedResultField.Column
cn.TableInfo = matchedResultField.Table
return true
}
return false
}
开发者ID:yzl11,项目名称:vessel,代码行数:50,代码来源:infobinder.go
注:本文中的github.com/pingcap/tidb/ast.ResultSetNode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论