本文整理匯總了Golang中github.com/cockroachdb/cockroach/sql/parser.QualifiedName.QualifyWithDatabase方法的典型用法代碼示例。如果您正苦於以下問題:Golang QualifiedName.QualifyWithDatabase方法的具體用法?Golang QualifiedName.QualifyWithDatabase怎麽用?Golang QualifiedName.QualifyWithDatabase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/sql/parser.QualifiedName
的用法示例。
在下文中一共展示了QualifiedName.QualifyWithDatabase方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: expandTableGlob
// expandTableGlob expands wildcards from the end of `expr` and
// returns the list of matching tables.
// `expr` is possibly modified to be qualified with the database it refers to.
// `expr` is assumed to be of one of several forms:
// database.table
// table
// *
func (p *planner) expandTableGlob(expr *parser.QualifiedName) (
parser.QualifiedNames, *roachpb.Error) {
if len(expr.Indirect) == 0 {
return parser.QualifiedNames{expr}, nil
}
if err := expr.QualifyWithDatabase(p.session.Database); err != nil {
return nil, roachpb.NewError(err)
}
// We must have a single indirect: either .table or .*
if len(expr.Indirect) != 1 {
return nil, roachpb.NewErrorf("invalid table glob: %s", expr)
}
switch expr.Indirect[0].(type) {
case parser.NameIndirection:
return parser.QualifiedNames{expr}, nil
case parser.StarIndirection:
dbDesc, pErr := p.getDatabaseDesc(string(expr.Base))
if pErr != nil {
return nil, pErr
}
tableNames, pErr := p.getTableNames(dbDesc)
if pErr != nil {
return nil, pErr
}
return tableNames, nil
default:
return nil, roachpb.NewErrorf("invalid table glob: %s", expr)
}
}