pub struct PgTransaction { /* private fields */ }Expand description
A PostgreSQL transaction that holds exclusive access to the client for the duration of the transaction scope.
§Preferred cleanup
Call Transaction::commit or Transaction::rollback to end the
transaction explicitly. If neither is called before this value is dropped,
the Drop implementation attempts to schedule a ROLLBACK on the current
Tokio runtime (best-effort). If no runtime is reachable the connection is
simply released; the server will clean up via connection reset.
Implementations§
Source§impl PgTransaction
impl PgTransaction
Sourcepub async fn savepoint_pg(&mut self, name: &str) -> Result<(), PgError>
pub async fn savepoint_pg(&mut self, name: &str) -> Result<(), PgError>
Create a savepoint with the given name.
The name must consist only of ASCII alphanumeric characters and
underscores ([a-zA-Z0-9_]). This restriction prevents SQL injection
because savepoint names cannot be parameterized in the PostgreSQL
wire protocol.
§Errors
Returns PgError::Notify if the name is empty or contains unsafe
characters. Returns PgError::Postgres on wire-level errors.
Sourcepub async fn rollback_to_savepoint_pg(
&mut self,
name: &str,
) -> Result<(), PgError>
pub async fn rollback_to_savepoint_pg( &mut self, name: &str, ) -> Result<(), PgError>
Roll back to a savepoint without releasing it.
The savepoint remains active after this call; you can roll back to it
again or release it with PgTransaction::release_savepoint_pg.
§Errors
Returns PgError::Notify if the name is invalid or the transaction
has already been consumed. Returns PgError::Postgres on server
errors (e.g. the named savepoint does not exist).
Sourcepub async fn release_savepoint_pg(&mut self, name: &str) -> Result<(), PgError>
pub async fn release_savepoint_pg(&mut self, name: &str) -> Result<(), PgError>
Release (remove) a savepoint.
All savepoints created after the named savepoint are also removed.
§Errors
Returns PgError::Notify if the name is invalid or the transaction
has already been consumed. Returns PgError::Postgres on server
errors (e.g. the named savepoint does not exist).
Trait Implementations§
Source§impl Drop for PgTransaction
impl Drop for PgTransaction
Source§impl Transaction for PgTransaction
impl Transaction for PgTransaction
Source§fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
sql: &'life1 str,
params: &'life2 [&'life3 dyn ToSqlValue],
) -> Pin<Box<dyn Future<Output = Result<u64, OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
sql: &'life1 str,
params: &'life2 [&'life3 dyn ToSqlValue],
) -> Pin<Box<dyn Future<Output = Result<u64, OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn query<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
sql: &'life1 str,
params: &'life2 [&'life3 dyn ToSqlValue],
) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn query<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
sql: &'life1 str,
params: &'life2 [&'life3 dyn ToSqlValue],
) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
SELECT statement within the transaction.Source§fn commit<'async_trait>(
self: Box<Self>,
) -> Pin<Box<dyn Future<Output = Result<(), OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
fn commit<'async_trait>(
self: Box<Self>,
) -> Pin<Box<dyn Future<Output = Result<(), OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
Source§fn rollback<'async_trait>(
self: Box<Self>,
) -> Pin<Box<dyn Future<Output = Result<(), OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
fn rollback<'async_trait>(
self: Box<Self>,
) -> Pin<Box<dyn Future<Output = Result<(), OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
Source§fn savepoint<'life0, 'life1, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn savepoint<'life0, 'life1, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn release_savepoint<'life0, 'life1, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn release_savepoint<'life0, 'life1, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn rollback_to_savepoint<'life0, 'life1, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn rollback_to_savepoint<'life0, 'life1, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), OxiSqlError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn query_stream<'a>(
&'a mut self,
sql: &'a str,
params: &'a [&'a dyn ToSqlValue],
) -> Pin<Box<dyn Stream<Item = Result<Row, OxiSqlError>> + Send + 'a>>
fn query_stream<'a>( &'a mut self, sql: &'a str, params: &'a [&'a dyn ToSqlValue], ) -> Pin<Box<dyn Stream<Item = Result<Row, OxiSqlError>> + Send + 'a>>
SELECT within the transaction and return rows as an async stream. Read more