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

Function WriteCopyInResponse

server/wire/protocol.go:362–389  ·  view source on GitHub ↗

writeCopyInResponse tells client to send COPY data

(w io.Writer, numColumns int16, textFormat bool)

Source from the content-addressed store, hash-verified

360 data = append(data, 1)
361 }
362
363 // Number of columns
364 colBytes := make([]byte, 2)
365 binary.BigEndian.PutUint16(colBytes, uint16(numColumns))
366 data = append(data, colBytes...)
367
368 // Format for each column (0=text)
369 for i := int16(0); i < numColumns; i++ {
370 formatBytes := make([]byte, 2)
371 if textFormat {
372 binary.BigEndian.PutUint16(formatBytes, 0)
373 } else {
374 binary.BigEndian.PutUint16(formatBytes, 1)
375 }
376 data = append(data, formatBytes...)
377 }
378
379 return WriteMessage(w, MsgCopyOutResponse, data)
380}
381
382// writeCopyInResponse tells client to send COPY data
383func WriteCopyInResponse(w io.Writer, numColumns int16, textFormat bool) error {
384 var data []byte
385
386 // Overall format (0=text)
387 if textFormat {
388 data = append(data, 0)
389 } else {
390 data = append(data, 1)
391 }
392

Callers 3

handleCopyInMethod · 0.92
handleCopyInBinaryMethod · 0.92

Calls 1

WriteMessageFunction · 0.85

Tested by

no test coverage detected