Skip to content

Commit

Permalink
cherry pick pingcap#17848 to release-4.0
Browse files Browse the repository at this point in the history
Signed-off-by: sre-bot <[email protected]>
  • Loading branch information
JmPotato authored and sre-bot committed Jun 12, 2020
1 parent 8405115 commit a31fdf7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 12 additions & 0 deletions expression/builtin_compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ func (s *testEvaluatorSuite) TestGreatestLeastFuncs(c *C) {
[]interface{}{tm, 123},
curTimeInt, int64(123), false, false,
},
{
[]interface{}{tm, "invalid_time_1", "invalid_time_2", tmWithFsp},
curTimeWithFspString, "invalid_time_1", false, false,
},
{
[]interface{}{tm, "invalid_time_2", "invalid_time_1", tmWithFsp},
curTimeWithFspString, "invalid_time_2", false, false,
},
{
[]interface{}{tm, "invalid_time", nil, tmWithFsp},
nil, nil, true, false,
},
{
[]interface{}{duration, "123"},
"12:59:59", "123", false, false,
Expand Down
12 changes: 7 additions & 5 deletions expression/builtin_compare_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,9 @@ func (b *builtinLeastTimeSig) vecEvalString(input *chunk.Chunk, result *chunk.Co
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
} else if !findInvalidTime[i] {
invalidValue[i] = result.GetString(i)
// Make a deep copy here.
// Otherwise invalidValue will internally change with result.
invalidValue[i] = string(result.GetBytes(i))
findInvalidTime[i] = true
}
continue
Expand All @@ -754,12 +756,12 @@ func (b *builtinLeastTimeSig) vecEvalString(input *chunk.Chunk, result *chunk.Co
}
result.ReserveString(n)
for i := 0; i < n; i++ {
if findInvalidTime[i] {
result.AppendString(invalidValue[i])
continue
}
if dst.IsNull(i) {
result.AppendNull()
continue
}
if findInvalidTime[i] {
result.AppendString(invalidValue[i])
} else {
result.AppendString(dstTimes[i].String())
}
Expand Down

0 comments on commit a31fdf7

Please sign in to comment.