MCPcopy Index your code
hub / github.com/electric-sql/pglite / execute

Function execute

packages/pg-protocol/src/serializer.ts:201–220  ·  view source on GitHub ↗
(config?: ExecOpts)

Source from the content-addressed store, hash-verified

199])
200
201const execute = (config?: ExecOpts): Uint8Array => {
202 // this is the happy path for most queries
203 if (!config || (!config.portal && !config.rows)) {
204 return emptyExecute
205 }
206
207 const portal = config.portal ?? ''
208 const rows = config.rows ?? 0
209
210 const portalLength = byteLengthUtf8(portal)
211 const len = 4 + portalLength + 1 + 4
212 // one extra bit for code
213 const bufferView = new DataView(new ArrayBuffer(1 + len))
214 bufferView.setUint8(0, code.execute)
215 bufferView.setInt32(1, len, false)
216 new TextEncoder().encodeInto(portal, new Uint8Array(bufferView.buffer, 5))
217 bufferView.setUint8(portalLength + 5, 0) // null terminate portal cString
218 bufferView.setUint32(bufferView.byteLength - 4, rows, false)
219 return new Uint8Array(bufferView.buffer)
220}
221
222const cancel = (processID: number, secretKey: number): Uint8Array => {
223 const bufferView = new DataView(new ArrayBuffer(16))

Callers

nothing calls this directly

Calls 1

byteLengthUtf8Function · 0.90

Tested by

no test coverage detected