#[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
MissingRole
The statement needs a column that plays role, and the table has none.
UnsupportedForm
The dialect has no statements for 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
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.
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.
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
Flattened
The statement needs every column, and the struct flattens another whose columns the description cannot see.
ServerTooOld
The server is older than the dialect’s statements need, as
Dialect::check_server found when the subscription
started.
Fields
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.
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.
UnsupportedOpening
The dialect opens no transaction at the table’s isolation level or mode, as
Dialect::begin found.
Fields
opening: &'static strThe 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.
Trait Implementations§
Source§impl Clone for StatementError
impl Clone for StatementError
Source§impl Debug for StatementError
impl Debug for StatementError
Source§impl Display for StatementError
impl Display for StatementError
impl Eq for StatementError
Source§impl Error for StatementError
impl Error for StatementError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()