*: WIP-fix issue 234.
This commit is contained in:
@ -344,6 +344,7 @@ import (
|
||||
DeleteFromStmt "DELETE FROM statement"
|
||||
DistinctOpt "Distinct option"
|
||||
DoStmt "Do statement"
|
||||
DropDatabase "DROP {DATABASE | SCHEMA}"
|
||||
DropDatabaseStmt "DROP DATABASE statement"
|
||||
DropIndexStmt "DROP INDEX statement"
|
||||
DropTableStmt "DROP TABLE statement"
|
||||
@ -1134,6 +1135,7 @@ DefaultOpt:
|
||||
DefaultKwdOpt:
|
||||
{}
|
||||
| "DEFAULT"
|
||||
|
||||
/******************************************************************
|
||||
* Do statement
|
||||
* See: https://dev.mysql.com/doc/refman/5.7/en/do.html
|
||||
@ -1218,11 +1220,18 @@ DeleteFromStmt:
|
||||
}
|
||||
}
|
||||
|
||||
DropDatabase:
|
||||
"DROP" "DATABASE"
|
||||
{
|
||||
}
|
||||
| "DROP" "SCHEMA"
|
||||
{
|
||||
}
|
||||
|
||||
DropDatabaseStmt:
|
||||
"DROP" "DATABASE" IfExists Identifier
|
||||
DropDatabase IfExists DBName
|
||||
{
|
||||
$$ = &stmts.DropDatabaseStmt{IfExists: $3.(bool), Name: $4.(string)}
|
||||
$$ = &stmts.DropDatabaseStmt{IfExists: $2.(bool), Name: $3.(string)}
|
||||
if yylex.(*lexer).root {
|
||||
break
|
||||
}
|
||||
|
||||
@ -350,6 +350,20 @@ func (s *testParserSuite) TestParser0(c *C) {
|
||||
{"show collation", true},
|
||||
{"show collation like 'utf8%'", true},
|
||||
{"show collation where Charset = 'utf8' and Collation = 'utf8_bin'", true},
|
||||
|
||||
// For drop datbase/schema
|
||||
{"create database xxx", true},
|
||||
{"create database if exists xxx", false},
|
||||
{"create database if not exists xxx", true},
|
||||
{"create schema xxx", true},
|
||||
{"create schema if exists xxx", false},
|
||||
{"create schema if not exists xxx", true},
|
||||
{"drop database xxx", true},
|
||||
{"drop database if exists xxx", true},
|
||||
{"drop database if not exists xxx", false},
|
||||
{"drop schema xxx", true},
|
||||
{"drop schema if exists xxx", true},
|
||||
{"drop schema if not exists xxx", false},
|
||||
}
|
||||
|
||||
for _, t := range table {
|
||||
|
||||
13
tidb_test.go
13
tidb_test.go
@ -859,6 +859,19 @@ func (s *testSessionSuite) TestBootstrap(c *C) {
|
||||
mustExecSQL(c, se, "USE test;")
|
||||
}
|
||||
|
||||
func (s *testSessionSuite) TestDatabase(c *C) {
|
||||
store := newStore(c, s.dbName)
|
||||
se := newSession(c, store, s.dbName)
|
||||
|
||||
mustExecSQL(c, se, "create database xxx")
|
||||
mustExecSQL(c, se, "use xxx")
|
||||
mustExecSQL(c, se, "drop database xxx")
|
||||
|
||||
mustExecSQL(c, se, "create schema xxx")
|
||||
mustExecSQL(c, se, "use xxx")
|
||||
mustExecSQL(c, se, "drop schema xxx")
|
||||
}
|
||||
|
||||
func newSession(c *C, store kv.Storage, dbName string) Session {
|
||||
se, err := CreateSession(store)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
Reference in New Issue
Block a user