Struct ReadConn
pub struct ReadConn { /* private fields */ }Expand description
A read-only connection for the daemon’s raw-read path. See the module docs for why this is separate from the coordinator’s read-write reader.
Implementations§
§impl ReadConn
impl ReadConn
pub fn open(path: impl AsRef<Path>) -> Result<ReadConn, ReplicaError>
pub fn open(path: impl AsRef<Path>) -> Result<ReadConn, ReplicaError>
Open a read-only connection at path with the default READ_TIME_BUDGET /
READ_ROW_CAP. The file must already exist (a read-only connection cannot create it),
so open this only after the writer has created + initialized the database.
pub fn open_with_limits(
path: impl AsRef<Path>,
time_budget: Duration,
row_cap: usize,
) -> Result<ReadConn, ReplicaError>
pub fn open_with_limits( path: impl AsRef<Path>, time_budget: Duration, row_cap: usize, ) -> Result<ReadConn, ReplicaError>
Like open but with explicit budgets (tests drive tiny budgets to exercise
the interrupt / row-cap paths deterministically).
pub fn open_with_budgets(
path: impl AsRef<Path>,
time_budget: Duration,
vm_budget: u64,
row_cap: usize,
) -> Result<ReadConn, ReplicaError>
pub fn open_with_budgets( path: impl AsRef<Path>, time_budget: Duration, vm_budget: u64, row_cap: usize, ) -> Result<ReadConn, ReplicaError>
Like open_with_limits, with an explicit VM-instruction budget.
Exposed primarily for deterministic boundary tests and per-SKU configuration.
pub fn flush_prepared_statement_cache(&self)
pub fn flush_prepared_statement_cache(&self)
Drop cached prepared statements after a committed schema boundary. SQLite may defer an automatic reprepare until the first step, which is too late for callers that inspect column metadata immediately after prepare.
pub fn committed_tx_id(&self) -> Result<u64, ReplicaError>
pub fn committed_tx_id(&self) -> Result<u64, ReplicaError>
The standalone WAL2 authority’s latest durable commit watermark. Public read fences compare
their canonical w:<16-hex> session cursor against this value on the read connection, so
the check observes committed state without entering (or waiting behind) the writer queue.
pub fn begin_snapshot(&self) -> Result<u64, ReplicaError>
pub fn begin_snapshot(&self) -> Result<u64, ReplicaError>
Open a stable read snapshot and return the committed-write watermark it observes. Under wal2 a reader holds its snapshot BESIDE the single writer, so a caller can page a multi-statement report through one consistent view while writes keep committing — this is what backs a standalone daemon’s read-only public transaction without occupying the writer.
BEGIN alone is deferred; the __replica_meta watermark read both MATERIALIZES the
snapshot (pinning it at the current committed head) and returns the exact TxId the
session-cursor fence compares against, so fence and snapshot cannot disagree. On a failed
watermark read the transaction is rolled back before the error returns.
A held snapshot pins wal2 checkpointing for its whole lifetime — callers MUST bound it (the daemon caps concurrent snapshot sessions and reaps them at the session deadline).
pub fn end_snapshot(&self)
pub fn end_snapshot(&self)
Release the open snapshot (idempotent; a read-only transaction’s commit and rollback are
the same operation). Statement errors — including a watchdog SQLITE_INTERRUPT — can
abort the transaction underneath us, so this rolls back only if one is still open.
pub fn snapshot_open(&self) -> bool
pub fn snapshot_open(&self) -> bool
Whether a begin_snapshot transaction is still open. SQLite may
abort it wholesale on a statement error; callers must check before advertising an open
transaction to their client.
pub fn read_sql(
&self,
sql: &str,
params: &[OwnedValue],
) -> Result<SqlReadRows, ReplicaError>
pub fn read_sql( &self, sql: &str, params: &[OwnedValue], ) -> Result<SqlReadRows, ReplicaError>
Run one raw read under the time budget + row cap and return its columns and rows. A bad
statement / type error surfaces as Err (never a panic); a budget overrun surfaces as an
interrupted Sqlite; too many rows as
ReadRejected.
pub fn execute_statement(
&self,
request: &SqlStatementRequest,
) -> Result<StatementResult, StatementRunError>
pub fn execute_statement( &self, request: &SqlStatementRequest, ) -> Result<StatementResult, StatementRunError>
Execute one statement through the public SQL result surface. The file handle is physically read-only and the shared classifier is checked before prepare, so transaction control and readonly-but-stateful statements cannot smuggle through this path.
pub fn execute_statement_batch(
&self,
requests: &[SqlStatementRequest],
) -> Result<Vec<StatementResult>, StatementRunError>
pub fn execute_statement_batch( &self, requests: &[SqlStatementRequest], ) -> Result<Vec<StatementResult>, StatementRunError>
Execute an all-read batch against one committed snapshot. The transaction is always rolled back (read-only), including when a statement fails.