Skip to main content

MergeStatement

Struct MergeStatement 

Source
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

Source§

fn clone(&self) -> MergeStatement

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MergeStatement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for MergeStatement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for MergeStatement

Source§

fn eq(&self, other: &MergeStatement) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MergeStatement

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.