MCPcopy Index your code
hub / github.com/pingcap/tidb / CreateBinaryJSONWithCheck

Function CreateBinaryJSONWithCheck

pkg/types/json_binary.go:648–659  ·  view source on GitHub ↗

CreateBinaryJSONWithCheck creates a BinaryJSON from interface with error check.

(in any)

Source from the content-addressed store, hash-verified

646
647// CreateBinaryJSONWithCheck creates a BinaryJSON from interface with error check.
648func CreateBinaryJSONWithCheck(in any) (BinaryJSON, error) {
649 typeCode, buf, err := appendBinaryJSON(nil, in)
650 if err != nil {
651 return BinaryJSON{}, err
652 }
653 bj := BinaryJSON{TypeCode: typeCode, Value: buf}
654 // GetElemDepth always returns +1.
655 if bj.GetElemDepth()-1 > maxJSONDepth {
656 return BinaryJSON{}, ErrJSONDocumentTooDeep
657 }
658 return bj, nil
659}
660
661func appendBinaryJSON(buf []byte, in any) (JSONTypeCode, []byte, error) {
662 var typeCode byte

Callers 9

vecEvalJSONMethod · 0.92
vecEvalJSONMethod · 0.92
evalJSONMethod · 0.92
evalJSONMethod · 0.92
appendJSONArrayMethod · 0.92
UnmarshalJSONMethod · 0.85
CreateBinaryJSONFunction · 0.85

Calls 2

GetElemDepthMethod · 0.95
appendBinaryJSONFunction · 0.85

Tested by

no test coverage detected