Skip to main content

StatementError

Enum StatementError 

Source
#[non_exhaustive]
pub enum StatementError { MissingRole { statement: &'static str, role: Role, }, UnsupportedForm { dialect: &'static str, form: &'static str, }, FormMismatch { statement: &'static str, form: &'static str, }, UnsupportedFifo { dialect: &'static str, }, AdvisoryFifo { dialect: &'static str, }, IdentifierTooLong { dialect: &'static str, identifier: String, limit: NameLimit, }, Flattened { statement: &'static str, }, ServerTooOld { dialect: &'static str, server: String, required: &'static str, }, UnsupportedFetch { dialect: &'static str, }, LeaseOnDatabaseClock { dialect: &'static str, }, UnsupportedOpening { dialect: &'static str, opening: &'static str, }, FifoAtSerializable { dialect: &'static str, }, }
Expand description

Why a dialect cannot build a statement for a table.

A broker builds a subscription’s statements when the subscription starts, so a refusal stops it before it claims a row, and the message names the change to make.

§Examples

A dialect of the service’s own refuses a table its claim does not serve:

use ruststream_sqlx_dialect::{
    ClaimShape, Dialect, Isolation, Opening, Param, RowLock, Statement, StatementError,
    TableSpec,
};

/// SQL Server, a database without a built-in dialect.
#[derive(Debug)]
pub struct Mssql;

impl RowLock for Mssql {
    // The claim of the service's one queue table, which it reads whole.
    fn lock_claim(
        &self,
        spec: &TableSpec<'_>,
        _shape: ClaimShape,
    ) -> Result<Statement, StatementError> {
        // This claim keeps no group in order.
        if spec.is_fifo() {
            return Err(StatementError::UnsupportedFifo { dialect: self.name() });
        }

        // READPAST, which skips the rows another claim holds, refuses SERIALIZABLE.
        let opening = spec.opening();
        if opening == Opening::Isolation(Isolation::Serializable) {
            return Err(StatementError::UnsupportedOpening {
                dialect: self.name(),
                opening: opening.name(),
            });
        }
        Ok(Statement::new(
            "SELECT TOP (@p1) [job_id], [payload] FROM [email_jobs] \
             WITH (UPDLOCK, READPAST) ORDER BY [job_id]",
            [Param::Limit],
        ))
    }
}

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

MissingRole

The statement needs a column that plays role, and the table has none.

Fields

§statement: &'static str

The statement being built.

§role: Role

The role it needs.

§

UnsupportedForm

The dialect has no statements for the table’s form.

Fields

§dialect: &'static str

The dialect’s name.

§form: &'static str

The name of the table’s form.

§

FormMismatch

The statement belongs to one form, and the table takes rows in another: the row lock claim asked for a lease table, a lease statement for a table without a lease, or an advisory statement for a table without a lock key.

Fields

§statement: &'static str

The statement being built.

§form: &'static str

The name of the table’s form.

§

UnsupportedFifo

The dialect has no claim that keeps a group in order. A dialect of the service’s own returns it from a claim of a table with FIFO groups when it builds no claim for them.

Fields

§dialect: &'static str

The dialect’s name.

§

AdvisoryFifo

The table takes its rows by advisory lock and keeps its groups in order. In that form a lock key on the group’s column keeps a group in order, so the advisory claim and the take refuse FIFO groups.

Fields

§dialect: &'static str

The dialect’s name.

§

IdentifierTooLong

A table, schema or column name is longer than the database allows. Postgres would cut it short without a word and address another object; MySQL would refuse the statement.

Fields

§dialect: &'static str

The dialect’s name.

§identifier: String

The name that is too long.

§limit: NameLimit

The longest name the database keeps, in the unit it measures names by.

§

Flattened

The statement needs every column, and the struct flattens another whose columns the description cannot see.

Fields

§statement: &'static str

The statement being built.

§

ServerTooOld

The server is older than the dialect’s statements need, as Dialect::check_server found when the subscription started.

Fields

§dialect: &'static str

The dialect’s name.

§server: String

The version the server reports.

§required: &'static str

The oldest server the dialect’s statements run on.

§

UnsupportedFetch

The dialect cannot read rows by a list of ids, so a claim of the service’s own needs a fetch of its own beside it.

Fields

§dialect: &'static str

The dialect’s name.

§

LeaseOnDatabaseClock

The table declares a lease and reads the database’s clock. Settlement matches the expiry the claim wrote, so the claim computes it from the crate’s clock.

Fields

§dialect: &'static str

The dialect’s name.

§

UnsupportedOpening

The dialect opens no transaction at the table’s isolation level or mode, as Dialect::begin found.

Fields

§dialect: &'static str

The dialect’s name.

§opening: &'static str

The opening, as Opening::name names it.

§

FifoAtSerializable

The table keeps its groups in order, takes its rows by row lock and opens its claims at SERIALIZABLE, a level at which the dialect’s fifo_guard would wait for the group’s row in work instead of answering at once.

Fields

§dialect: &'static str

The dialect’s name.

Trait Implementations§

Source§

impl Clone for StatementError

Source§

fn clone(&self) -> Self

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 StatementError

Source§

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

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

impl Display for StatementError

Source§

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

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

impl Eq for StatementError

Source§

impl Error for StatementError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for StatementError

Source§

fn eq(&self, other: &Self) -> 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 StatementError

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.