diff --git a/pkg/sql/stats/histogram.go b/pkg/sql/stats/histogram.go index d300fb00c65c..8e2a9ae2c720 100644 --- a/pkg/sql/stats/histogram.go +++ b/pkg/sql/stats/histogram.go @@ -7,6 +7,7 @@ package stats import ( "context" + "encoding/hex" "fmt" "math" "sort" @@ -135,6 +136,12 @@ func DecodeUpperBound( } else { datum, _, err = keyside.Decode(a, typ, upperBound, encoding.Ascending) } + if err != nil { + err = errors.Wrapf( + err, "decoding histogram version %d type %v value %v", + int(version), typ.Family().Name(), hex.EncodeToString(upperBound), + ) + } return datum, err } diff --git a/pkg/util/encoding/encoding.go b/pkg/util/encoding/encoding.go index 86fcaa353bf7..a2fee04b92e5 100644 --- a/pkg/util/encoding/encoding.go +++ b/pkg/util/encoding/encoding.go @@ -3162,6 +3162,9 @@ func DecodeUUIDValue(b []byte) (remaining []byte, u uuid.UUID, err error) { // DecodeUntaggedUUIDValue decodes a value encoded by EncodeUntaggedUUIDValue. func DecodeUntaggedUUIDValue(b []byte) (remaining []byte, u uuid.UUID, err error) { + if len(b) < uuidValueEncodedLength { + return b, uuid.UUID{}, errors.Errorf("invalid uuid length of %d", len(b)) + } u, err = uuid.FromBytes(b[:uuidValueEncodedLength]) if err != nil { return b, uuid.UUID{}, err