Skip to content

Commit

Permalink
support all engine
Browse files Browse the repository at this point in the history
  • Loading branch information
djshow832 committed Oct 15, 2021
1 parent cc96f59 commit 7c83d0f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
20 changes: 15 additions & 5 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2893,8 +2893,21 @@ func (s *testIntegrationSuite3) TestCreateTemporaryTable(c *C) {

// Not support yet.
tk.MustGetErrCode("create global temporary table t (id int) on commit preserve rows", errno.ErrUnsupportedDDLOperation)
// Engine type can only be 'memory' or empty for now.
tk.MustGetErrCode("create global temporary table t (id int) engine = 'innodb' on commit delete rows", errno.ErrUnsupportedDDLOperation)

// Engine type can be anyone, see https://github.com/pingcap/tidb/issues/28541.
tk.MustExec("drop table if exists tengine")
tk.MustExec("create global temporary table tengine (id int) engine = 'innodb' on commit delete rows")
tk.MustExec("drop table if exists tengine")
tk.MustExec("create global temporary table tengine (id int) engine = 'memory' on commit delete rows")
tk.MustExec("drop table if exists tengine")
tk.MustExec("create global temporary table tengine (id int) engine = 'myisam' on commit delete rows")
tk.MustExec("drop table if exists tengine")
tk.MustExec("create temporary table tengine (id int) engine = 'innodb'")
tk.MustExec("drop table if exists tengine")
tk.MustExec("create temporary table tengine (id int) engine = 'memory'")
tk.MustExec("drop table if exists tengine")
tk.MustExec("create temporary table tengine (id int) engine = 'myisam'")
tk.MustExec("drop table if exists tengine")

// Create local temporary table.
tk.MustExec("create database tmp_db")
Expand Down Expand Up @@ -2936,9 +2949,6 @@ func (s *testIntegrationSuite3) TestCreateTemporaryTable(c *C) {
c.Assert(infoschema.ErrTableExists.Equal(err), IsTrue)
tk.MustExec("create temporary table if not exists b_local_temp_table (id int)")

// Engine type can only be 'memory' or empty for now.
tk.MustGetErrCode("create temporary table te (id int) engine = 'innodb'", errno.ErrUnsupportedDDLOperation)

// Stale read see the local temporary table but can't read on it.
tk.MustExec("START TRANSACTION READ ONLY AS OF TIMESTAMP NOW(3)")
tk.MustGetErrMsg("select * from overlap", "can not stale read temporary table")
Expand Down
6 changes: 0 additions & 6 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2447,12 +2447,6 @@ func handleTableOptions(options []*ast.TableOption, tbInfo *model.TableInfo) err
tbInfo.PreSplitRegions = op.UintValue
case ast.TableOptionCharset, ast.TableOptionCollate:
// We don't handle charset and collate here since they're handled in `getCharsetAndCollateInTableOption`.
case ast.TableOptionEngine:
if tbInfo.TempTableType != model.TempTableNone {
if op.StrValue != "" && !strings.EqualFold(op.StrValue, "memory") {
return errors.Trace(errUnsupportedEngineTemporary)
}
}
case ast.TableOptionPlacementPolicy:
tbInfo.PlacementPolicyRef = &model.PolicyRefInfo{
Name: model.NewCIStr(op.StrValue),
Expand Down
1 change: 0 additions & 1 deletion ddl/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ var (
ErrOptOnTemporaryTable = dbterror.ClassDDL.NewStd(mysql.ErrOptOnTemporaryTable)

errUnsupportedOnCommitPreserve = dbterror.ClassDDL.NewStdErr(mysql.ErrUnsupportedDDLOperation, parser_mysql.Message("TiDB doesn't support ON COMMIT PRESERVE ROWS for now", nil))
errUnsupportedEngineTemporary = dbterror.ClassDDL.NewStdErr(mysql.ErrUnsupportedDDLOperation, parser_mysql.Message("TiDB doesn't support this kind of engine for temporary table", nil))
errUnsupportedClusteredSecondaryKey = dbterror.ClassDDL.NewStdErr(mysql.ErrUnsupportedDDLOperation, parser_mysql.Message("CLUSTERED/NONCLUSTERED keyword is only supported for primary key", nil))

// ErrUnsupportedLocalTempTableDDL returns when ddl operation unsupported for local temporary table
Expand Down

0 comments on commit 7c83d0f

Please sign in to comment.