diff --git a/expression/builtin_time.go b/expression/builtin_time.go index d9cdcb9504e4b..0c0e4b9e3b4f5 100644 --- a/expression/builtin_time.go +++ b/expression/builtin_time.go @@ -5937,7 +5937,7 @@ func (b *builtinConvertTzSig) convertTz(dt types.Time, fromTzStr, toTzStr string } } - t, err := dt.GoTime(fromTz) + t, err := dt.AdjustedGoTime(fromTz) if err != nil { return types.ZeroTime, true, nil } diff --git a/expression/builtin_time_test.go b/expression/builtin_time_test.go index 4d9c610400565..e50aaae3793b8 100644 --- a/expression/builtin_time_test.go +++ b/expression/builtin_time_test.go @@ -2729,7 +2729,7 @@ func TestConvertTz(t *testing.T) { {"2021-10-31 02:59:59", "Europe/Amsterdam", "+02:00", true, "2021-10-31 03:59:59"}, {"2021-10-31 02:00:00", "Europe/Amsterdam", "+01:00", true, "2021-10-31 02:00:00"}, {"2021-10-31 03:00:00", "Europe/Amsterdam", "+01:00", true, "2021-10-31 03:00:00"}, - {"2021-03-28 02:30:00", "Europe/Amsterdam", "UTC", true, ""}, + {"2021-03-28 02:30:00", "Europe/Amsterdam", "UTC", true, "2021-03-28 01:00:00"}, {"2021-10-22 10:00:00", "Europe/Tallinn", "SYSTEM", true, t1.In(loc2).Format("2006-01-02 15:04:00")}, {"2021-10-22 10:00:00", "SYSTEM", "Europe/Tallinn", true, t2.In(loc1).Format("2006-01-02 15:04:00")}, } diff --git a/expression/integration_test.go b/expression/integration_test.go index d32a72c9db505..23176117ba25f 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -6915,6 +6915,16 @@ func TestIssue28739(t *testing.T) { " ")) } +func TestIssue30081(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec(`USE test`) + tk.MustQuery(`SELECT CONVERT_TZ('2007-03-11 2:00:00','US/Eastern','US/Central');`). + Check(testkit.Rows(`2007-03-11 01:00:00`)) + tk.MustQuery(`SELECT CONVERT_TZ('2007-03-11 3:00:00','US/Eastern','US/Central');`). + Check(testkit.Rows(`2007-03-11 01:00:00`)) +} + func TestIssue30326(t *testing.T) { store, clean := testkit.CreateMockStore(t) defer clean()