Struct tokio_postgres::Transaction [−][src]
pub struct Transaction<'a> { /* fields omitted */ }
Expand description
A representation of a PostgreSQL database transaction.
Transactions will implicitly roll back when dropped. Use the commit
method to commit the changes made in the
transaction. Transactions can be nested, with inner transactions implemented via safepoints.
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::query
.
Like Client::query_one
.
Like Client::query_opt
.
pub async fn query_raw<T, P, I>(
&self,
statement: &T,
params: I
) -> Result<RowStream, Error> where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
pub async fn query_raw<T, P, I>(
&self,
statement: &T,
params: I
) -> Result<RowStream, Error> where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
Like Client::query_raw
.
Like Client::execute
.
pub async fn execute_raw<P, I, T>(
&self,
statement: &T,
params: I
) -> Result<u64, Error> where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
pub async fn execute_raw<P, I, T>(
&self,
statement: &T,
params: I
) -> Result<u64, Error> where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
Like Client::execute_iter
.
Binds a statement to a set of parameters, creating a Portal
which can be incrementally queried.
Portals only last for the duration of the transaction in which they are created, and can only be used on the connection that created them.
Panics
Panics if the number of parameters provided does not match the number expected.
pub async fn bind_raw<P, T, I>(
&self,
statement: &T,
params: I
) -> Result<Portal, Error> where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
pub async fn bind_raw<P, T, I>(
&self,
statement: &T,
params: I
) -> Result<Portal, Error> where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
A maximally flexible version of bind
.
Continues execution of a portal, returning a stream of the resulting 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 rows will be returned.
The maximally flexible version of query_portal
.
pub async fn copy_in<T, U>(&self, statement: &T) -> Result<CopyInSink<U>, Error> where
T: ?Sized + ToStatement,
U: Buf + 'static + Send,
pub async fn copy_in<T, U>(&self, statement: &T) -> Result<CopyInSink<U>, Error> where
T: ?Sized + ToStatement,
U: Buf + 'static + Send,
Like Client::copy_in
.
pub async fn copy_out<T>(&self, statement: &T) -> Result<CopyOutStream, Error> where
T: ?Sized + ToStatement,
pub async fn copy_out<T>(&self, statement: &T) -> Result<CopyOutStream, Error> where
T: ?Sized + ToStatement,
Like Client::copy_out
.
Like Client::simple_query
.
Like Client::cancel_token
.
pub async fn cancel_query<T>(&self, tls: T) -> Result<(), Error> where
T: MakeTlsConnect<Socket>,
👎 Deprecated since 0.6.0: use Transaction::cancel_token() instead
pub async fn cancel_query<T>(&self, tls: T) -> Result<(), Error> where
T: MakeTlsConnect<Socket>,
use Transaction::cancel_token() instead
Like Client::cancel_query
.
pub async fn cancel_query_raw<S, T>(
&self,
stream: S,
tls: T
) -> Result<(), Error> where
S: AsyncRead + AsyncWrite + Unpin,
T: TlsConnect<S>,
👎 Deprecated since 0.6.0: use Transaction::cancel_token() instead
pub async fn cancel_query_raw<S, T>(
&self,
stream: S,
tls: T
) -> Result<(), Error> where
S: AsyncRead + AsyncWrite + Unpin,
T: TlsConnect<S>,
use Transaction::cancel_token() instead
Like Client::cancel_query_raw
.
Like Client::transaction
, but creates a nested transaction via a savepoint.
Like Client::transaction
, but creates a nested transaction via a savepoint with the specified name.
Trait Implementations
fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
query: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + Sync)]
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>> where
T: ?Sized + ToStatement + Sync + Send,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
query: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + Sync)]
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>> where
T: ?Sized + ToStatement + Sync + Send,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Like Client::execute
.
fn execute_raw<'life0, 'life1, 'async_trait, P, I, T>(
&'life0 self,
statement: &'life1 T,
params: I
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>> where
T: ?Sized + ToStatement + Sync + Send,
P: BorrowToSql,
I: IntoIterator<Item = P> + Sync + Send,
I::IntoIter: ExactSizeIterator,
P: 'async_trait,
I: 'async_trait,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn execute_raw<'life0, 'life1, 'async_trait, P, I, T>(
&'life0 self,
statement: &'life1 T,
params: I
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>> where
T: ?Sized + ToStatement + Sync + Send,
P: BorrowToSql,
I: IntoIterator<Item = P> + Sync + Send,
I::IntoIter: ExactSizeIterator,
P: 'async_trait,
I: 'async_trait,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Like Client::execute_raw
.
fn query<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
query: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + Sync)]
) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, Error>> + Send + 'async_trait>> where
T: ?Sized + ToStatement + Sync + Send,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn query<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
query: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + Sync)]
) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, Error>> + Send + 'async_trait>> where
T: ?Sized + ToStatement + Sync + Send,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Like Client::query
.
fn query_one<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
statement: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + Sync)]
) -> Pin<Box<dyn Future<Output = Result<Row, Error>> + Send + 'async_trait>> where
T: ?Sized + ToStatement + Sync + Send,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn query_one<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
statement: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + Sync)]
) -> Pin<Box<dyn Future<Output = Result<Row, Error>> + Send + 'async_trait>> where
T: ?Sized + ToStatement + Sync + Send,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Like Client::query_one
.
fn query_opt<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
statement: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + Sync)]
) -> Pin<Box<dyn Future<Output = Result<Option<Row>, Error>> + Send + 'async_trait>> where
T: ?Sized + ToStatement + Sync + Send,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn query_opt<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
statement: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + Sync)]
) -> Pin<Box<dyn Future<Output = Result<Option<Row>, Error>> + Send + 'async_trait>> where
T: ?Sized + ToStatement + Sync + Send,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Like Client::query_opt
.
fn query_raw<'life0, 'life1, 'async_trait, T, P, I>(
&'life0 self,
statement: &'life1 T,
params: I
) -> Pin<Box<dyn Future<Output = Result<RowStream, Error>> + Send + 'async_trait>> where
T: ?Sized + ToStatement + Sync + Send,
P: BorrowToSql,
I: IntoIterator<Item = P> + Sync + Send,
I::IntoIter: ExactSizeIterator,
T: 'async_trait,
P: 'async_trait,
I: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn query_raw<'life0, 'life1, 'async_trait, T, P, I>(
&'life0 self,
statement: &'life1 T,
params: I
) -> Pin<Box<dyn Future<Output = Result<RowStream, Error>> + Send + 'async_trait>> where
T: ?Sized + ToStatement + Sync + Send,
P: BorrowToSql,
I: IntoIterator<Item = P> + Sync + Send,
I::IntoIter: ExactSizeIterator,
T: 'async_trait,
P: 'async_trait,
I: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Like Client::query_raw
.
Like Client::prepare
.
Like Client::prepare_typed
.
fn transaction<'a, 'async_trait>(
&'a mut self
) -> Pin<Box<dyn Future<Output = Result<Transaction<'a>, Error>> + Send + 'async_trait>> where
'a: 'async_trait,
Self: 'async_trait,
fn transaction<'a, 'async_trait>(
&'a mut self
) -> Pin<Box<dyn Future<Output = Result<Transaction<'a>, Error>> + Send + 'async_trait>> where
'a: 'async_trait,
Self: 'async_trait,
Like Client::transaction
.