mod aggregate;
mod coerce;
mod condition;
mod dml;
mod scope;
mod select;
#[cfg(test)]
mod tests;
use wasm_dbms_api::prelude::{
AggregateFunction, ColumnDef, DeleteBehavior, Filter, JoinColumnDef, Query,
};
pub(crate) use self::dml::{delete, insert, update};
pub(crate) use self::select::select;
pub(crate) type Catalog<'a> = dyn Fn(&str) -> Option<&'static [ColumnDef]> + 'a;
#[derive(Debug)]
pub(crate) enum SelectPlan {
Table(TablePlan),
Join(TablePlan),
Aggregate(AggregatePlan),
}
#[derive(Debug)]
pub(crate) struct TablePlan {
pub(crate) table: String,
pub(crate) query: Query,
pub(crate) projection: Option<Vec<OutputColumn>>,
}
#[derive(Debug)]
pub(crate) struct OutputColumn {
pub(crate) table: Option<String>,
pub(crate) column: String,
pub(crate) name: String,
}
#[derive(Debug)]
pub(crate) struct AggregatePlan {
pub(crate) table: String,
pub(crate) query: Query,
pub(crate) aggregates: Vec<AggregateFunction>,
pub(crate) outputs: Vec<AggregateOutput>,
}
#[derive(Debug)]
pub(crate) struct AggregateOutput {
pub(crate) source: AggregateSource,
pub(crate) def: JoinColumnDef,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum AggregateSource {
GroupKey(usize),
Aggregate(usize),
}
#[derive(Debug)]
pub(crate) struct InsertPlan {
pub(crate) table: String,
pub(crate) values: Vec<(ColumnDef, wasm_dbms_api::prelude::Value)>,
}
#[derive(Debug)]
pub(crate) struct UpdatePlan {
pub(crate) table: String,
pub(crate) values: Vec<(ColumnDef, wasm_dbms_api::prelude::Value)>,
pub(crate) filter: Filter,
}
#[derive(Debug)]
pub(crate) struct DeletePlan {
pub(crate) table: String,
pub(crate) filter: Filter,
pub(crate) behavior: DeleteBehavior,
}