expression: correct constant propagation for collation (#22666)
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
This commit is contained in:
@ -20,7 +20,6 @@ import (
|
||||
"github.com/pingcap/tidb/sessionctx"
|
||||
"github.com/pingcap/tidb/types"
|
||||
"github.com/pingcap/tidb/util/chunk"
|
||||
"github.com/pingcap/tidb/util/collate"
|
||||
"github.com/pingcap/tidb/util/disjointset"
|
||||
"github.com/pingcap/tidb/util/logutil"
|
||||
"go.uber.org/zap"
|
||||
@ -88,7 +87,7 @@ func validEqualCondHelper(ctx sessionctx.Context, eq *ScalarFunction, colIsLeft
|
||||
if ContainMutableConst(ctx, []Expression{con}) {
|
||||
return nil, nil
|
||||
}
|
||||
if !collate.CompatibleCollate(col.GetType().Collate, con.GetType().Collate) {
|
||||
if col.GetType().Collate != con.GetType().Collate {
|
||||
return nil, nil
|
||||
}
|
||||
return col, con
|
||||
|
||||
@ -6412,6 +6412,13 @@ func (s *testIntegrationSerialSuite) TestCollateConstantPropagation(c *C) {
|
||||
tk.MustExec("insert into t1 values ('ß', 's');")
|
||||
tk.MustExec("insert into t2 values ('s', 's')")
|
||||
tk.MustQuery("select * from t1 left join t2 on t1.a = t2.a collate utf8mb4_unicode_ci where t1.a = 's';").Check(testkit.Rows("ß s <nil> <nil>"))
|
||||
tk.MustExec("drop table if exists t1, t2;")
|
||||
tk.MustExec("create table t1(a char(10) collate utf8mb4_general_ci, index (a));")
|
||||
tk.MustExec("create table t2(a char(10) collate utf8_bin, index (a));")
|
||||
tk.MustExec("insert into t1 values ('a');")
|
||||
tk.MustExec("insert into t2 values ('A');")
|
||||
tk.MustExec("set names utf8 collate utf8_general_ci;")
|
||||
tk.MustQuery("select * from t1, t2 where t1.a=t2.a and t1.a= 'a';").Check(testkit.Rows("a A"))
|
||||
}
|
||||
|
||||
func (s *testIntegrationSuite2) TestIssue17791(c *C) {
|
||||
|
||||
Reference in New Issue
Block a user