Skip to content

Commit

Permalink
cherry pick pingcap#30002 to release-5.2
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <[email protected]>
  • Loading branch information
Yisaer authored and ti-srebot committed Dec 16, 2021
1 parent ae76eac commit 5e73d17
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
36 changes: 36 additions & 0 deletions executor/explain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,39 @@ func (s *testSuite2) TestExplainAnalyzeCTEMemoryAndDiskInfo(c *C) {
c.Assert(rows[4][7].(string), Not(Equals), "N/A")
c.Assert(rows[4][8].(string), Not(Equals), "N/A")
}
<<<<<<< HEAD
=======

func (s *testSuite) TestExplainStatementsSummary(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustQuery("desc select * from information_schema.statements_summary").Check(testkit.Rows(
`MemTableScan_4 10000.00 root table:STATEMENTS_SUMMARY `))
tk.MustQuery("desc select * from information_schema.statements_summary where digest is null").Check(testutil.RowsWithSep("|",
`Selection_5|8000.00|root| isnull(Column#5)`, `└─MemTableScan_6|10000.00|root|table:STATEMENTS_SUMMARY|`))
tk.MustQuery("desc select * from information_schema.statements_summary where digest = 'abcdefg'").Check(testutil.RowsWithSep(" ",
`MemTableScan_5 10000.00 root table:STATEMENTS_SUMMARY digests: ["abcdefg"]`))
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;")
}
>>>>>>> 05ccb8a20... planner: fix panic when the join key is scalarFunction (#30002)
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 @@ -286,10 +286,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 5e73d17

Please sign in to comment.