pub struct PgTransaction { /* private fields */ }Expand description
An explicit transaction on a single connection checked out of the pool.
deadpool-postgres’s default recycling method (Fast) does not run
any reset query when a connection is returned to the pool — unlike
pool release, which always issues ROLLBACK itself if the
released connection still has an open transaction. That safety net has
to be reproduced here explicitly, or a connection released mid- or
aborted-transaction would silently corrupt the next borrower’s session.
Hence commit rolls back on its own failure before returning the error,
and both commit/rollback consume self so the connection is only
ever returned to the pool (via Drop) once it is guaranteed to be back
in a clean, non-transactional state.
Implementations§
Source§impl PgTransaction
impl PgTransaction
Sourcepub fn types(&self) -> &ExtensionOids
pub fn types(&self) -> &ExtensionOids
The type OIDs discovered when the owning pool connected.
Sourcepub async fn query_typed_with_globals(
&self,
sql: &str,
params: &[DecodedValue],
ext: &ExtensionOids,
globals: &str,
) -> Result<Vec<DecodedValue>>
pub async fn query_typed_with_globals( &self, sql: &str, params: &[DecodedValue], ext: &ExtensionOids, globals: &str, ) -> Result<Vec<DecodedValue>>
query_typed, with pylon.globals set for the rest of this
transaction — see PgPool::query_typed_with_globals.
Sourcepub async fn execute_typed_with_globals(
&self,
sql: &str,
params: &[DecodedValue],
globals: &str,
) -> Result<u64>
pub async fn execute_typed_with_globals( &self, sql: &str, params: &[DecodedValue], globals: &str, ) -> Result<u64>
execute_typed, with pylon.globals set — see query_typed_with_globals.
pub async fn query_typed( &self, sql: &str, params: &[DecodedValue], ext: &ExtensionOids, ) -> Result<Vec<DecodedValue>>
pub async fn execute_typed( &self, sql: &str, params: &[DecodedValue], ) -> Result<u64>
Sourcepub async fn batch_execute(&self, sql: &str) -> Result<()>
pub async fn batch_execute(&self, sql: &str) -> Result<()>
Runs sql via the simple query protocol — see PgPool::batch_execute
for why migration DDL steps need this instead of execute_typed.
Sourcepub async fn savepoint(&self, name: &str) -> Result<()>
pub async fn savepoint(&self, name: &str) -> Result<()>
Establishes a named savepoint inside this transaction. Used by
migration execution’s dev-mode rebase: a step runs inside a
savepoint so an “already exists” error (from watch having applied
the same DDL earlier) can be rolled back to just that step instead
of aborting the whole outer transaction.
pub async fn release_savepoint(&self, name: &str) -> Result<()>
pub async fn rollback_to_savepoint(&self, name: &str) -> Result<()>
Sourcepub async fn commit(self) -> Result<()>
pub async fn commit(self) -> Result<()>
Commits the transaction. On failure (e.g. a serialization failure or deadlock detected at COMMIT time), best-effort rolls back first so the connection isn’t returned to the pool still aborted — the original commit error is what’s returned either way.
pub async fn rollback(self) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PgTransaction
impl !UnwindSafe for PgTransaction
impl Freeze for PgTransaction
impl Send for PgTransaction
impl Sync for PgTransaction
impl Unpin for PgTransaction
impl UnsafeUnpin for PgTransaction
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.