Expand description
Storage-backed MongrelDB Kit crate.
This crate wraps MongrelDB core with the kit schema model, transaction semantics, query execution, and migration runner.
Re-exports§
pub use db::ApproxAggKind;pub use db::ApproxAggregate;pub use db::Database;pub use db::ExplainPlan;pub use db::IncrementalAggKind;pub use db::IncrementalAggregate;pub use db::SimilarRow;pub use error::KitError;pub use error::Result;pub use migrate::migrate;pub use query::JoinRow;pub use schema::Row;pub use txn::Transaction;
Modules§
- arrow_
util - Arrow IPC <-> JSON row helpers, shared by the embedded SQL surface
([
Database::sql] /sql_arrow/sql_rows) and the optionalremoteHTTP client. Kept here (rather than insideremote.rs) so the default embedded build — which has no HTTP dependency — can still decode the Arrow IPC bytes thatMongrelSession::runproduces. - check
- Evaluation of table/column check constraints.
- db
- Database handle for
mongreldb-kit. - error
- Error model for
mongreldb-kit. - external
- keys
- Key encoding for Kit indexes, guards, and primary keys.
- migrate
- Migration runner for
mongreldb-kit. - migrations
- Migration planning and checksums.
- planner
- Delete planning: compute the set of rows affected by a delete, including cascade, set-null, and restrict foreign-key actions.
- procedure
- pushdown
- Predicate pushdown: translate Kit
Exprpredicates into MongrelDB coreConditions so the native engine can resolve them via indexes instead of a full-scan + Rust evaluation (Kit Priority 1). - query
- Query execution for kit statements.
- schema
- Schema/value conversion between the kit model and MongrelDB core.
- trigger
- tsv
- TSV import/export for kit tables.
- txn
- Kit transaction wrapper around a MongrelDB core transaction.
- validation
- Row validation against a
Tableschema.
Structs§
- Aggregate
- A single aggregate output column, e.g.
SUM(total) AS total_sum. - Aggregate
Query - A grouped/aggregated query. Rows are scanned, optionally filtered, grouped by
group_bykey columns, reduced withaggregates, and finally filtered byhaving. With nogroup_by, the whole (filtered) table is one group. - Cache
Stats - Cumulative page-cache access counters (Priority 14: hit visibility). A hit is a lookup that returned a page visible to the snapshot; a miss is a lookup that found nothing or an entry too new for the snapshot (the caller then reads from disk).
- Check
Constraint - A named table-level check constraint.
- Check
Parse Error - Error produced when a check expression cannot be parsed.
- Column
- A column definition.
- Cte
- A common table expression: a named, materialized subquery. A later query can
read from
nameas if it were a table. - Delete
- A
DELETEstatement. - Delete
Plan - Result of planning a delete against a schema.
- Foreign
Key - A foreign-key reference from child columns to parent columns.
- Index
- An index on one or more columns.
- Insert
- An
INSERTstatement. - Join
- One joined table in a
JoinQuery. - Join
Query - A nested-loop join query. The result is a list of combined rows; each combined
row is a JSON object keyed by table alias whose values are that source’s row
object (or JSON
nullfor an unmatched right side of aLEFTjoin). Column references infilter/order_by/joinonmust be qualified (alias.column). - Migration
- A numbered schema migration.
- OrderBy
- An
ORDER BYclause. - Procedure
Spec - Restricted
Constraint - A foreign-key constraint that blocks the delete.
- RowRef
- A row identified for deletion planning.
- Schema
- A validated collection of tables.
- Select
- A
SELECTstatement. - Sequence
- A monotonic sequence allocator.
- SetNull
Update - A child row that must be updated to set its foreign-key columns to null.
- Table
- A table definition.
- Trigger
Config - Trigger
Spec - Unique
Constraint - A uniqueness constraint over one or more columns.
- Update
- An
UPDATEstatement. - Upsert
- An
UPSERTstatement. - Validation
Error - A validation failure returned by
validate_row. - View
Spec - A SQL view definition (
CREATE VIEW <name> AS <select>). Views are session-scoped in the engine (not persisted to the catalog), so a view created via a migration lives in the kit’s long-lived SQL session for the database’s lifetime — mirroring how the daemon and long-lived apps use MongrelDB. SeeDatabase::sql/refresh_sql_session. - Virtual
Table Spec
Enums§
- AggFunc
- An aggregate function.
- Column
Type - Storage/application types supported by Kit columns.
- Default
Kind - How a default value is produced when a row omits a column.
- Direction
- Sort direction for
ORDER BY. - Expr
- A query expression.
- Foreign
KeyAction - Action taken when a referenced parent row is deleted.
- Index
Build Policy - When a bulk load (
bulk_load/bulk_load_columns/bulk_load_fast) builds the live in-memory indexes. - Index
Kind - The kind of secondary index the Kit declares on a column.
- Join
Kind - The kind of join to perform.
- KeyComponent
- A single typed key component.
- Literal
- A scalar literal.
- Migration
Op - A single schema-migration operation.
- OnConflict
- SQL-style conflict behavior for
UPSERT. - Planner
Error - Errors returned by delete planning.
- Query
- Top-level query statement.
- Schema
Error - Errors that can occur while constructing a
Schema.
Constants§
- KIT_
KEY_ VERSION - Stable on-disk format version embedded in unique-key encodings.
Functions§
- decode_
pk - Decode an encoded primary key into its typed components.
- encode_
component - Encode a single typed component.
- encode_
pk - Encode a primary key value.
- encode_
row_ guard_ key - Encode a row-guard key for optimistic foreign-key checks.
- encode_
unique_ key - Encode a unique-constraint key.
- eval_
check - Evaluate a check expression against a row.
- migration_
checksum - Compute a deterministic, content-aware SHA-256 checksum for a migration.
- plan_
delete - Plan the deletion of a single row identified by its table and primary key.
- plan_
migrations - Plan the migrations that must be applied.
- quote_
ident - validate_
row - Validate a JSON row against a table definition.