pub enum CheckExpr {
Show 15 variants
True,
Col(u16),
Lit(Value),
IsNull(u16),
IsNotNull(u16),
Eq(Box<CheckExpr>, Box<CheckExpr>),
Ne(Box<CheckExpr>, Box<CheckExpr>),
Lt(Box<CheckExpr>, Box<CheckExpr>),
Le(Box<CheckExpr>, Box<CheckExpr>),
Gt(Box<CheckExpr>, Box<CheckExpr>),
Ge(Box<CheckExpr>, Box<CheckExpr>),
And(Box<CheckExpr>, Box<CheckExpr>),
Or(Box<CheckExpr>, Box<CheckExpr>),
Not(Box<CheckExpr>),
Regex {
col: u16,
pattern: String,
negated: bool,
case_insensitive: bool,
cached: OnceLock<Regex>,
},
}Expand description
A minimal boolean expression IR for CHECK constraints, evaluated against a
row’s cells. Terms (CheckExpr::Col / CheckExpr::Lit) resolve to
Value; comparisons and logical ops are boolean. Any comparison involving
Value::Null yields three-valued Unknown.
The CheckExpr::Regex variant stores the pattern string for serde/equality
and caches the compiled regex::Regex in a std::sync::OnceLock (populated
on first evaluation). The cache is #[serde(skip)] and excluded from
PartialEq.
Variants§
True
Constant true (the trivially-satisfied CHECK).
Col(u16)
A bare column reference used as a boolean (truthiness coercion).
Lit(Value)
A literal value.
IsNull(u16)
IsNotNull(u16)
Eq(Box<CheckExpr>, Box<CheckExpr>)
Ne(Box<CheckExpr>, Box<CheckExpr>)
Lt(Box<CheckExpr>, Box<CheckExpr>)
Le(Box<CheckExpr>, Box<CheckExpr>)
Gt(Box<CheckExpr>, Box<CheckExpr>)
Ge(Box<CheckExpr>, Box<CheckExpr>)
And(Box<CheckExpr>, Box<CheckExpr>)
Or(Box<CheckExpr>, Box<CheckExpr>)
Not(Box<CheckExpr>)
Regex
Regex pattern match against a column’s value (PostgreSQL ~/~*/!~/!~*).
The column value must be Value::Bytes (UTF-8 string); non-bytes and null
yield Unknown (CHECK passes). negated inverts the match result;
case_insensitive enables case-insensitive matching. The Rust regex
crate is linear-time (no catastrophic backtracking), so ReDoS is not a
concern.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CheckExpr
impl<'de> Deserialize<'de> for CheckExpr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl !Freeze for CheckExpr
impl RefUnwindSafe for CheckExpr
impl Send for CheckExpr
impl Sync for CheckExpr
impl Unpin for CheckExpr
impl UnsafeUnpin for CheckExpr
impl UnwindSafe for CheckExpr
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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