本文整理汇总了Golang中github.com/cockroachdb/cockroach/sql/parser.QualifiedName.IsStar方法的典型用法代码示例。如果您正苦于以下问题:Golang QualifiedName.IsStar方法的具体用法?Golang QualifiedName.IsStar怎么用?Golang QualifiedName.IsStar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cockroachdb/cockroach/sql/parser.QualifiedName
的用法示例。
在下文中一共展示了QualifiedName.IsStar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: findColumn
// findColumn looks up the column described by a QualifiedName. The qname will be normalized.
func (qt qvalResolver) findColumn(qname *parser.QualifiedName) (columnRef, error) {
ref := columnRef{colIdx: invalidColIdx}
if err := qname.NormalizeColumnName(); err != nil {
return ref, err
}
// We can't resolve stars to a single column.
if qname.IsStar() {
err := fmt.Errorf("qualified name \"%s\" not found", qname)
return ref, err
}
// TODO(radu): when we support multiple FROMs, we will find the node with the correct alias; if
// no alias is given, we will search for the column in all FROMs and make sure there is only
// one. For now we just check that the name matches (if given).
if qname.Base == "" {
qname.Base = parser.Name(qt.table.alias)
}
if equalName(qt.table.alias, string(qname.Base)) {
colName := qname.Column()
for idx, col := range qt.table.columns {
if equalName(col.Name, colName) {
ref.table = qt.table
ref.colIdx = idx
return ref, nil
}
}
}
err := fmt.Errorf("qualified name \"%s\" not found", qname)
return ref, err
}
示例2: findColumn
// findColumn looks up the column described by a QualifiedName. The qname will be normalized.
func (qt qvalResolver) findColumn(qname *parser.QualifiedName) (columnRef, error) {
ref := columnRef{colIdx: invalidColIdx}
if err := qname.NormalizeColumnName(); err != nil {
return ref, err
}
// We can't resolve stars to a single column.
if qname.IsStar() {
err := fmt.Errorf("qualified name \"%s\" not found", qname)
return ref, err
}
colName := sqlbase.NormalizeName(qname.Column())
for _, table := range qt.tables {
if qname.Base == "" || sqlbase.EqualName(table.alias, string(qname.Base)) {
for idx, col := range table.columns {
if sqlbase.NormalizeName(col.Name) == colName {
if ref.colIdx != invalidColIdx {
return ref, fmt.Errorf("column reference \"%s\" is ambiguous", qname)
}
ref.table = table
ref.colIdx = idx
}
}
}
}
if ref.colIdx == invalidColIdx {
return ref, fmt.Errorf("qualified name \"%s\" not found", qname)
}
return ref, nil
}