本文整理汇总了Golang中github.com/pingcap/tidb/util/testkit.NewTestKit函数的典型用法代码示例。如果您正苦于以下问题:Golang NewTestKit函数的具体用法?Golang NewTestKit怎么用?Golang NewTestKit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewTestKit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestGrantGlobal
func (s *testSuite) TestGrantGlobal(c *C) {
defer testleak.AfterTest(c)()
tk := testkit.NewTestKit(c, s.store)
// Create a new user.
createUserSQL := `CREATE USER 'testGlobal'@'localhost' IDENTIFIED BY '123';`
tk.MustExec(createUserSQL)
// Make sure all the global privs for new user is "N".
for _, v := range mysql.AllDBPrivs {
sql := fmt.Sprintf("SELECT %s FROM mysql.User WHERE User=\"testGlobal\" and host=\"localhost\";", mysql.Priv2UserCol[v])
r := tk.MustQuery(sql)
r.Check(testkit.Rows("N"))
}
// Grant each priv to the user.
for _, v := range mysql.AllGlobalPrivs {
sql := fmt.Sprintf("GRANT %s ON *.* TO 'testGlobal'@'localhost';", mysql.Priv2Str[v])
tk.MustExec(sql)
sql = fmt.Sprintf("SELECT %s FROM mysql.User WHERE User=\"testGlobal\" and host=\"localhost\"", mysql.Priv2UserCol[v])
tk.MustQuery(sql).Check(testkit.Rows("Y"))
}
// Create a new user.
createUserSQL = `CREATE USER 'testGlobal1'@'localhost' IDENTIFIED BY '123';`
tk.MustExec(createUserSQL)
tk.MustExec("GRANT ALL ON *.* TO 'testGlobal1'@'localhost';")
// Make sure all the global privs for granted user is "Y".
for _, v := range mysql.AllGlobalPrivs {
sql := fmt.Sprintf("SELECT %s FROM mysql.User WHERE User=\"testGlobal1\" and host=\"localhost\"", mysql.Priv2UserCol[v])
tk.MustQuery(sql).Check(testkit.Rows("Y"))
}
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:31,代码来源:grant_test.go
示例2: TestAlterTable
func (s *testSuite) TestAlterTable(c *C) {
defer testleak.AfterTest(c)()
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table if not exists alter_test (c1 int)")
tk.MustExec("alter table alter_test add column c2 int")
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:7,代码来源:executor_ddl_test.go
示例3: TestShow
func (s *testSuite) TestShow(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
testSQL := `drop table if exists show_test`
tk.MustExec(testSQL)
testSQL = `create table show_test (id int PRIMARY KEY AUTO_INCREMENT, c1 int, c2 int, c3 int default 1);`
tk.MustExec(testSQL)
testSQL = "show columns from show_test;"
result := tk.MustQuery(testSQL)
c.Check(result.Rows(), HasLen, 4)
testSQL = "show create table show_test;"
result = tk.MustQuery(testSQL)
c.Check(result.Rows(), HasLen, 1)
testSQL = "SHOW VARIABLES LIKE 'character_set_results';"
result = tk.MustQuery(testSQL)
c.Check(result.Rows(), HasLen, 1)
// Test case for index type and comment
tk.MustExec(`create table show_index (c int, index cIdx using hash (c) comment "index_comment_for_cIdx");`)
testSQL = "SHOW index from show_index;"
result = tk.MustQuery(testSQL)
c.Check(result.Rows(), HasLen, 1)
expectedRow := []interface{}{
"show_index", int64(1), "cIdx", int64(1), "c", "utf8_bin",
int64(0), nil, nil, "YES", "HASH", "", "index_comment_for_cIdx"}
row := result.Rows()[0]
c.Check(row, HasLen, len(expectedRow))
for i, r := range row {
c.Check(r, Equals, expectedRow[i])
}
}
开发者ID:astaxie,项目名称:tidb,代码行数:34,代码来源:show_test.go
示例4: TestInfoBinder
func (ts *testInfoBinderSuite) TestInfoBinder(c *C) {
store, err := tidb.NewStore(tidb.EngineGoLevelDBMemory)
c.Assert(err, IsNil)
defer store.Close()
testKit := testkit.NewTestKit(c, store)
testKit.MustExec("use test")
testKit.MustExec("create table t (c1 int, c2 int)")
domain := sessionctx.GetDomain(testKit.Se.(context.Context))
src := "SELECT c1 from t"
l := parser.NewLexer(src)
c.Assert(parser.YYParse(l), Equals, 0)
stmts := l.Stmts()
c.Assert(len(stmts), Equals, 1)
v := &optimizer.InfoBinder{
Info: domain.InfoSchema(),
DefaultSchema: model.NewCIStr("test"),
}
selectStmt := stmts[0].(*ast.SelectStmt)
selectStmt.Accept(v)
verifier := &binderVerifier{
c: c,
}
selectStmt.Accept(verifier)
}
开发者ID:yzl11,项目名称:vessel,代码行数:26,代码来源:infobinder_test.go
示例5: TestLoadDataEscape
func (s *testSuite) TestLoadDataEscape(c *C) {
defer func() {
s.cleanEnv(c)
testleak.AfterTest(c)()
}()
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test; drop table if exists load_data_test;")
tk.MustExec("CREATE TABLE load_data_test (id INT NOT NULL PRIMARY KEY, value TEXT NOT NULL) CHARACTER SET utf8")
tk.MustExec("load data local infile '/tmp/nonexistence.csv' into table load_data_test")
ctx := tk.Se.(context.Context)
ld := makeLoadDataInfo(2, ctx, c)
// test escape
cases := []testCase{
// data1 = nil, data2 != nil
{nil, []byte("1\ta string\n"), []string{fmt.Sprintf("%v %v", 1, []byte("a string"))}, nil},
{nil, []byte("2\tstr \\t\n"), []string{fmt.Sprintf("%v %v", 2, []byte("str \t"))}, nil},
{nil, []byte("3\tstr \\n\n"), []string{fmt.Sprintf("%v %v", 3, []byte("str \n"))}, nil},
{nil, []byte("4\tboth \\t\\n\n"), []string{fmt.Sprintf("%v %v", 4, []byte("both \t\n"))}, nil},
{nil, []byte("5\tstr \\\\\n"), []string{fmt.Sprintf("%v %v", 5, []byte("str \\"))}, nil},
{nil, []byte("6\t\\r\\t\\n\\0\\Z\\b\n"), []string{fmt.Sprintf("%v %v", 6, []byte{'\r', '\t', '\n', 0, 26, '\b'})}, nil},
}
deleteSQL := "delete from load_data_test"
selectSQL := "select * from load_data_test;"
checkCases(cases, ld, c, tk, ctx, selectSQL, deleteSQL)
}
开发者ID:pingcap,项目名称:tidb,代码行数:25,代码来源:executor_write_test.go
示例6: TestUpdate
func (s *testSuite) TestUpdate(c *C) {
defer func() {
s.cleanEnv(c)
testleak.AfterTest(c)()
}()
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
s.fillData(tk, "update_test")
updateStr := `UPDATE update_test SET name = "abc" where id > 0;`
tk.MustExec(updateStr)
tk.CheckExecResult(2, 0)
// select data
tk.MustExec("begin")
r := tk.MustQuery(`SELECT * from update_test limit 2;`)
rowStr1 := fmt.Sprintf("%v %v", 1, []byte("abc"))
rowStr2 := fmt.Sprintf("%v %v", 2, []byte("abc"))
r.Check(testkit.Rows(rowStr1, rowStr2))
tk.MustExec("commit")
tk.MustExec(`UPDATE update_test SET name = "foo"`)
tk.CheckExecResult(2, 0)
// table option is auto-increment
tk.MustExec("begin")
tk.MustExec("drop table if exists update_test;")
tk.MustExec("commit")
tk.MustExec("begin")
tk.MustExec("create table update_test(id int not null auto_increment, name varchar(255), primary key(id))")
tk.MustExec("insert into update_test(name) values ('aa')")
tk.MustExec("update update_test set id = 8 where name = 'aa'")
tk.MustExec("insert into update_test(name) values ('bb')")
tk.MustExec("commit")
tk.MustExec("begin")
r = tk.MustQuery("select * from update_test;")
rowStr1 = fmt.Sprintf("%v %v", 8, []byte("aa"))
rowStr2 = fmt.Sprintf("%v %v", 9, []byte("bb"))
r.Check(testkit.Rows(rowStr1, rowStr2))
tk.MustExec("commit")
tk.MustExec("begin")
tk.MustExec("drop table if exists update_test;")
tk.MustExec("commit")
tk.MustExec("begin")
tk.MustExec("create table update_test(id int not null auto_increment, name varchar(255), index(id))")
tk.MustExec("insert into update_test(name) values ('aa')")
_, err := tk.Exec("update update_test set id = null where name = 'aa'")
c.Assert(err, NotNil)
c.Assert(err.Error(), DeepEquals, "Column 'id' cannot be null")
tk.MustExec("drop table update_test")
tk.MustExec("create table update_test(id int)")
tk.MustExec("begin")
tk.MustExec("insert into update_test(id) values (1)")
tk.MustExec("update update_test set id = 2 where id = 1 limit 1")
r = tk.MustQuery("select * from update_test;")
r.Check(testkit.Rows("2"))
tk.MustExec("commit")
}
开发者ID:pingcap,项目名称:tidb,代码行数:60,代码来源:executor_write_test.go
示例7: TestMultipleTableUpdate
func (s *testSuite) TestMultipleTableUpdate(c *C) {
defer func() {
s.cleanEnv(c)
testleak.AfterTest(c)()
}()
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
s.fillMultiTableForUpdate(tk)
tk.MustExec(`UPDATE items, month SET items.price=month.mprice WHERE items.id=month.mid;`)
tk.MustExec("begin")
r := tk.MustQuery("SELECT * FROM items")
rowStr1 := fmt.Sprintf("%v %v", 11, []byte("month_price_11"))
rowStr2 := fmt.Sprintf("%v %v", 12, []byte("items_price_12"))
rowStr3 := fmt.Sprintf("%v %v", 13, []byte("month_price_13"))
r.Check(testkit.Rows(rowStr1, rowStr2, rowStr3))
tk.MustExec("commit")
// Single-table syntax but with multiple tables
tk.MustExec(`UPDATE items join month on items.id=month.mid SET items.price=month.mid;`)
tk.MustExec("begin")
r = tk.MustQuery("SELECT * FROM items")
rowStr1 = fmt.Sprintf("%v %v", 11, []byte("11"))
rowStr2 = fmt.Sprintf("%v %v", 12, []byte("items_price_12"))
rowStr3 = fmt.Sprintf("%v %v", 13, []byte("13"))
r.Check(testkit.Rows(rowStr1, rowStr2, rowStr3))
tk.MustExec("commit")
// JoinTable with alias table name.
tk.MustExec(`UPDATE items T0 join month T1 on T0.id=T1.mid SET T0.price=T1.mprice;`)
tk.MustExec("begin")
r = tk.MustQuery("SELECT * FROM items")
rowStr1 = fmt.Sprintf("%v %v", 11, []byte("month_price_11"))
rowStr2 = fmt.Sprintf("%v %v", 12, []byte("items_price_12"))
rowStr3 = fmt.Sprintf("%v %v", 13, []byte("month_price_13"))
r.Check(testkit.Rows(rowStr1, rowStr2, rowStr3))
tk.MustExec("commit")
// fix https://github.com/pingcap/tidb/issues/369
testSQL := `
DROP TABLE IF EXISTS t1, t2;
create table t1 (c int);
create table t2 (c varchar(256));
insert into t1 values (1), (2);
insert into t2 values ("a"), ("b");
update t1, t2 set t1.c = 10, t2.c = "abc";`
tk.MustExec(testSQL)
// fix https://github.com/pingcap/tidb/issues/376
testSQL = `DROP TABLE IF EXISTS t1, t2;
create table t1 (c1 int);
create table t2 (c2 int);
insert into t1 values (1), (2);
insert into t2 values (1), (2);
update t1, t2 set t1.c1 = 10, t2.c2 = 2 where t2.c2 = 1;`
tk.MustExec(testSQL)
r = tk.MustQuery("select * from t1")
r.Check(testkit.Rows("10", "10"))
}
开发者ID:pingcap,项目名称:tidb,代码行数:60,代码来源:executor_write_test.go
示例8: TestNameResolver
func (ts *testNameResolverSuite) TestNameResolver(c *C) {
store, err := tidb.NewStore(tidb.EngineGoLevelDBMemory)
c.Assert(err, IsNil)
defer store.Close()
testKit := testkit.NewTestKit(c, store)
testKit.MustExec("use test")
testKit.MustExec("create table t1 (c1 int, c2 int)")
testKit.MustExec("create table t2 (c1 int, c2 int)")
testKit.MustExec("create table t3 (c1 int, c2 int)")
ctx := testKit.Se.(context.Context)
domain := sessionctx.GetDomain(ctx)
db.BindCurrentSchema(ctx, "test")
for _, tc := range resolverTestCases {
node, err := parser.ParseOneStmt(tc.src, "", "")
c.Assert(err, IsNil)
resolveErr := plan.ResolveName(node, domain.InfoSchema(), ctx)
if tc.valid {
c.Assert(resolveErr, IsNil)
verifier := &resolverVerifier{c: c, src: tc.src}
node.Accept(verifier)
} else {
c.Assert(resolveErr, NotNil, Commentf("%s", tc.src))
}
}
}
开发者ID:anywhy,项目名称:tidb,代码行数:25,代码来源:resolver_test.go
示例9: TestInsertIgnore
func (s *testSuite) TestInsertIgnore(c *C) {
defer func() {
s.cleanEnv(c)
testleak.AfterTest(c)()
}()
var cfg kv.InjectionConfig
tk := testkit.NewTestKit(c, kv.NewInjectedStore(s.store, &cfg))
tk.MustExec("use test")
testSQL := `drop table if exists t;
create table t (id int PRIMARY KEY AUTO_INCREMENT, c1 int);`
tk.MustExec(testSQL)
testSQL = `insert into t values (1, 2);`
tk.MustExec(testSQL)
r := tk.MustQuery("select * from t;")
rowStr := fmt.Sprintf("%v %v", "1", "2")
r.Check(testkit.Rows(rowStr))
tk.MustExec("insert ignore into t values (1, 3), (2, 3)")
r = tk.MustQuery("select * from t;")
rowStr = fmt.Sprintf("%v %v", "1", "2")
rowStr1 := fmt.Sprintf("%v %v", "2", "3")
r.Check(testkit.Rows(rowStr, rowStr1))
cfg.SetGetError(errors.New("foo"))
_, err := tk.Exec("insert ignore into t values (1, 3)")
c.Assert(err, NotNil)
cfg.SetGetError(nil)
}
开发者ID:pingcap,项目名称:tidb,代码行数:30,代码来源:executor_write_test.go
示例10: TestGrantDBScope
func (s *testSuite) TestGrantDBScope(c *C) {
defer testleak.AfterTest(c)()
tk := testkit.NewTestKit(c, s.store)
// Create a new user.
createUserSQL := `CREATE USER 'testDB'@'localhost' IDENTIFIED BY '123';`
tk.MustExec(createUserSQL)
// Make sure all the db privs for new user is empty.
sql := fmt.Sprintf("SELECT * FROM mysql.db WHERE User=\"testDB\" and host=\"localhost\"")
tk.MustQuery(sql).Check(testkit.Rows())
// Grant each priv to the user.
for _, v := range mysql.AllDBPrivs {
sql := fmt.Sprintf("GRANT %s ON test.* TO 'testDB'@'localhost';", mysql.Priv2Str[v])
tk.MustExec(sql)
sql = fmt.Sprintf("SELECT %s FROM mysql.DB WHERE User=\"testDB\" and host=\"localhost\" and db=\"test\"", mysql.Priv2UserCol[v])
tk.MustQuery(sql).Check(testkit.Rows("Y"))
}
// Create a new user.
createUserSQL = `CREATE USER 'testDB1'@'localhost' IDENTIFIED BY '123';`
tk.MustExec(createUserSQL)
tk.MustExec("USE test;")
tk.MustExec("GRANT ALL ON * TO 'testDB1'@'localhost';")
// Make sure all the db privs for granted user is "Y".
for _, v := range mysql.AllDBPrivs {
sql := fmt.Sprintf("SELECT %s FROM mysql.DB WHERE User=\"testDB1\" and host=\"localhost\" and db=\"test\";", mysql.Priv2UserCol[v])
tk.MustQuery(sql).Check(testkit.Rows("Y"))
}
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:29,代码来源:grant_test.go
示例11: TestCreateDropDatabase
func (s *testSuite) TestCreateDropDatabase(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("create database if not exists drop_test;")
tk.MustExec("drop database if exists drop_test;")
tk.MustExec("create database drop_test;")
tk.MustExec("drop database drop_test;")
}
开发者ID:astaxie,项目名称:tidb,代码行数:7,代码来源:executor_ddl_test.go
示例12: SetUpSuite
func (s *testBinlogSuite) SetUpSuite(c *C) {
logLevel := os.Getenv("log_level")
log.SetLevelByString(logLevel)
store, err := tikv.NewMockTikvStore()
c.Assert(err, IsNil)
s.store = store
tidb.SetSchemaLease(0)
s.unixFile = "/tmp/mock-binlog-pump"
os.Remove(s.unixFile)
l, err := net.Listen("unix", s.unixFile)
c.Assert(err, IsNil)
s.serv = grpc.NewServer()
s.pump = new(mockBinlogPump)
binlog.RegisterPumpServer(s.serv, s.pump)
go s.serv.Serve(l)
opt := grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
return net.DialTimeout("unix", addr, timeout)
})
clientCon, err := grpc.Dial(s.unixFile, opt, grpc.WithInsecure())
c.Assert(err, IsNil)
c.Assert(clientCon, NotNil)
binloginfo.PumpClient = binlog.NewPumpClient(clientCon)
s.tk = testkit.NewTestKit(c, s.store)
s.tk.MustExec("use test")
domain := sessionctx.GetDomain(s.tk.Se.(context.Context))
s.ddl = domain.DDL()
}
开发者ID:pingcap,项目名称:tidb,代码行数:27,代码来源:binloginfo_test.go
示例13: TestSetPwd
func (s *testSuite) TestSetPwd(c *C) {
defer testleak.AfterTest(c)()
tk := testkit.NewTestKit(c, s.store)
createUserSQL := `CREATE USER 'testpwd'@'localhost' IDENTIFIED BY '';`
tk.MustExec(createUserSQL)
result := tk.MustQuery(`SELECT Password FROM mysql.User WHERE User="testpwd" and Host="localhost"`)
rowStr := fmt.Sprintf("%v", []byte(""))
result.Check(testkit.Rows(rowStr))
// set password for
tk.MustExec(`SET PASSWORD FOR 'testpwd'@'localhost' = 'password';`)
result = tk.MustQuery(`SELECT Password FROM mysql.User WHERE User="testpwd" and Host="localhost"`)
rowStr = fmt.Sprintf("%v", []byte(util.EncodePassword("password")))
result.Check(testkit.Rows(rowStr))
// set password
setPwdSQL := `SET PASSWORD = 'pwd'`
// Session user is empty.
_, err := tk.Exec(setPwdSQL)
c.Check(err, NotNil)
tk.Se, err = tidb.CreateSession(s.store)
c.Check(err, IsNil)
ctx := tk.Se.(context.Context)
ctx.GetSessionVars().User = "[email protected]"
// Session user doesn't exist.
_, err = tk.Exec(setPwdSQL)
c.Check(terror.ErrorEqual(err, executor.ErrPasswordNoMatch), IsTrue)
// normal
ctx.GetSessionVars().User = "[email protected]"
tk.MustExec(setPwdSQL)
result = tk.MustQuery(`SELECT Password FROM mysql.User WHERE User="testpwd" and Host="localhost"`)
rowStr = fmt.Sprintf("%v", []byte(util.EncodePassword("pwd")))
result.Check(testkit.Rows(rowStr))
}
开发者ID:pingcap,项目名称:tidb,代码行数:35,代码来源:executor_simple_test.go
示例14: TestInSubquery
func (s *testSuite) TestInSubquery(c *C) {
defer testleak.AfterTest(c)()
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t (a int, b int)")
tk.MustExec("insert t values (1, 1), (2, 1)")
result := tk.MustQuery("select m1.a from t as m1 where m1.a in (select m2.b from t as m2)")
result.Check(testkit.Rows("1"))
result = tk.MustQuery("select m1.a from t as m1 where (3, m1.b) not in (select * from t as m2)")
result.Check(testkit.Rows("1", "2"))
result = tk.MustQuery("select m1.a from t as m1 where m1.a in (select m2.b+? from t as m2)", 1)
result.Check(testkit.Rows("2"))
tk.MustExec(`prepare stmt1 from 'select m1.a from t as m1 where m1.a in (select m2.b+? from t as m2)'`)
tk.MustExec("set @a = 1")
result = tk.MustQuery(`execute stmt1 using @a;`)
result.Check(testkit.Rows("2"))
tk.MustExec("set @a = 0")
result = tk.MustQuery(`execute stmt1 using @a;`)
result.Check(testkit.Rows("1"))
result = tk.MustQuery("select m1.a from t as m1 where m1.a in (1, 3, 5)")
result.Check(testkit.Rows("1"))
tk.MustExec("drop table if exists t1")
tk.MustExec("create table t1 (a float)")
tk.MustExec("insert t1 values (281.37)")
tk.MustQuery("select a from t1 where (a in (select a from t1))").Check(testkit.Rows("281.37"))
}
开发者ID:jmptrader,项目名称:tidb,代码行数:29,代码来源:executor_test.go
示例15: TestSetVar
func (s *testSuite) TestSetVar(c *C) {
plan.UseNewPlanner = true
defer testleak.AfterTest(c)()
tk := testkit.NewTestKit(c, s.store)
testSQL := "SET @a = 1;"
tk.MustExec(testSQL)
testSQL = `SET @a = "1";`
tk.MustExec(testSQL)
testSQL = "SET @a = null;"
tk.MustExec(testSQL)
testSQL = "SET @@global.autocommit = 1;"
tk.MustExec(testSQL)
// TODO: this test case should returns error.
// testSQL = "SET @@global.autocommit = null;"
// _, err := tk.Exec(testSQL)
// c.Assert(err, NotNil)
testSQL = "SET @@autocommit = 1;"
tk.MustExec(testSQL)
testSQL = "SET @@autocommit = null;"
_, err := tk.Exec(testSQL)
c.Assert(err, NotNil)
errTestSql := "SET @@date_format = 1;"
_, err = tk.Exec(errTestSql)
c.Assert(err, NotNil)
errTestSql = "SET @@rewriter_enabled = 1;"
_, err = tk.Exec(errTestSql)
c.Assert(err, NotNil)
errTestSql = "SET xxx = abcd;"
_, err = tk.Exec(errTestSql)
c.Assert(err, NotNil)
errTestSql = "SET @@global.a = 1;"
_, err = tk.Exec(errTestSql)
c.Assert(err, NotNil)
errTestSql = "SET @@global.timestamp = 1;"
_, err = tk.Exec(errTestSql)
c.Assert(err, NotNil)
// For issue 998
testSQL = "SET @issue998a=1, @issue998b=5;"
tk.MustExec(testSQL)
tk.MustQuery(`select @issue998a, @issue998b;`).Check(testkit.Rows("1 5"))
testSQL = "SET @@autocommit=0, @issue998a=2;"
tk.MustExec(testSQL)
tk.MustQuery(`select @issue998a, @@autocommit;`).Check(testkit.Rows("2 0"))
testSQL = "SET @@global.autocommit=1, @issue998b=6;"
tk.MustExec(testSQL)
tk.MustQuery(`select @issue998b, @@global.autocommit;`).Check(testkit.Rows("6 1"))
plan.UseNewPlanner = false
}
开发者ID:duzhanyuan,项目名称:tidb,代码行数:60,代码来源:executor_simple_test.go
示例16: TestSelectErrorRow
func (s *testSuite) TestSelectErrorRow(c *C) {
defer testleak.AfterTest(c)()
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("begin")
_, err := tk.Exec("select row(1, 1) from test")
c.Assert(err, NotNil)
_, err = tk.Exec("select * from test group by row(1, 1);")
c.Assert(err, NotNil)
_, err = tk.Exec("select * from test order by row(1, 1);")
c.Assert(err, NotNil)
_, err = tk.Exec("select * from test having row(1, 1);")
c.Assert(err, NotNil)
_, err = tk.Exec("select (select 1, 1) from test;")
c.Assert(err, NotNil)
_, err = tk.Exec("select * from test group by (select 1, 1);")
c.Assert(err, NotNil)
_, err = tk.Exec("select * from test order by (select 1, 1);")
c.Assert(err, NotNil)
_, err = tk.Exec("select * from test having (select 1, 1);")
c.Assert(err, NotNil)
tk.MustExec("commit")
}
开发者ID:jmptrader,项目名称:tidb,代码行数:32,代码来源:executor_test.go
示例17: TestDelete
func (s *testSuite) TestDelete(c *C) {
defer func() {
s.cleanEnv(c)
testleak.AfterTest(c)()
}()
tk := testkit.NewTestKit(c, s.store)
s.fillData(tk, "delete_test")
tk.MustExec(`update delete_test set name = "abc" where id = 2;`)
tk.CheckExecResult(1, 0)
tk.MustExec(`delete from delete_test where id = 2 limit 1;`)
tk.CheckExecResult(1, 0)
// Test delete with false condition
tk.MustExec(`delete from delete_test where 0;`)
tk.CheckExecResult(0, 0)
tk.MustExec("insert into delete_test values (2, 'abc')")
tk.MustExec(`delete from delete_test where delete_test.id = 2 limit 1`)
tk.CheckExecResult(1, 0)
// Select data
tk.MustExec("begin")
rows := tk.MustQuery(`SELECT * from delete_test limit 2;`)
rowStr := fmt.Sprintf("%v %v", "1", []byte("hello"))
rows.Check(testkit.Rows(rowStr))
tk.MustExec("commit")
tk.MustExec(`delete from delete_test ;`)
tk.CheckExecResult(1, 0)
}
开发者ID:pingcap,项目名称:tidb,代码行数:32,代码来源:executor_write_test.go
示例18: TestCreateDropIndex
func (s *testSuite) TestCreateDropIndex(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table if not exists drop_test (a int)")
tk.MustExec("create index idx_a on drop_test (a)")
tk.MustExec("drop index idx_a on drop_test")
tk.MustExec("drop table drop_test")
}
开发者ID:astaxie,项目名称:tidb,代码行数:8,代码来源:executor_ddl_test.go
示例19: TestColumn
func (s *testDBSuite) TestColumn(c *C) {
defer testleak.AfterTest(c)()
s.tk = testkit.NewTestKit(c, s.store)
s.tk.MustExec("use " + s.schemaName)
s.testAddColumn(c)
s.testDropColumn(c)
s.testChangeColumn(c)
}
开发者ID:pingcap,项目名称:tidb,代码行数:8,代码来源:ddl_db_test.go
示例20: TestJoinPanic
func (s *testSuite) TestJoinPanic(c *C) {
defer testleak.AfterTest(c)()
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists events")
tk.MustExec("create table events (clock int, source int)")
tk.MustQuery("SELECT * FROM events e JOIN (SELECT MAX(clock) AS clock FROM events e2 GROUP BY e2.source) e3 ON e3.clock=e.clock")
}
开发者ID:jmptrader,项目名称:tidb,代码行数:8,代码来源:executor_test.go
注:本文中的github.com/pingcap/tidb/util/testkit.NewTestKit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论