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

ddl: fix 'create table like' for cached table #56135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions pkg/ddl/create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,7 @@ func BuildTableInfoWithLike(ctx sessionctx.Context, ident ast.Ident, referTblInf
tblInfo.Name = ident.Name
tblInfo.AutoIncID = 0
tblInfo.ForeignKeys = nil
tblInfo.TableCacheStatusType = model.TableCacheStatusDisable
// Ignore TiFlash replicas for temporary tables.
if s.TemporaryKeyword != ast.TemporaryNone {
tblInfo.TiFlashReplica = nil
Expand Down
7 changes: 7 additions & 0 deletions pkg/ddl/db_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ func TestAlterTableCache(t *testing.T) {
"(id int not null primary key, code int not null, value int default null, unique key code(code))" +
"on commit delete rows")
tk.MustGetErrMsg("alter table tmp1 cache", dbterror.ErrOptOnTemporaryTable.GenWithStackByArgs("alter temporary table cache").Error())
// create table like
tk.MustExec("drop table t")
tk.MustExec("create table t (a int)")
tk.MustExec("alter table t cache")
tk.MustExec("create table t3 like t")
checkTableCacheStatus(t, tk, "test", "t", model.TableCacheStatusEnable)
checkTableCacheStatus(t, tk, "test", "t3", model.TableCacheStatusDisable)
}

func TestCacheTableSizeLimit(t *testing.T) {
Expand Down