Unverified Commit 78006812 authored by ti-srebot's avatar ti-srebot Committed by GitHub
Browse files

cherry pick #21213 to release-4.0 (#21380)

Signed-off-by: default avatarti-srebot <ti-srebot@pingcap.com>
Co-authored-by: default avatarKenan Yao <cauchy1992@gmail.com>
parent a0a70da6
Showing with 16 additions and 1 deletion
+16 -1
...@@ -1571,6 +1571,17 @@ func (s *testIntegrationSerialSuite) TestIssue20710(c *C) { ...@@ -1571,6 +1571,17 @@ func (s *testIntegrationSerialSuite) TestIssue20710(c *C) {
} }
} }
func (s *testIntegrationSuite) TestQueryBlockTableAliasInHint(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
c.Assert(tk.HasPlan("select /*+ HASH_JOIN(@sel_1 t2) */ * FROM (select 1) t1 NATURAL LEFT JOIN (select 2) t2", "HashJoin"), IsTrue)
tk.MustQuery("select /*+ HASH_JOIN(@sel_1 t2) */ * FROM (select 1) t1 NATURAL LEFT JOIN (select 2) t2").Check(testkit.Rows(
"1 2",
))
c.Assert(tk.Se.GetSessionVars().StmtCtx.GetWarnings(), HasLen, 0)
}
func (s *testIntegrationSuite) TestIssue10448(c *C) { func (s *testIntegrationSuite) TestIssue10448(c *C) {
tk := testkit.NewTestKit(c, s.store) tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test") tk.MustExec("use test")
......
...@@ -484,7 +484,11 @@ func extractTableAlias(p Plan, parentOffset int) *hintTableInfo { ...@@ -484,7 +484,11 @@ func extractTableAlias(p Plan, parentOffset int) *hintTableInfo {
if blockOffset != parentOffset && blockAsNames != nil && blockAsNames[blockOffset].TableName.L != "" { if blockOffset != parentOffset && blockAsNames != nil && blockAsNames[blockOffset].TableName.L != "" {
blockOffset = parentOffset blockOffset = parentOffset
} }
return &hintTableInfo{dbName: firstName.DBName, tblName: firstName.TblName, selectOffset: blockOffset} dbName := firstName.DBName
if dbName.L == "" {
dbName = model.NewCIStr(p.SCtx().GetSessionVars().CurrentDB)
}
return &hintTableInfo{dbName: dbName, tblName: firstName.TblName, selectOffset: blockOffset}
} }
return nil return nil
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment