本文整理匯總了Golang中github.com/cockroachdb/cockroach/sql/parser.QualifiedName.Base方法的典型用法代碼示例。如果您正苦於以下問題:Golang QualifiedName.Base方法的具體用法?Golang QualifiedName.Base怎麽用?Golang QualifiedName.Base使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/sql/parser.QualifiedName
的用法示例。
在下文中一共展示了QualifiedName.Base方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: getDesc
func (v *qnameVisitor) getDesc(qname *parser.QualifiedName) *TableDescriptor {
if v.desc == nil {
return nil
}
if qname.Base == "" {
qname.Base = parser.Name(v.desc.Alias)
return v.desc
}
if equalName(v.desc.Alias, string(qname.Base)) {
return v.desc
}
return nil
}
示例3: normalizeTableName
func (p *planner) normalizeTableName(qname *parser.QualifiedName) error {
if qname == nil || qname.Base == "" {
return fmt.Errorf("empty table name: %s", qname)
}
if len(qname.Indirect) == 0 {
if p.session.Database == "" {
return fmt.Errorf("no database specified")
}
qname.Indirect = append(qname.Indirect, parser.NameIndirection(qname.Base))
qname.Base = parser.Name(p.session.Database)
}
return nil
}