Expand description
SPG execution engine — v0.3 wires the SQL front-end to the in-memory
storage layer. Implements CREATE TABLE, single-row INSERT VALUES, and
SELECT * FROM <table> (no WHERE yet — that lands in v0.4 alongside
expression evaluation against rows).
Re-exports§
pub use crate::users::Role;pub use crate::users::ScramSecrets;pub use crate::users::UserError;pub use crate::users::UserStore;
Modules§
- aggregate
- Aggregate executor.
- describe
- v6.3.3 — Describe statement pre-Execute.
- eval
- Expression evaluator. Given a parsed
Expr, aRow, and the row’s column schema, produce aValue. v0.4 implements: - json
- v4.14 minimal JSON parser for the
->/->>operators. - memoize
- v6.2.6 — Memoize cache for correlated subqueries.
- plan_
cache - v6.3.0 — Engine-level plan cache.
- publications
- v6.1.2 — logical-replication publication catalog.
- query_
stats - v6.5.1 — per-distinct-SQL LRU stat collector.
- reorder
- v6.2.3 — JOIN reorder planner pass.
- selectivity
- v6.2.2 — selectivity estimation over per-column statistics.
- statistics
- v6.2.0 — per-column statistics for the cost-based optimizer.
- subscriptions
- v6.1.4 — logical-replication subscription catalog.
- users
- User table + RBAC types for v4.1.
Structs§
- Activity
Row - v6.5.2 — one row of
spg_stat_activity. Engine-public so spg-server can construct rows without re-exporting internal dispatch types. - Audit
Row - v6.5.3 — one row of
spg_audit_chain. Engine-public so spg-server can construct rows directly fromAuditEntry. - Cancel
Token - v4.5 cooperative cancellation token. A long-running SELECT /
UPDATE / DELETE checks
is_cancelledat row-loop checkpoints and bails withEngineError::Cancelled. The host (spg-server) creates anAtomicBoolper query, spawns a watchdog thread that sets it afterSPG_QUERY_TIMEOUT_MS, and passes it viaexecute_with_cancel/execute_readonly_with_cancel. - Engine
- TxId
- v4.41.1 opaque transaction handle. Returned by
Engine::alloc_tx_id, threaded throughEngine::execute_inso dispatch can identify which in-flight TX a statement belongs to.IMPLICIT_TXis the reserved slot every legacy caller — engine self-tests, spg-cli, spg-embedded, startup replay — implicitly uses through the unchangedEngine::execute(sql)API. v4.41.1 keeps at most one active slot at runtime (dispatch holdsengine.write()across the wrap, same as v4.34); the map shape is here to let v4.42 turn on N in-flight implicit TXs without reshuffling the engine internals.
Enums§
- Engine
Error - All errors the engine can return.
- Query
Result - Result of executing one statement.
Constants§
- COMPACTION_
TARGET_ DEFAULT_ BYTES - v6.7.3 — default segment-size threshold used by
COMPACT COLD SEGMENTSwhen no explicit target is supplied. Segments whoseOwnedSegment::bytes().len()is strictly less than this value are eligible to merge. spg-server readsSPG_COMPACTION_TARGET_SEGMENT_BYTESto override. - IMPLICIT_
TX - Reserved slot used by
Engine::execute(sql)— the legacy single- global-shadow path. Newalloc_tx_idhandles start at 1.
Type Aliases§
- Activity
Provider - v6.5.2 — provider callback type. Fresh snapshot returned each call; engine doesn’t cache the slice.
- Audit
Chain Provider - v6.5.3 — chain-table provider + verifier. spg-server registers
fn pointers that snapshot / verify the audit log.
verifyreturns(verified_count, broken_at_seq)—broken_at_seqis-1on a clean chain. - Audit
Verifier - ClockFn
- The execution engine. Holds the catalog and (later) other server-scope
state.
Engine::new()is intentionally cheap so callers can construct one per database, per test. Function pointer that returns “now” as microseconds since Unix epoch. The engine isno_std, so it can’t reach forstd::timeitself — callers (spg-server, the sqllogictest runner) inject a concrete implementation.NonemeansNOW()/CURRENT_*raiseUnsupported. - SaltFn
- Function pointer that produces 16 cryptographically random bytes.
Like
ClockFn, the engine isno_stdand can’t reach for /dev/urandom itself — host (spg-server) injects an OS-backed source.Nonemeans SQL-drivenCREATE USERfalls back to a deterministic salt derived from the username (acceptable in tests; the server always installs a real RNG so production paths never see this). - Slow
Query Logger - v6.5.6 — callback signature for slow-query log emission. Called
with
(sql, elapsed_us)once per successful execute that crosses the threshold.