Menu
Public repository / 13939e59df06417f83824268593c175461b35fce
AkurAI-Framework / crates/sqlexec/src/lib.rs
Latest change d971623579ac6cb425eea3ca33f24af5983c18b2 - feat(sqlexec): SQL executor over the storage B+tree (CREATE/INSERT/SELECT) by Ólafur Búi Ólafsson
//! AkurAI-Framework SQL executor — pure `std`, zero external dependencies.
//!
//! The back half of the query engine. Where [`akurai_sql`] turns SQL text into
//! an AST, this crate *runs* that AST over the [`akurai_storage`] B+tree:
//! it owns a catalog of table schemas, a typed row codec, a `WHERE` evaluator,
//! and an [`Executor`] that ties them together.
//!
//! ```no_run
//! use akurai_sqlexec::{Executor, Outcome};
//!
//! let mut db = Executor::open("app.db").unwrap();
//! db.execute("CREATE TABLE users (id INTEGER NOT NULL, name TEXT)").unwrap();
//! db.execute("INSERT INTO users (id, name) VALUES (1, 'ada')").unwrap();
//! if let Outcome::Rows(rs) = db.execute("SELECT name FROM users WHERE id = 1").unwrap() {
//! assert_eq!(rs.columns, vec!["name".to_string()]);
//! }
//! ```
//!
//! ## Supported statements
//!
//! - `CREATE TABLE` — registers a schema (column names, types, `NOT NULL`),
//! persisted in the tree so it survives reopening.
//! - `INSERT` — validates against the schema and writes one typed row under an
//! auto-incrementing rowid.
//! - `SELECT` — scans a table, applies `WHERE`, `ORDER BY`, and `LIMIT`, and
//! projects `*` or named columns into a [`ResultSet`].
//!
//! `UPDATE`/`DELETE` execution, joins, indexes, and multi-statement
//! transactions are deliberately out of scope for this slice.
#![forbid(unsafe_code)]
mod catalog;
mod error;
mod eval;
mod exec;
mod row;
mod value;
pub use error::ExecError;
pub use exec::{Executor, Outcome};
pub use value::Value;
/// The rows a `SELECT` produces, plus the names of the projected columns.
#[derive(Debug, Clone, PartialEq)]
pub struct ResultSet {
/// Projected column names, left to right.
pub columns: Vec<String>,
/// Result rows; each is one [`Value`] per projected column.
pub rows: Vec<Vec<Value>>,
}