MCPcopy Create free account
hub / github.com/PostHog/duckgres / buildBindBody

Function buildBindBody

server/conn_bind_test.go:13–25  ·  view source on GitHub ↗

buildBindBody constructs a Bind message body (without the 'B' type byte and length header): portal name, statement name, no format codes, one parameter with the given declared length and actual data, no result format codes.

(portal, stmt string, declaredLen int32, data []byte)

Source from the content-addressed store, hash-verified

11// length header): portal name, statement name, no format codes, one parameter
12// with the given declared length and actual data, no result format codes.
13func buildBindBody(portal, stmt string, declaredLen int32, data []byte) []byte {
14 var buf bytes.Buffer
15 buf.WriteString(portal)
16 buf.WriteByte(0)
17 buf.WriteString(stmt)
18 buf.WriteByte(0)
19 _ = binary.Write(&buf, binary.BigEndian, int16(0)) // no param format codes
20 _ = binary.Write(&buf, binary.BigEndian, int16(1)) // one parameter
21 _ = binary.Write(&buf, binary.BigEndian, declaredLen)
22 buf.Write(data)
23 _ = binary.Write(&buf, binary.BigEndian, int16(0)) // no result format codes
24 return buf.Bytes()
25}
26
27// bindMessageBody builds a Bind message body (without the type byte and
28// length prefix) for portal/statement names with raw trailing fields.

Calls 1

WriteMethod · 0.45

Tested by

no test coverage detected