本文整理汇总了Golang中github.com/pingcap/tidb/sessionctx/db.GetCurrentSchema函数的典型用法代码示例。如果您正苦于以下问题:Golang GetCurrentSchema函数的具体用法?Golang GetCurrentSchema怎么用?Golang GetCurrentSchema使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetCurrentSchema函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Next
// Next implements Executor Next interface.
func (e *CheckTableExec) Next() (*Row, error) {
if e.done {
return nil, nil
}
dbName := model.NewCIStr(db.GetCurrentSchema(e.ctx))
is := sessionctx.GetDomain(e.ctx).InfoSchema()
for _, t := range e.tables {
tb, err := is.TableByName(dbName, t.Name)
if err != nil {
return nil, errors.Trace(err)
}
for _, idx := range tb.Indices() {
txn, err := e.ctx.GetTxn(false)
if err != nil {
return nil, errors.Trace(err)
}
err = inspectkv.CompareIndexData(txn, tb, idx)
if err != nil {
return nil, errors.Errorf("%v err:%v", t.Name, err)
}
}
}
e.done = true
return nil, nil
}
示例2: builtinDatabase
// See https://dev.mysql.com/doc/refman/5.7/en/information-functions.html
func builtinDatabase(args []types.Datum, ctx context.Context) (d types.Datum, err error) {
s := db.GetCurrentSchema(ctx)
if s == "" {
return d, nil
}
d.SetString(s)
return d, nil
}
示例3: getDBName
func (r *ShowRset) getDBName(ctx context.Context) string {
if len(r.DBName) > 0 {
return r.DBName
}
// if r.DBName is empty, we should use current db name if possible.
return db.GetCurrentSchema(ctx)
}
示例4: Full
// Full returns an Ident which set schema to the current schema if it is empty.
func (i Ident) Full(ctx context.Context) (full Ident) {
full.Name = i.Name
if i.Schema.O != "" {
full.Schema = i.Schema
} else {
full.Schema = model.NewCIStr(db.GetCurrentSchema(ctx))
}
return
}
示例5: String
func (s *session) String() string {
// TODO: how to print binded context in values appropriately?
data := map[string]interface{}{
"userName": s.userName,
"currDBName": db.GetCurrentSchema(s),
"sid": s.sid,
"txn": s.txn.String(),
}
b, _ := json.MarshalIndent(data, "", " ")
return string(b)
}
示例6: builtinDatabase
func builtinDatabase(args []interface{}, data map[interface{}]interface{}) (v interface{}, err error) {
c, ok := data[ExprEvalArgCtx]
if !ok {
return nil, errors.Errorf("Missing ExprEvalArgCtx when evalue builtin")
}
ctx := c.(context.Context)
d := db.GetCurrentSchema(ctx)
if d == "" {
return nil, nil
}
return d, nil
}
示例7: getDBName
func (s *ShowStmt) getDBName(ctx context.Context) string {
if len(s.DBName) > 0 {
return s.DBName
}
// maybe db.table format
if len(s.TableIdent.Schema.O) > 0 {
return s.TableIdent.Schema.O
}
// try use current db name if possible.
return db.GetCurrentSchema(ctx)
}
示例8: String
func (s *session) String() string {
// TODO: how to print binded context in values appropriately?
data := map[string]interface{}{
"currDBName": db.GetCurrentSchema(s),
"sid": s.sid,
}
if s.txn != nil {
// if txn is committed or rolled back, txn is nil.
data["txn"] = s.txn.String()
}
b, _ := json.MarshalIndent(data, "", " ")
return string(b)
}
示例9: getTargetSchema
// Find the schema by dbName.
func (e *GrantExec) getTargetSchema() (*model.DBInfo, error) {
dbName := e.Level.DBName
if len(dbName) == 0 {
// Grant *, use current schema
dbName = db.GetCurrentSchema(e.ctx)
if len(dbName) == 0 {
return nil, errors.New("Miss DB name for grant privilege.")
}
}
//check if db exists
schema := model.NewCIStr(dbName)
is := sessionctx.GetDomain(e.ctx).InfoSchema()
db, ok := is.SchemaByName(schema)
if !ok {
return nil, errors.Errorf("Unknown schema name: %s", dbName)
}
return db, nil
}
示例10: ResolveName
// ResolveName resolves table name and column name.
// It generates ResultFields for ResultSetNode and resolves ColumnNameExpr to a ResultField.
func ResolveName(node ast.Node, info infoschema.InfoSchema, ctx context.Context) error {
defaultSchema := db.GetCurrentSchema(ctx)
resolver := nameResolver{Info: info, Ctx: ctx, DefaultSchema: model.NewCIStr(defaultSchema)}
node.Accept(&resolver)
return errors.Trace(resolver.Err)
}