Skip to main content

radixdb_executor/mutation/
row_validation.rs

1// Copyright 2026 RadixDB Contributors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8
9//! Executor adapter for storage-owned commit-time row validation.
10
11use radixdb_core::{Result, Row, Schema};
12use radixdb_storage::validation::PreparedRowValidator;
13
14struct ExecutorRowValidator {
15    schema: Schema,
16    checks: Vec<(String, crate::expression::SharedProgram)>,
17    vm: crate::expression::ExprVM,
18}
19
20impl PreparedRowValidator for ExecutorRowValidator {
21    fn validate(&mut self, row: &Row) -> Result<()> {
22        crate::mutation::validation::validate_resulting_row_constraints(
23            &self.schema,
24            &self.checks,
25            row,
26            &mut self.vm,
27        )
28    }
29}
30
31pub fn bind(schema: &Schema) -> Result<Box<dyn PreparedRowValidator>> {
32    Ok(Box::new(ExecutorRowValidator {
33        schema: schema.clone(),
34        checks: crate::mutation::validation::compile_table_check_constraints(schema)?,
35        vm: crate::expression::ExprVM::new(),
36    }))
37}