Skip to content

Commit

Permalink
ddl: forbidden flashback/recover local temprorary table (pingcap#27323)
Browse files Browse the repository at this point in the history
  • Loading branch information
sylzd authored Aug 20, 2021
1 parent dfe9acf commit fdb7243
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion executor/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ func (e *DDLExec) getRecoverTableByTableName(tableName *ast.TableName) (*model.J
return nil, nil, err
}
if tableInfo == nil || jobInfo == nil {
return nil, nil, errors.Errorf("Can't find dropped/truncated table: %v in DDL history jobs", tableName.Name)
return nil, nil, errors.Errorf("Can't find localTemporary/dropped/truncated table: %v in DDL history jobs", tableName.Name)
}
// Dropping local temporary tables won't appear in DDL jobs.
if tableInfo.TempTableType == model.TempTableGlobal {
Expand Down
10 changes: 9 additions & 1 deletion executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5909,7 +5909,7 @@ func (s *testRecoverTable) TestFlashbackTable(c *C) {

// Test flash table with not_exist_table_name name.
_, err = tk.Exec("flashback table t_not_exists")
c.Assert(err.Error(), Equals, "Can't find dropped/truncated table: t_not_exists in DDL history jobs")
c.Assert(err.Error(), Equals, "Can't find localTemporary/dropped/truncated table: t_not_exists in DDL history jobs")

// Test flashback table failed by there is already a new table with the same name.
// If there is a new table with the same name, should return failed.
Expand Down Expand Up @@ -6008,6 +6008,11 @@ func (s *testRecoverTable) TestRecoverTempTable(c *C) {
tk.MustExec("set tidb_enable_global_temporary_table=true")
tk.MustExec("create global temporary table t_recover (a int) on commit delete rows;")

tk.MustExec("set @@tidb_enable_noop_functions=1;")
tk.MustExec("use test_recover")
tk.MustExec("drop table if exists tmp2_recover")
tk.MustExec("create temporary table tmp2_recover (a int);")

timeBeforeDrop, _, safePointSQL, resetGC := s.mockGC(tk)
defer resetGC()
// Set GC safe point
Expand All @@ -6016,6 +6021,9 @@ func (s *testRecoverTable) TestRecoverTempTable(c *C) {
tk.MustExec("drop table t_recover")
tk.MustGetErrCode("recover table t_recover;", errno.ErrUnsupportedDDLOperation)
tk.MustGetErrCode("flashback table t_recover;", errno.ErrUnsupportedDDLOperation)
tk.MustExec("drop table tmp2_recover")
tk.MustGetErrMsg("recover table tmp2_recover;", "Can't find localTemporary/dropped/truncated table: tmp2_recover in DDL history jobs")
tk.MustGetErrMsg("flashback table tmp2_recover;", "Can't find localTemporary/dropped/truncated table: tmp2_recover in DDL history jobs")
}

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

0 comments on commit fdb7243

Please sign in to comment.