Skip to content

Commit

Permalink
ddl: fix none info of alter table placement (#29929)
Browse files Browse the repository at this point in the history
  • Loading branch information
sylzd authored Nov 24, 2021
1 parent 05ccb8a commit a90c988
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
35 changes: 35 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,41 @@ func (s *testSuiteP2) TestAdminShowDDLJobs(c *C) {
c.Assert(row[9], Equals, "<nil>")
}

func (s *testSuiteP2) TestAdminShowDDLJobsInfo(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("create database if not exists test_admin_show_ddl_jobs")
defer tk.MustExec("drop database if exists test_admin_show_ddl_jobs")
tk.MustExec("use test_admin_show_ddl_jobs")
tk.MustExec("drop table if exists t, t1;")
tk.MustExec("create table t (a int);")
tk.MustExec("create table t1 (a int);")

// Test for issue: https://github.com/pingcap/tidb/issues/29915
tk.MustExec("drop placement policy if exists x;")
tk.MustExec("create placement policy x followers=4;")
tk.MustExec("alter table t placement policy x;")
c.Assert(tk.MustQuery("admin show ddl jobs 1").Rows()[0][3], Equals, "alter table placement")

tk.MustExec("rename table t to tt, t1 to tt1")
c.Assert(tk.MustQuery("admin show ddl jobs 1").Rows()[0][3], Equals, "rename tables")

tk.MustExec("create table tt2 (c int) PARTITION BY RANGE (c) " +
"(PARTITION p0 VALUES LESS THAN (6)," +
"PARTITION p1 VALUES LESS THAN (11)," +
"PARTITION p2 VALUES LESS THAN (16)," +
"PARTITION p3 VALUES LESS THAN (21));")
tk.MustExec("alter table tt2 partition p0 " +
"PRIMARY_REGION=\"cn-east-1\" " +
"REGIONS=\"cn-east-1, cn-east-2\" " +
"FOLLOWERS=2 ")
c.Assert(tk.MustQuery("admin show ddl jobs 1").Rows()[0][3], Equals, "alter table partition policy")

tk.MustExec("alter table tt1 cache")
c.Assert(tk.MustQuery("admin show ddl jobs 1").Rows()[0][3], Equals, "alter table cache")
tk.MustExec("alter table tt1 nocache")
c.Assert(tk.MustQuery("admin show ddl jobs 1").Rows()[0][3], Equals, "alter table nocache")
}

func (s *testSuiteP2) TestAdminChecksumOfPartitionedTable(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("USE test;")
Expand Down
6 changes: 5 additions & 1 deletion parser/model/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ var actionMap = map[ActionType]string{
ActionModifyColumn: "modify column",
ActionRebaseAutoID: "rebase auto_increment ID",
ActionRenameTable: "rename table",
ActionRenameTables: "rename tables",
ActionSetDefaultValue: "set default value",
ActionShardRowID: "shard row ID",
ActionModifyTableComment: "modify table comment",
Expand Down Expand Up @@ -144,12 +145,15 @@ var actionMap = map[ActionType]string{
ActionAlterCheckConstraint: "alter check constraint",
ActionDropIndexes: "drop multi-indexes",
ActionAlterTableAttributes: "alter table attributes",
ActionAlterTablePartitionPolicy: "alter table partition policy",
ActionAlterTablePartitionAttributes: "alter table partition attributes",
ActionCreatePlacementPolicy: "create placement policy",
ActionAlterPlacementPolicy: "alter placement policy",
ActionDropPlacementPolicy: "drop placement policy",
ActionModifySchemaDefaultPlacement: "modify schema default placement",
ActionAlterCacheTable: "alter cache table",
ActionAlterTablePlacement: "alter table placement",
ActionAlterCacheTable: "alter table cache",
ActionAlterNoCacheTable: "alter table nocache",
ActionAlterTableStatsOptions: "alter table statistics options",

// `ActionAlterTableAlterPartition` is removed and will never be used.
Expand Down
4 changes: 4 additions & 0 deletions parser/model/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func TestString(t *testing.T) {
{ActionTruncateTable, "truncate table"},
{ActionModifyColumn, "modify column"},
{ActionRenameTable, "rename table"},
{ActionRenameTables, "rename tables"},
{ActionSetDefaultValue, "set default value"},
{ActionCreateSchema, "create schema"},
{ActionDropSchema, "drop schema"},
Expand All @@ -297,6 +298,9 @@ func TestString(t *testing.T) {
{ActionDropColumns, "drop multi-columns"},
{ActionModifySchemaCharsetAndCollate, "modify schema charset and collate"},
{ActionDropIndexes, "drop multi-indexes"},
{ActionAlterTablePlacement, "alter table placement"},
{ActionAlterTablePartitionPolicy, "alter table partition policy"},
{ActionAlterNoCacheTable, "alter table nocache"},
}

for _, v := range acts {
Expand Down

0 comments on commit a90c988

Please sign in to comment.