Skip to main content

Module write

Module write 

Source
Expand description

Embeddable batched write path with structured partial-failure reporting.

This is the write counterpart to the streaming read cursor: a host embedding ferrule-sql as an output sink pushes rows in and gets back a structured WriteReport describing exactly which batches / rows landed and which were rejected, so it can route the rejects.

Reuse, not reinvention. Every byte of SQL this module emits comes from the existing copy/load machinery — build_insert_sql and the per-dialect conflict (ON CONFLICT / MERGE / ODKU) builders, the insert_batch bulk-vs-generic dispatcher, quote_identifier, render_value, and the transaction helpers. The write path only adds batching, back-pressure, the atomic-boundary policy, and the structured result.

Bounded, back-pressured batches. Rows are consumed from any iterator and flushed in fixed-size batches (WriteOptions::batch_size); only one batch is buffered at a time, so peak memory is O(batch_size) regardless of how many rows the source iterator yields. Pair this with the streaming RowCursor on the read side for an end-to-end bounded-memory pipe.

Structs§

RejectedBatch
A batch that failed to write as a unit.
RejectedRow
A single row rejected during a WriteOptions::isolate_failures probe. row_index is the 0-based index within the whole write.
WriteOptions
Configuration for a batched write.
WriteReport
Structured outcome of a batched write.

Enums§

BatchOutcome
What happened to one batch.
WriteMode
Host-facing conflict semantics for a batched write.

Constants§

DEFAULT_WRITE_BATCH
Default rows per write batch. Caps the in-flight buffer so a write of an unbounded row stream stays O(batch_size) in memory.

Functions§

write_rows
Write rows into table on dst in bounded back-pressured batches, returning a structured WriteReport.