Skip to content

Commit

Permalink
cherry pick pingcap#30122 to release-5.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
wjhuang2016 authored and ti-srebot committed Nov 29, 2021
1 parent 90ae7cc commit 9575a84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions expression/builtin_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,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)
Expand Down
4 changes: 4 additions & 0 deletions types/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -3219,13 +3219,17 @@ func microSeconds(t *CoreTime, input string, ctx map[string]int) (string, bool)
t.setMicrosecond(0)
return input, true
}
<<<<<<< HEAD

v, ok := parseDigits(input, length)

if !ok {
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))
Expand Down

0 comments on commit 9575a84

Please sign in to comment.