From 7a575f3b9fb5edd891f5af4197c92644643e71bb Mon Sep 17 00:00:00 2001 From: wjHuang Date: Mon, 29 Nov 2021 16:29:52 +0800 Subject: [PATCH] cherry pick #30122 to release-5.2 Signed-off-by: ti-srebot --- expression/builtin_time_test.go | 1 + types/time.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/expression/builtin_time_test.go b/expression/builtin_time_test.go index b8ef7f9d4a36e..3f0707064eb90 100644 --- a/expression/builtin_time_test.go +++ b/expression/builtin_time_test.go @@ -1413,6 +1413,7 @@ func (s *testEvaluatorSuite) TestStrToDate(c *C) { {"15-01-2001 1:59:58.", "%d-%m-%Y %H:%i:%s.%f", true, types.KindMysqlTime, time.Date(2001, 1, 15, 1, 59, 58, 000000000, time.Local)}, {"15-01-2001 1:9:8.999", "%d-%m-%Y %H:%i:%s.%f", true, types.KindMysqlTime, time.Date(2001, 1, 15, 1, 9, 8, 999000000, time.Local)}, {"15-01-2001 1:9:8.999", "%d-%m-%Y %H:%i:%S.%f", true, types.KindMysqlTime, time.Date(2001, 1, 15, 1, 9, 8, 999000000, time.Local)}, + {"2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f", true, types.KindMysqlTime, time.Date(2003, 1, 2, 10, 11, 12, 1200000, time.Local)}, {"2003-01-02 10:11:12 PM", "%Y-%m-%d %H:%i:%S %p", false, types.KindMysqlTime, time.Time{}}, {"10:20:10AM", "%H:%i:%S%p", false, types.KindMysqlTime, time.Time{}}, // test %@(skip alpha), %#(skip number), %.(skip punct) diff --git a/types/time.go b/types/time.go index ddca9a6333a81..5ff62ba788f8d 100644 --- a/types/time.go +++ b/types/time.go @@ -3224,6 +3224,7 @@ func microSeconds(t *CoreTime, input string, ctx map[string]int) (string, bool) t.setMicrosecond(0) return input, true } +<<<<<<< HEAD v, ok := parseDigits(input, length) @@ -3231,6 +3232,9 @@ func microSeconds(t *CoreTime, input string, ctx map[string]int) (string, bool) return input, false } for v > 0 && v*10 < 1000000 { +======= + for i := step; i < 6; i++ { +>>>>>>> 352811dfc... types: fix wrong str_to_date() microseconds with leading zeros are not converted correctly (#30122) v *= 10 } t.setMicrosecond(uint32(v))