pub struct ConstraintService<P>{ /* private fields */ }Expand description
High-level constraint service API intended for runtime consumers.
Implementations§
Source§impl<P> ConstraintService<P>
impl<P> ConstraintService<P>
Sourcepub fn new(
metadata: Arc<MetadataManager<P>>,
catalog: Arc<TableCatalog>,
) -> Self
pub fn new( metadata: Arc<MetadataManager<P>>, catalog: Arc<TableCatalog>, ) -> Self
Create a new constraint validation service.
Sourcepub fn validate_insert_foreign_keys<F>(
&self,
referencing_table_id: TableId,
schema_field_ids: &[FieldId],
column_order: &[usize],
rows: &[Vec<PlanValue>],
fetch_parent_rows: F,
) -> LlkvResult<()>
pub fn validate_insert_foreign_keys<F>( &self, referencing_table_id: TableId, schema_field_ids: &[FieldId], column_order: &[usize], rows: &[Vec<PlanValue>], fetch_parent_rows: F, ) -> LlkvResult<()>
Validate that incoming INSERT rows satisfy the table’s foreign key constraints.
Sourcepub fn validate_insert_constraints<FSingle, FMulti>(
&self,
schema_field_ids: &[FieldId],
column_constraints: &[InsertColumnConstraint],
unique_columns: &[InsertUniqueColumn],
multi_column_uniques: &[InsertMultiColumnUnique],
primary_key: Option<&InsertMultiColumnUnique>,
column_order: &[usize],
rows: &[Vec<PlanValue>],
fetch_column_values: FSingle,
fetch_multi_column_rows: FMulti,
) -> LlkvResult<()>
pub fn validate_insert_constraints<FSingle, FMulti>( &self, schema_field_ids: &[FieldId], column_constraints: &[InsertColumnConstraint], unique_columns: &[InsertUniqueColumn], multi_column_uniques: &[InsertMultiColumnUnique], primary_key: Option<&InsertMultiColumnUnique>, column_order: &[usize], rows: &[Vec<PlanValue>], fetch_column_values: FSingle, fetch_multi_column_rows: FMulti, ) -> LlkvResult<()>
Validate INSERT rows against all table constraints including primary keys, unique constraints, and CHECK expressions. This is a comprehensive validation that combines uniqueness checks (both single-column and multi-column) with row-level CHECK constraint evaluation.
Sourcepub fn validate_row_level_constraints(
&self,
schema_field_ids: &[FieldId],
column_constraints: &[InsertColumnConstraint],
column_order: &[usize],
rows: &[Vec<PlanValue>],
) -> LlkvResult<()>
pub fn validate_row_level_constraints( &self, schema_field_ids: &[FieldId], column_constraints: &[InsertColumnConstraint], column_order: &[usize], rows: &[Vec<PlanValue>], ) -> LlkvResult<()>
Validate rows against CHECK constraints. This method evaluates CHECK expressions for each row, ensuring they satisfy the table’s row-level constraint rules.
Sourcepub fn validate_primary_key_rows<F>(
&self,
schema_field_ids: &[FieldId],
primary_key: &InsertMultiColumnUnique,
column_order: &[usize],
rows: &[Vec<PlanValue>],
fetch_multi_column_rows: F,
) -> LlkvResult<()>
pub fn validate_primary_key_rows<F>( &self, schema_field_ids: &[FieldId], primary_key: &InsertMultiColumnUnique, column_order: &[usize], rows: &[Vec<PlanValue>], fetch_multi_column_rows: F, ) -> LlkvResult<()>
Validate that INSERT rows satisfy the primary key constraint by checking for duplicates against both existing rows in the table and within the new batch.
Sourcepub fn validate_update_primary_keys<F>(
&self,
schema_field_ids: &[FieldId],
primary_key: &InsertMultiColumnUnique,
column_order: &[usize],
rows: &[Vec<PlanValue>],
original_keys: &[Option<UniqueKey>],
fetch_multi_column_rows: F,
) -> LlkvResult<()>
pub fn validate_update_primary_keys<F>( &self, schema_field_ids: &[FieldId], primary_key: &InsertMultiColumnUnique, column_order: &[usize], rows: &[Vec<PlanValue>], original_keys: &[Option<UniqueKey>], fetch_multi_column_rows: F, ) -> LlkvResult<()>
Validate UPDATE operations that modify primary key columns. Ensures that updated primary key values don’t conflict with existing rows (excluding the original row being updated).
Sourcepub fn validate_delete_foreign_keys<FParents, FChildren>(
&self,
referenced_table_id: TableId,
referenced_row_ids: &[RowId],
fetch_parent_rows: FParents,
fetch_child_rows: FChildren,
) -> LlkvResult<()>where
FParents: FnMut(ForeignKeyParentRowsFetch<'_>) -> LlkvResult<Vec<Vec<PlanValue>>>,
FChildren: FnMut(ForeignKeyChildRowsFetch<'_>) -> LlkvResult<Vec<(RowId, Vec<PlanValue>)>>,
pub fn validate_delete_foreign_keys<FParents, FChildren>(
&self,
referenced_table_id: TableId,
referenced_row_ids: &[RowId],
fetch_parent_rows: FParents,
fetch_child_rows: FChildren,
) -> LlkvResult<()>where
FParents: FnMut(ForeignKeyParentRowsFetch<'_>) -> LlkvResult<Vec<Vec<PlanValue>>>,
FChildren: FnMut(ForeignKeyChildRowsFetch<'_>) -> LlkvResult<Vec<(RowId, Vec<PlanValue>)>>,
Validate that deleting the given rows will not violate foreign key constraints.
Sourcepub fn validate_update_foreign_keys<FParents, FChildren>(
&self,
referenced_table_id: TableId,
referenced_row_ids: &[RowId],
updated_field_ids: &[FieldId],
fetch_parent_rows: FParents,
fetch_child_rows: FChildren,
) -> LlkvResult<()>where
FParents: FnMut(ForeignKeyParentRowsFetch<'_>) -> LlkvResult<Vec<Vec<PlanValue>>>,
FChildren: FnMut(ForeignKeyChildRowsFetch<'_>) -> LlkvResult<Vec<(RowId, Vec<PlanValue>)>>,
pub fn validate_update_foreign_keys<FParents, FChildren>(
&self,
referenced_table_id: TableId,
referenced_row_ids: &[RowId],
updated_field_ids: &[FieldId],
fetch_parent_rows: FParents,
fetch_child_rows: FChildren,
) -> LlkvResult<()>where
FParents: FnMut(ForeignKeyParentRowsFetch<'_>) -> LlkvResult<Vec<Vec<PlanValue>>>,
FChildren: FnMut(ForeignKeyChildRowsFetch<'_>) -> LlkvResult<Vec<(RowId, Vec<PlanValue>)>>,
Validate that updating the given rows will not violate foreign key constraints.
This checks if any columns being updated are referenced by foreign keys, and whether the OLD values are still being referenced by child tables.
Sourcepub fn referencing_foreign_keys(
&self,
referenced_table_id: TableId,
) -> LlkvResult<Vec<ForeignKeyView>>
pub fn referencing_foreign_keys( &self, referenced_table_id: TableId, ) -> LlkvResult<Vec<ForeignKeyView>>
Return the set of foreign keys referencing the provided table.
Trait Implementations§
Source§impl<P> Clone for ConstraintService<P>
impl<P> Clone for ConstraintService<P>
Source§fn clone(&self) -> ConstraintService<P>
fn clone(&self) -> ConstraintService<P>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<P> Freeze for ConstraintService<P>
impl<P> RefUnwindSafe for ConstraintService<P>where
P: RefUnwindSafe,
impl<P> Send for ConstraintService<P>
impl<P> Sync for ConstraintService<P>
impl<P> Unpin for ConstraintService<P>
impl<P> UnwindSafe for ConstraintService<P>where
P: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more