Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#51586
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
YangKeao committed Apr 15, 2024
1 parent 1fec74b commit 4731571
Show file tree
Hide file tree
Showing 4 changed files with 1,048 additions and 2 deletions.
2 changes: 1 addition & 1 deletion expression/builtin_cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ func (b *builtinCastStringAsJSONSig) evalJSON(row chunk.Row) (res types.BinaryJS
typ := b.args[0].GetType()
if types.IsBinaryStr(typ) {
buf := []byte(val)
if typ.GetType() == mysql.TypeString {
if typ.GetType() == mysql.TypeString && typ.GetFlen() > 0 {
// the tailing zero should also be in the opaque json
buf = make([]byte, typ.GetFlen())
copy(buf, val)
Expand Down
2 changes: 1 addition & 1 deletion expression/builtin_cast_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ func (b *builtinCastStringAsJSONSig) vecEvalJSON(input *chunk.Chunk, result *chu

val := buf.GetBytes(i)
resultBuf := val
if typ.GetType() == mysql.TypeString {
if typ.GetType() == mysql.TypeString && typ.GetFlen() > 0 {
// only for BINARY: the tailing zero should also be in the opaque json
resultBuf = make([]byte, typ.GetFlen())
copy(resultBuf, val)
Expand Down

0 comments on commit 4731571

Please sign in to comment.