#[non_exhaustive]pub struct LockMode {
pub no_key: bool,
pub skip_locked: bool,
pub nowait: bool,
pub of: Vec<&'static str>,
pub silent_on_sqlite: bool,
}Expand description
SELECT … FOR UPDATE row-lock options — skip_locked, nowait,
of and no_key.
It is #[non_exhaustive], so a new per-backend flag can be added
without breaking code that builds a LockMode directly. Build one
with LockMode::default plus field assignment, or chain the
crate::query::QuerySet methods (.select_for_update(),
.skip_locked(), .nowait(), .no_key(), .of(…)).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.no_key: boolPG 9.3+: FOR NO KEY UPDATE instead of FOR UPDATE. A weaker
lock that does not block writers which leave the row’s PK and
unique columns alone. MySQL has no equivalent, so the writer
falls back to FOR UPDATE.
skip_locked: boolPG / MySQL 8+: SKIP LOCKED. Rows another transaction holds
are dropped from the result instead of waited for — the usual
“claim the next free row” pattern.
nowait: boolPG / MySQL 8+: NOWAIT. Fails at once if any row in the
result is locked. The database cannot combine it with
skip_locked, so if both are set the writer emits
SKIP LOCKED, the more forgiving one.
of: Vec<&'static str>PG 9.3+: FOR UPDATE OF table1, table2, …. Locks only the
named tables when the query joins. Pass table names or
aliases; an empty vec emits no OF clause. MySQL supports it
since 8.0.1; on SQLite it does nothing.
silent_on_sqlite: boolDo not log the tracing::warn! the writer emits when this
LockMode reaches a SQLite query. SQLite has no row-level
lock syntax, so the clause is dropped and the warning says so.
Set it on test fixtures or single-writer apps where SQLite’s
global writer lock is enough.
Trait Implementations§
impl Eq for LockMode
impl StructuralPartialEq for LockMode
Auto Trait Implementations§
impl Freeze for LockMode
impl RefUnwindSafe for LockMode
impl Send for LockMode
impl Sync for LockMode
impl Unpin for LockMode
impl UnsafeUnpin for LockMode
impl UnwindSafe for LockMode
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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> ⓘ
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 more