Skip to content

CopyInReceiver

[Source]

Receives the result of a Session.copy_in() call. The session is passed to each callback so receivers can execute follow-up operations without needing to store a session reference.

interface tag CopyInReceiver

Public Behaviours

pg_copy_ready

[Source]

Called when the session is ready to accept the next chunk of COPY data. Called once when the server enters COPY mode, and again after each send_copy_data() call.

The receiver should respond by calling exactly one of: - session.send_copy_data(data) to send a chunk (triggers another pg_copy_ready) - session.finish_copy() to signal successful end of data - session.abort_copy(reason) to abort the operation

The flow control guarantee depends on the receiver calling exactly one of these methods per pg_copy_ready. Calling send_copy_data without a preceding pg_copy_ready bypasses the bounded-memory guarantee.

be pg_copy_ready(
  session: Session tag)

Parameters


pg_copy_complete

[Source]

Called when the COPY operation completes successfully. The count is the number of rows copied.

be pg_copy_complete(
  session: Session tag,
  count: USize val)

Parameters


pg_copy_failed

[Source]

Called when the COPY operation fails. The failure is either a server error (ErrorResponseMessage) or a client-side error (ClientQueryError) such as the session being closed, not yet authenticated, or torn down after a server protocol violation (ProtocolViolation).

be pg_copy_failed(
  session: Session tag,
  failure: (ErrorResponseMessage val | ClientQueryError))

Parameters