Skip to content

Commit

Permalink
executor: fix flashback table faild in uppercase d ... (#17093) (#17167)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored May 14, 2020
1 parent 1934f34 commit d23fb6a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 2 additions & 4 deletions executor/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func (e *DDLExec) getRecoverTableByTableName(tableName *ast.TableName) (*model.J
}
schemaName := tableName.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 All @@ -518,9 +518,7 @@ func (e *DDLExec) getRecoverTableByTableName(tableName *ast.TableName) (*model.J
}
schema, ok := dom.InfoSchema().SchemaByID(job.SchemaID)
if !ok {
return true, infoschema.ErrDatabaseNotExists.GenWithStackByArgs(
fmt.Sprintf("(Schema ID %d)", job.SchemaID),
)
return false, nil
}
if schema.Name.L == schemaName {
tableInfo = tblInfo
Expand Down
21 changes: 21 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4813,6 +4813,27 @@ func (s *testRecoverTable) TestFlashbackTable(c *C) {
// Check flashback table autoID.
tk.MustExec("insert into t_p_flashback1 values (6)")
tk.MustQuery("select a,_tidb_rowid from t_p_flashback1 order by a;").Check(testkit.Rows("1 1", "2 2", "3 3", "4 5001", "5 5002", "6 10001"))

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("flashback 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("flashback table t")
tk.MustExec("insert into t values (3)")
tk.MustQuery("select a from t order by a").Check(testkit.Rows("1", "2", "3"))
}

func (s *testSuiteP2) TestPointGetPreparedPlan(c *C) {
Expand Down

0 comments on commit d23fb6a

Please sign in to comment.