MCPcopy
hub / github.com/brianc/node-postgres / bind

Function bind

packages/pg-protocol/src/serializer.ts:144–171  ·  view source on GitHub ↗
(config: BindOpts = {})

Source from the content-addressed store, hash-verified

142}
143
144const bind = (config: BindOpts = {}): Buffer => {
145 // normalize config
146 const portal = config.portal || ''
147 const statement = config.statement || ''
148 const binary = config.binary || false
149 const values = config.values || emptyArray
150 const len = values.length
151
152 writer.addCString(portal).addCString(statement)
153 writer.addInt16(len)
154
155 try {
156 writeValues(values, config.valueMapper)
157 } catch (err) {
158 writer.clear()
159 paramWriter.clear()
160 throw err
161 }
162
163 writer.addInt16(len)
164 writer.add(paramWriter.flush())
165
166 // all results use the same format code
167 writer.addInt16(1)
168 // format code
169 writer.addInt16(binary ? ParamType.BINARY : ParamType.STRING)
170 return writer.flush(code.bind)
171}
172
173type ExecOpts = {
174 portal?: string

Callers

nothing calls this directly

Calls 6

writeValuesFunction · 0.85
clearMethod · 0.80
addCStringMethod · 0.45
addInt16Method · 0.45
addMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected