本文整理匯總了Golang中github.com/cockroachdb/cockroach/pkg/sql/parser.TableName.NormalizedTableName方法的典型用法代碼示例。如果您正苦於以下問題:Golang TableName.NormalizedTableName方法的具體用法?Golang TableName.NormalizedTableName怎麽用?Golang TableName.NormalizedTableName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/pkg/sql/parser.TableName
的用法示例。
在下文中一共展示了TableName.NormalizedTableName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newSourceInfoForSingleTable
// newSourceInfoForSingleTable creates a simple dataSourceInfo
// which maps the same tableAlias to all columns.
func newSourceInfoForSingleTable(tn parser.TableName, columns ResultColumns) *dataSourceInfo {
norm := tn.NormalizedTableName()
return &dataSourceInfo{
sourceColumns: columns,
sourceAliases: sourceAliases{norm: fillColumnRange(0, len(columns)-1)},
}
}
示例2: expandStar
// expandStar returns the array of column metadata and name
// expressions that correspond to the expansion of a star.
func (src *dataSourceInfo) expandStar(
v parser.VarName, ivarHelper parser.IndexedVarHelper,
) (columns ResultColumns, exprs []parser.TypedExpr, err error) {
if len(src.sourceColumns) == 0 {
return nil, nil, fmt.Errorf("cannot use %q without a FROM clause", v)
}
colSel := func(idx int) {
col := src.sourceColumns[idx]
if !col.hidden {
ivar := ivarHelper.IndexedVar(idx)
columns = append(columns, ResultColumn{Name: col.Name, Typ: ivar.ResolvedType()})
exprs = append(exprs, ivar)
}
}
tableName := parser.TableName{}
if a, ok := v.(*parser.AllColumnsSelector); ok {
tableName = a.TableName
}
if tableName.Table() == "" {
for i := 0; i < len(src.sourceColumns); i++ {
colSel(i)
}
} else {
norm := tableName.NormalizedTableName()
qualifiedTn, err := src.checkDatabaseName(norm)
if err != nil {
return nil, nil, err
}
colRange, ok := src.sourceAliases[qualifiedTn]
if !ok {
return nil, nil, fmt.Errorf("table %q not found", tableName.String())
}
for _, i := range colRange {
colSel(i)
}
}
return columns, exprs, nil
}