pub struct MergeStatement {
pub ctes: Vec<Cte>,
pub target: String,
pub target_alias: Option<String>,
pub source: String,
pub source_alias: Option<String>,
pub source_select: Option<Box<SelectStatement>>,
pub source_column_aliases: Vec<String>,
pub on: Expr,
pub clauses: Vec<MergeWhenClause>,
pub returning: Option<Vec<SelectItem>>,
}Expand description
v7.17.0 Phase 3.P0-42 — SQL:2003 / PG 15+ MERGE statement.
One WHEN clause fires per source row depending on whether the
on condition matched any target row(s); the executor walks
clauses in declaration order and fires the first whose
matched kind and optional condition are both satisfied.
Fields§
§ctes: Vec<Cte>v7.39 (read01 round 149) — leading WITH <cte> [, …] (PG 15 allows
a WITH clause on MERGE; WITH RECURSIVE is rejected at parse, as
in PG). Each CTE materialises before the merge runs and its alias
resolves as a source relation.
target: String§target_alias: Option<String>§source: String§source_alias: Option<String>§source_select: Option<Box<SelectStatement>>v7.37 D.44 — USING (SELECT …) alias subquery source. When present,
the engine materialises this SELECT for the source rows and source
is empty; the alias (required by PG for a subquery source) is in
source_alias. None = plain USING <table> (source names a table).
source_column_aliases: Vec<String>v7.39 (round 768, F31-D5) — USING (VALUES …) s(id, v): the
positional column-alias list after the source alias. Empty when
the statement carries none; the engine renames the materialised
source columns positionally (PG’s rule).
on: Expr§clauses: Vec<MergeWhenClause>§returning: Option<Vec<SelectItem>>v7.39 (read01 round 130) — PG17+ MERGE … RETURNING <projection>.
The projection may use merge_action(), OLD.*/NEW.*, and the
target/source aliases. None = no RETURNING (the common form).
Trait Implementations§
Source§impl Clone for MergeStatement
impl Clone for MergeStatement
Source§fn clone(&self) -> MergeStatement
fn clone(&self) -> MergeStatement
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more