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

Method Encode

pgproto3/row_description.go:103–123  ·  view source on GitHub ↗

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

(dst []byte)

Source from the content-addressed store, hash-verified

101
102// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
103func (src *RowDescription) Encode(dst []byte) ([]byte, error) {
104 dst, sp := beginMessage(dst, 'T')
105
106 if len(src.Fields) > math.MaxUint16 {
107 return nil, errors.New("too many fields")
108 }
109 dst = pgio.AppendUint16(dst, uint16(len(src.Fields)))
110 for _, fd := range src.Fields {
111 dst = append(dst, fd.Name...)
112 dst = append(dst, 0)
113
114 dst = pgio.AppendUint32(dst, fd.TableOID)
115 dst = pgio.AppendUint16(dst, fd.TableAttributeNumber)
116 dst = pgio.AppendUint32(dst, fd.DataTypeOID)
117 dst = pgio.AppendInt16(dst, fd.DataTypeSize)
118 dst = pgio.AppendInt32(dst, fd.TypeModifier)
119 dst = pgio.AppendInt16(dst, fd.Format)
120 }
121
122 return finishMessage(dst, sp)
123}
124
125// MarshalJSON implements encoding/json.Marshaler.
126func (src RowDescription) MarshalJSON() ([]byte, error) {

Callers

nothing calls this directly

Calls 6

AppendUint16Function · 0.92
AppendUint32Function · 0.92
AppendInt16Function · 0.92
AppendInt32Function · 0.92
beginMessageFunction · 0.85
finishMessageFunction · 0.85

Tested by

no test coverage detected