pub struct TxOptions { /* private fields */ }Expand description
What a transaction is opened with: the parts of transaction control the three engines do not agree on.
Defaults to “whatever the engine’s own default is” on every axis, so
Transaction::begin_on_with with a default TxOptions sends exactly
what Transaction::begin_on sends.
Implementations§
Source§impl TxOptions
impl TxOptions
Sourcepub const fn read_only(self) -> Self
pub const fn read_only(self) -> Self
Shorthand for Access::ReadOnly.
Sourcepub const fn sqlite_begin(self, mode: SqliteBegin) -> Self
pub const fn sqlite_begin(self, mode: SqliteBegin) -> Self
SQLite’s begin mode. An error on any other family.
Sourcepub const fn get_isolation(self) -> Option<Isolation>
pub const fn get_isolation(self) -> Option<Isolation>
The isolation level asked for, if any.
Sourcepub const fn get_access(self) -> Option<Access>
pub const fn get_access(self) -> Option<Access>
The access mode asked for, if any.
Sourcepub const fn get_sqlite_begin(self) -> Option<SqliteBegin>
pub const fn get_sqlite_begin(self) -> Option<SqliteBegin>
The SQLite begin mode asked for, if any.
Sourcepub fn check(&self, family: Family) -> Result<(), ExecError>
pub fn check(&self, family: Family) -> Result<(), ExecError>
Can this engine honour these options? Answers without opening a transaction — backends call it before checking a connection out, and callers can pre-flight a configuration with it.
Sourcepub fn plan(&self, family: Family) -> Result<Vec<String>, ExecError>
pub fn plan(&self, family: Family) -> Result<Vec<String>, ExecError>
The exact statements Transaction::begin_on_with will run, in
order, on the transaction’s own connection — or the error explaining
why this engine cannot be asked for this.
Nothing here is inferred at run time from a server version; it is the documented grammar of each engine, and it is public so that “what does keelson actually send?” is answerable without a packet capture.
| PostgreSQL | MySQL / InnoDB | SQLite | |
|---|---|---|---|
| READ UNCOMMITTED | refused (accepted by the server, run as READ COMMITTED) | yes | refused |
| READ COMMITTED | yes (default) | yes | refused |
| REPEATABLE READ | yes | yes (default) | refused |
| SERIALIZABLE | yes | yes | yes — SQLite’s only level |
| READ ONLY | yes | yes | refused (PRAGMA query_only is connection state) |
SqliteBegin | refused | refused | yes |
The rule behind every refusal: a level is accepted only when the engine runs the transaction at that level. Substituting a neighbouring level would satisfy the SQL standard (it permits running stricter than asked) and would still be a lie to the caller, who asked in order to get particular behaviour.
The match on Family is exhaustive on purpose: a new family cannot
be added to this crate without deciding what it does here.