Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: fix flashback table faild in uppercase database name (#17093) #17165

Merged
merged 5 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions ddl/serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,27 @@ func (s *testSerialSuite) TestRecoverTableByTableName(c *C) {
tk.MustExec("insert into t_recover values (10)")
tk.MustQuery("select * from t_recover;").Check(testkit.Rows("1", "7", "8", "9", "10"))

tk.MustExec("drop database if exists Test2")
tk.MustExec("create database Test2")
tk.MustExec("use Test2")
tk.MustExec("create table t (a int);")
tk.MustExec("insert into t values (1),(2)")
tk.MustExec("drop table t")
tk.MustExec("recover table t")
tk.MustQuery("select a from t order by a").Check(testkit.Rows("1", "2"))

tk.MustExec("drop table t")
tk.MustExec("drop database if exists Test3")
tk.MustExec("create database Test3")
tk.MustExec("use Test3")
tk.MustExec("create table t (a int);")
tk.MustExec("drop table t")
tk.MustExec("drop database Test3")
tk.MustExec("use Test2")
tk.MustExec("recover table t")
tk.MustExec("insert into t values (3)")
tk.MustQuery("select a from t order by a").Check(testkit.Rows("1", "2", "3"))

gcEnable, err := gcutil.CheckGCEnable(tk.Se)
c.Assert(err, IsNil)
c.Assert(gcEnable, Equals, false)
Expand Down
6 changes: 2 additions & 4 deletions executor/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (e *DDLExec) getRecoverTableByTableName(s *ast.RecoverTableStmt, t *meta.Me
}
schemaName := s.Table.Schema.L
if schemaName == "" {
schemaName = e.ctx.GetSessionVars().CurrentDB
schemaName = strings.ToLower(e.ctx.GetSessionVars().CurrentDB)
}
if schemaName == "" {
return nil, nil, errors.Trace(core.ErrNoDB)
Expand Down Expand Up @@ -425,9 +425,7 @@ func (e *DDLExec) getRecoverTableByTableName(s *ast.RecoverTableStmt, t *meta.Me
if table.Meta().Name.L == s.Table.Name.L {
schema, ok := dom.InfoSchema().SchemaByID(job.SchemaID)
if !ok {
return nil, nil, infoschema.ErrDatabaseNotExists.GenWithStackByArgs(
fmt.Sprintf("(Schema ID %d)", job.SchemaID),
)
continue
}
if schema.Name.L == schemaName {
tblInfo = table.Meta()
Expand Down