Skip to main content

Module sql

Module sql 

Source
Expand description

The shared SQL backend (sql feature): the NamespaceStore contract implemented once over SQLite, on the tiny synchronous SqlConn trait.

rusqlite and Durable Object SQLite can both implement SqlConn, so a native backend and every per-partition Durable Object run the same statements and the same physical schema migrations. SQL is an internal detail of this backend: nothing above NamespaceStore sees it.

Every statement stays within Durable Object limits: at most MAX_BOUND_PARAMS bound parameters, and no transaction-control statement (SqlConn::transaction owns atomicity).

Modules§

schema
The physical schema and its versioned, forward-only migrations.

Structs§

Capacity
A store’s size cap.
SqlKvStore
The NamespaceStore contract (and StoreMaintenance) over any SqlConn: full capabilities, every batch one SqlConn::transaction.
TimerCursor
One raw timer-index row and the exclusive position for its successor.

Enums§

SqlError
Why a SQL call failed. The backend’s own message never reaches a client: it is kept Redacted for the server-side log only.
SqlValue
A bound parameter or a result column: the four storage classes both rusqlite and Durable Object SQL bind (no REAL).

Constants§

DEFAULT_PAGE_SIZE
The page size the default reserve assumes: SQLite’s default and a Durable Object’s. A database with larger pages sets its reserve with Capacity::with_reserve and reserve_floor.
GET_MANY_CHUNK
Keys per get_many statement: one partition parameter plus this many keys stays far below super::MAX_BOUND_PARAMS.
MAX_BOUND_PARAMS
Most bound parameters in one statement: the Durable Object SQL limit (https://developers.cloudflare.com/durable-objects/platform/limits/). SqlKvStore never binds more.
RESERVE_TREE_DEPTH
The b-tree depth the reserve plans for.
TIMER_WINDOW_AFTER
Resume strictly after an index position; no aggregation or implicit wrap.
TIMER_WINDOW_START
Bounded first window over the existing timer index, including raw malformed keys.

Traits§

SqlConn
A synchronous SQL connection: a cheaply cloneable handle (rusqlite: a shared, locked Connection; a Durable Object: its storage handle).

Functions§

batch_growth_bytes
The most one batch can grow a database with page_size-byte pages (see the module docs).
reserve_floor
The smallest safe reserve: two batches’ growth (a put batch that starts just below the soft limit, then a delete-only batch).

Type Aliases§

Row
One result row, its columns in select order.
TxFn
The transaction body SqlConn::transaction runs: owned and 'static.