本文整理汇总了Golang中github.com/pingcap/tidb/domain.NewDomain函数的典型用法代码示例。如果您正苦于以下问题:Golang NewDomain函数的具体用法?Golang NewDomain怎么用?Golang NewDomain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewDomain函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Get
func (dm *domainMap) Get(store kv.Storage) (d *domain.Domain, err error) {
key := store.UUID()
dm.mu.Lock()
defer dm.mu.Unlock()
d = dm.domains[key]
if d != nil {
return
}
if SchemaLease <= minSchemaLease {
SchemaLease = minSchemaLease
}
lease := SchemaLease
// if storage is local storage, we may in test environment or
// run server in single machine mode, so we don't need wait
// 2 * lease time for DDL operation.
if localstore.IsLocalStore(store) {
lease = 0
}
d, err = domain.NewDomain(store, lease)
if err != nil {
return nil, errors.Trace(err)
}
dm.domains[key] = d
return
}
开发者ID:hanjinze,项目名称:tidb,代码行数:27,代码来源:tidb.go
示例2: Get
func (dm *domainMap) Get(store kv.Storage) (d *domain.Domain, err error) {
key := store.UUID()
dm.mu.Lock()
defer dm.mu.Unlock()
d = dm.domains[key]
if d != nil {
return
}
d, err = domain.NewDomain(store)
if err != nil {
return nil, errors.Trace(err)
}
dm.domains[key] = d
return
}
开发者ID:awesomeleo,项目名称:tidb,代码行数:15,代码来源:tidb.go
示例3: TestAdmin
func (s *testSuite) TestAdmin(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists admin_test")
tk.MustExec("create table admin_test (c1 int, c2 int, c3 int default 1, index (c1))")
tk.MustExec("insert admin_test (c1) values (1),(2),(NULL)")
r, err := tk.Exec("admin show ddl")
c.Assert(err, IsNil)
row, err := r.Next()
c.Assert(err, IsNil)
c.Assert(row.Data, HasLen, 3)
txn, err := s.store.Begin()
c.Assert(err, IsNil)
ddlInfo, err := inspectkv.GetDDLInfo(txn)
c.Assert(err, IsNil)
c.Assert(row.Data[0], Equals, ddlInfo.SchemaVer)
c.Assert(row.Data[1], DeepEquals, ddlInfo.Owner.String())
c.Assert(row.Data[2], DeepEquals, "")
row, err = r.Next()
c.Assert(err, IsNil)
c.Assert(row, IsNil)
// check table test
tk.MustExec("create table admin_test1 (c1 int, c2 int default 1, index (c1))")
tk.MustExec("insert admin_test1 (c1) values (21),(22)")
r, err = tk.Exec("admin check table admin_test, admin_test1")
c.Assert(err, IsNil)
c.Assert(r, IsNil)
// error table name
r, err = tk.Exec("admin check table admin_test_error")
c.Assert(err, NotNil)
// different index values
domain, err := domain.NewDomain(s.store, 1*time.Second)
c.Assert(err, IsNil)
is := domain.InfoSchema()
c.Assert(is, NotNil)
tb, err := is.TableByName(model.NewCIStr("test"), model.NewCIStr("admin_test"))
c.Assert(err, IsNil)
c.Assert(tb.Indices(), HasLen, 1)
err = tb.Indices()[0].X.Create(txn, []interface{}{int64(10)}, 1)
c.Assert(err, IsNil)
err = txn.Commit()
c.Assert(err, IsNil)
r, err = tk.Exec("admin check table admin_test")
c.Assert(err, NotNil)
}
开发者ID:70767096,项目名称:tidb,代码行数:46,代码来源:executor_test.go
示例4: Get
func (dm *domainMap) Get(store kv.Storage) (d *domain.Domain, err error) {
key := store.UUID()
dm.mu.Lock()
defer dm.mu.Unlock()
d = dm.domains[key]
if d != nil {
return
}
lease := time.Duration(0)
if !localstore.IsLocalStore(store) {
lease = schemaLease
}
d, err = domain.NewDomain(store, lease)
if err != nil {
return nil, errors.Trace(err)
}
dm.domains[key] = d
return
}
开发者ID:astaxie,项目名称:tidb,代码行数:20,代码来源:tidb.go
示例5: Get
func (dm *domainMap) Get(store kv.Storage) (d *domain.Domain, err error) {
key := store.UUID()
dm.mu.Lock()
defer dm.mu.Unlock()
d = dm.domains[key]
if d != nil {
return
}
lease := time.Duration(0)
if !localstore.IsLocalStore(store) {
lease = schemaLease
}
err = util.RunWithRetry(defaultMaxRetries, retryInterval, func() (retry bool, err1 error) {
d, err1 = domain.NewDomain(store, lease)
return true, errors.Trace(err1)
})
if err != nil {
return nil, errors.Trace(err)
}
dm.domains[key] = d
return
}
开发者ID:jmptrader,项目名称:tidb,代码行数:23,代码来源:tidb.go
注:本文中的github.com/pingcap/tidb/domain.NewDomain函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论