Skip to content

Commit

Permalink
Merge branch 'master' into from_binary
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala committed Nov 24, 2021
2 parents 691c843 + a90c988 commit f2568eb
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 2 deletions.
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
21 changes: 21 additions & 0 deletions executor/explain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,24 @@ func (s *testSuite) TestExplainStatementsSummary(c *C) {
tk.MustQuery("desc select * from information_schema.statements_summary where digest in ('a','b','c')").Check(testutil.RowsWithSep(" ",
`MemTableScan_5 10000.00 root table:STATEMENTS_SUMMARY digests: ["a","b","c"]`))
}

func (s *testSuite) TestFix29401(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec("drop table if exists tt123;")
tk.MustExec(`CREATE TABLE tt123 (
id int(11) NOT NULL,
a bigint(20) DEFAULT NULL,
b char(20) DEFAULT NULL,
c datetime DEFAULT NULL,
d double DEFAULT NULL,
e json DEFAULT NULL,
f decimal(40,6) DEFAULT NULL,
PRIMARY KEY (id) /*T![clustered_index] CLUSTERED */,
KEY a (a),
KEY b (b),
KEY c (c),
KEY d (d),
KEY f (f)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;`)
tk.MustExec(" explain select /*+ inl_hash_join(t1) */ * from tt123 t1 join tt123 t2 on t1.b=t2.e;")
}
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
6 changes: 5 additions & 1 deletion planner/core/rule_predicate_push_down.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,14 @@ func (p *LogicalProjection) appendExpr(expr expression.Expression) *expression.C

col := &expression.Column{
UniqueID: p.ctx.GetSessionVars().AllocPlanColumnID(),
RetType: expr.GetType(),
RetType: expr.GetType().Clone(),
}
col.SetCoercibility(expr.Coercibility())
p.schema.Append(col)
// reset ParseToJSONFlag in order to keep the flag away from json column
if col.GetType().Tp == mysql.TypeJSON {
col.GetType().Flag &= ^mysql.ParseToJSONFlag
}
return col
}

Expand Down

0 comments on commit f2568eb

Please sign in to comment.