executor: fix hash join between datetime and timestamp (#25915)
This commit is contained in:
@ -2592,3 +2592,20 @@ func (s *testSuiteJoinSerial) TestIssue20219(c *C) {
|
||||
tk.MustQuery("select /*+ inl_join(s)*/ t.a from t left join s on t.a = s.a;").Check(testkit.Rows("i", "j"))
|
||||
tk.MustQuery("show warnings").Check(testkit.Rows())
|
||||
}
|
||||
|
||||
func (s *testSuiteJoinSerial) TestIssue25902(c *C) {
|
||||
tk := testkit.NewTestKitWithInit(c, s.store)
|
||||
tk.MustExec("drop table if exists tt1,tt2,tt3; ")
|
||||
tk.MustExec("create table tt1 (ts timestamp);")
|
||||
tk.MustExec("create table tt2 (ts varchar(32));")
|
||||
tk.MustExec("create table tt3 (ts datetime);")
|
||||
tk.MustExec("insert into tt1 values (\"2001-01-01 00:00:00\");")
|
||||
tk.MustExec("insert into tt2 values (\"2001-01-01 00:00:00\");")
|
||||
tk.MustExec("insert into tt3 values (\"2001-01-01 00:00:00\");")
|
||||
tk.MustQuery("select * from tt1 where ts in (select ts from tt2);").Check(testkit.Rows("2001-01-01 00:00:00"))
|
||||
tk.MustQuery("select * from tt1 where ts in (select ts from tt3);").Check(testkit.Rows("2001-01-01 00:00:00"))
|
||||
tk.MustExec("set @tmp=(select @@session.time_zone);")
|
||||
tk.MustExec("set @@session.time_zone = '+10:00';")
|
||||
tk.MustQuery("select * from tt1 where ts in (select ts from tt2);").Check(testkit.Rows())
|
||||
tk.MustExec("set @@session.time_zone = @tmp;")
|
||||
}
|
||||
|
||||
@ -330,14 +330,7 @@ func encodeHashChunkRowIdx(sc *stmtctx.StatementContext, row chunk.Row, tp *type
|
||||
case mysql.TypeDate, mysql.TypeDatetime, mysql.TypeTimestamp:
|
||||
flag = uintFlag
|
||||
t := row.GetTime(idx)
|
||||
// Encoding timestamp need to consider timezone.
|
||||
// If it's not in UTC, transform to UTC first.
|
||||
if t.Type() == mysql.TypeTimestamp && sc.TimeZone != time.UTC {
|
||||
err = t.ConvertTimeZone(sc.TimeZone, time.UTC)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var v uint64
|
||||
v, err = t.ToPackedUint()
|
||||
if err != nil {
|
||||
@ -507,14 +500,7 @@ func HashChunkSelected(sc *stmtctx.StatementContext, h []hash.Hash64, chk *chunk
|
||||
isNull[i] = !ignoreNull
|
||||
} else {
|
||||
buf[0] = uintFlag
|
||||
// Encoding timestamp need to consider timezone.
|
||||
// If it's not in UTC, transform to UTC first.
|
||||
if t.Type() == mysql.TypeTimestamp && sc.TimeZone != time.UTC {
|
||||
err = t.ConvertTimeZone(sc.TimeZone, time.UTC)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var v uint64
|
||||
v, err = t.ToPackedUint()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user