pub struct CteDefinition {
pub name: String,
pub columns: Vec<String>,
pub query: Box<QueryExpr>,
pub recursive: bool,
}Expand description
A Common Table Expression (CTE) definition
CTEs provide named subqueries that can be referenced multiple times within the main query. Recursive CTEs enable hierarchical queries.
§Examples
-- Non-recursive CTE
WITH active_hosts AS (
SELECT * FROM hosts WHERE last_seen > now() - interval '1 hour'
)
SELECT * FROM active_hosts WHERE criticality > 5
-- Recursive CTE for attack paths
WITH RECURSIVE attack_path AS (
-- Base case: starting host
SELECT id, ip, 0 as depth FROM hosts WHERE ip = '192.168.1.1'
UNION ALL
-- Recursive case: follow connections
SELECT h.id, h.ip, ap.depth + 1
FROM attack_path ap
JOIN connections c ON c.source_id = ap.id
JOIN hosts h ON h.id = c.target_id
WHERE ap.depth < 10
)
SELECT * FROM attack_pathFields§
§name: StringName of the CTE (used to reference it in the main query)
columns: Vec<String>Optional column aliases for the CTE result
query: Box<QueryExpr>The query that defines this CTE
recursive: boolWhether this is a recursive CTE
Implementations§
Trait Implementations§
Source§impl Clone for CteDefinition
impl Clone for CteDefinition
Source§fn clone(&self) -> CteDefinition
fn clone(&self) -> CteDefinition
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CteDefinition
impl RefUnwindSafe for CteDefinition
impl Send for CteDefinition
impl Sync for CteDefinition
impl Unpin for CteDefinition
impl UnsafeUnpin for CteDefinition
impl UnwindSafe for CteDefinition
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request