Skip to content

Commit

Permalink
expression: compatibility is changed (#30653)
Browse files Browse the repository at this point in the history
close #19150
  • Loading branch information
Tangruilin authored Jan 5, 2022
1 parent ba59021 commit 1a6564b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions expression/builtin_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/logutil"
"github.com/pingcap/tidb/util/parser"
"github.com/pingcap/tipb/go-tipb"
"github.com/tikv/client-go/v2/oracle"
"go.uber.org/zap"
Expand Down Expand Up @@ -5773,6 +5774,16 @@ func (b *builtinAddStringAndStringSig) evalString(row chunk.Row) (result string,
}
return "", true, err
}

check := arg1Str
_, check, err = parser.Number(parser.Space0(check))
if err == nil {
check, err = parser.Char(check, '-')
if strings.Compare(check, "") != 0 && err == nil {
return "", true, nil
}
}

if isDuration(arg0) {
result, err = strDurationAddDuration(sc, arg0, arg1)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions expression/builtin_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ func TestAddTimeSig(t *testing.T) {
{"2018-08-16 20:21:01", "00:00:00.000001", "2018-08-16 20:21:01.000001"},
{"1", "xxcvadfgasd", ""},
{"xxcvadfgasd", "1", ""},
{"2020-05-13 14:01:24", "2020-04-29 05:11:19", ""},
}
fc := funcs[ast.AddTime]
for _, c := range tbl {
Expand Down

0 comments on commit 1a6564b

Please sign in to comment.