當前位置: 首頁>>代碼示例>>Golang>>正文


Golang domain.NewDomain函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。