Struct postgres::Transaction [−][src]
pub struct Transaction<'a> { /* fields omitted */ }
Expand description
A representation of a PostgreSQL database transaction.
Transactions will implicitly roll back by default when dropped. Use the commit
method to commit the changes made
in the transaction. Transactions can be nested, with inner transactions implemented via savepoints.
Implementations
Consumes the transaction, committing all changes made within it.
Rolls the transaction back, discarding all changes made within it.
This is equivalent to Transaction
’s Drop
implementation, but provides any error encountered to the caller.
Like Client::prepare_typed
.
Like Client::execute
.
Like Client::query
.
Like Client::query_one
.
Like Client::query_opt
.
pub fn query_raw<T, P, I>(
&mut self,
query: &T,
params: I
) -> Result<RowIter<'_>, Error> where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
pub fn query_raw<T, P, I>(
&mut self,
query: &T,
params: I
) -> Result<RowIter<'_>, Error> where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
Like Client::query_raw
.
Binds parameters to a statement, creating a “portal”.
Portals can be used with the query_portal
method to page through the results of a query without being forced
to consume them all immediately.
Portals are automatically closed when the transaction they were created in is closed.
Panics
Panics if the number of parameters provided does not match the number expected.
Continues execution of a portal, returning the next set of rows.
Unlike query
, portals can be incrementally evaluated by limiting the number of rows returned in each call to
query_portal
. If the requested number is negative or 0, all remaining rows will be returned.
The maximally flexible version of query_portal
.
pub fn copy_in<T>(&mut self, query: &T) -> Result<CopyInWriter<'_>, Error> where
T: ?Sized + ToStatement,
pub fn copy_in<T>(&mut self, query: &T) -> Result<CopyInWriter<'_>, Error> where
T: ?Sized + ToStatement,
Like Client::copy_in
.
pub fn copy_out<T>(&mut self, query: &T) -> Result<CopyOutReader<'_>, Error> where
T: ?Sized + ToStatement,
pub fn copy_out<T>(&mut self, query: &T) -> Result<CopyOutReader<'_>, Error> where
T: ?Sized + ToStatement,
Like Client::copy_out
.
Like Client::simple_query
.
Like Client::cancel_token
.
Like Client::transaction
, but creates a nested transaction via a savepoint.
Trait Implementations
Like Client::execute
.
Like Client::query
.
Like Client::query_one
.
Like Client::query_opt
.
fn query_raw<T, P, I>(
&mut self,
query: &T,
params: I
) -> Result<RowIter<'_>, Error> where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
fn query_raw<T, P, I>(
&mut self,
query: &T,
params: I
) -> Result<RowIter<'_>, Error> where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
Like Client::query_raw
.
Like Client::prepare_typed
.
fn copy_in<T>(&mut self, query: &T) -> Result<CopyInWriter<'_>, Error> where
T: ?Sized + ToStatement,
fn copy_in<T>(&mut self, query: &T) -> Result<CopyInWriter<'_>, Error> where
T: ?Sized + ToStatement,
Like Client::copy_in
.
fn copy_out<T>(&mut self, query: &T) -> Result<CopyOutReader<'_>, Error> where
T: ?Sized + ToStatement,
fn copy_out<T>(&mut self, query: &T) -> Result<CopyOutReader<'_>, Error> where
T: ?Sized + ToStatement,
Like Client::copy_out
.
Like Client::simple_query
.
Like Client::transaction
.