Skip to content

Commit

Permalink
Merge pull request cockroachdb#63650 from mgartner/backport20.2-63481
Browse files Browse the repository at this point in the history
release-20.2: rowenc: copy JSON bytes more efficiently in DecodeUntaggedDatum
  • Loading branch information
mgartner authored Apr 26, 2021
2 parents 108ed7d + 3a0cc04 commit c159beb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/sql/rowenc/column_type_encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,9 @@ func DecodeUntaggedDatum(a *DatumAlloc, t *types.T, buf []byte) (tree.Datum, []b
// We copy the byte buffer here, because the JSON decoding is lazy, and we
// do not want to hang on to the backing byte buffer, which might be an
// entire KV batch.
data = append([]byte{}, data...)
j, err := json.FromEncoding(data)
cpy := make([]byte, len(data))
copy(cpy, data)
j, err := json.FromEncoding(cpy)
if err != nil {
return nil, b, err
}
Expand Down

0 comments on commit c159beb

Please sign in to comment.