MCPcopy
hub / github.com/jackc/pgx / Decode

Method Decode

pgproto3/copy_out_response.go:22–44  ·  view source on GitHub ↗

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

(src []byte)

Source from the content-addressed store, hash-verified

20// Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
21// type identifier and 4 byte message length.
22func (dst *CopyOutResponse) Decode(src []byte) error {
23 buf := bytes.NewBuffer(src)
24
25 if buf.Len() < 3 {
26 return &invalidMessageFormatErr{messageType: "CopyOutResponse"}
27 }
28
29 overallFormat := buf.Next(1)[0]
30
31 columnCount := int(binary.BigEndian.Uint16(buf.Next(2)))
32 if buf.Len() != columnCount*2 {
33 return &invalidMessageFormatErr{messageType: "CopyOutResponse"}
34 }
35
36 columnFormatCodes := make([]uint16, columnCount)
37 for i := range columnCount {
38 columnFormatCodes[i] = binary.BigEndian.Uint16(buf.Next(2))
39 }
40
41 *dst = CopyOutResponse{OverallFormat: overallFormat, ColumnFormatCodes: columnFormatCodes}
42
43 return nil
44}
45
46// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
47func (src *CopyOutResponse) Encode(dst []byte) ([]byte, error) {

Callers 1

FuzzCopyOutResponseFunction · 0.95

Calls 3

Uint16Method · 0.80
LenMethod · 0.65
NextMethod · 0.65

Tested by 1

FuzzCopyOutResponseFunction · 0.76