Skip to main content

read_duck_blob

Function read_duck_blob 

Source
pub unsafe fn read_duck_blob<'a>(data: *const u8, idx: usize) -> &'a [u8] ⓘ
Expand description

Reads a DuckDB BLOB value at the given row index.

Returns the raw bytes without UTF-8 validation, or an empty slice if a pointer-format value contains a null pointer. BLOB and VARCHAR share the same duckdb_string_t layout (inline for ≤ 12 bytes, pointer otherwise).

§Safety

  • data must point at a DuckDB BLOB (or VARCHAR) vector’s data buffer.
  • idx must be within bounds of the vector.
  • For pointer-format blobs, the heap data must be valid for the lifetime of the returned slice. A NULL row cannot promise that — DuckDB leaves a NULL row’s payload as it was, which can be a pointer from an earlier chunk — so do not read NULL rows.
  • The returned slice can borrow from the vector’s own data buffer (an inline blob of 12 bytes or fewer is stored there), so the vector must also outlive it — do not destroy the data chunk while the slice is live.