Struct deadpool_postgres::Transaction
source · pub struct Transaction<'a> {
pub statement_cache: Arc<StatementCache>,
/* private fields */
}
Expand description
Wrapper around tokio_postgres::Transaction
with a StatementCache
from the Client
object it was created by.
Fields§
§statement_cache: Arc<StatementCache>
StatementCache
of this Transaction
.
Implementations§
source§impl<'a> Transaction<'a>
impl<'a> Transaction<'a>
sourcepub async fn prepare_cached(&self, query: &str) -> Result<Statement, Error>
pub async fn prepare_cached(&self, query: &str) -> Result<Statement, Error>
Like tokio_postgres::Transaction::prepare()
, but uses an existing
Statement
from the StatementCache
if possible.
sourcepub async fn prepare_typed_cached(
&self,
query: &str,
types: &[Type]
) -> Result<Statement, Error>
pub async fn prepare_typed_cached( &self, query: &str, types: &[Type] ) -> Result<Statement, Error>
Like tokio_postgres::Transaction::prepare_typed()
, but uses an
existing Statement
from the StatementCache
if possible.
sourcepub async fn transaction(&mut self) -> Result<Transaction<'_>, Error>
pub async fn transaction(&mut self) -> Result<Transaction<'_>, Error>
Like tokio_postgres::Transaction::transaction()
, but returns a
wrapped Transaction
with a StatementCache
.
sourcepub async fn savepoint<I>(&mut self, name: I) -> Result<Transaction<'_>, Error>
pub async fn savepoint<I>(&mut self, name: I) -> Result<Transaction<'_>, Error>
Like tokio_postgres::Transaction::savepoint()
, but returns a wrapped
Transaction
with a StatementCache
.
Methods from Deref<Target = PgTransaction<'a>>§
sourcepub async fn prepare_typed(
&self,
query: &str,
parameter_types: &[Type]
) -> Result<Statement, Error>
pub async fn prepare_typed( &self, query: &str, parameter_types: &[Type] ) -> Result<Statement, Error>
Like Client::prepare_typed
.
sourcepub async fn query<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Vec<Row>, Error>where
T: ToStatement + ?Sized,
pub async fn query<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Vec<Row>, Error>where
T: ToStatement + ?Sized,
Like Client::query
.
sourcepub async fn query_one<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Row, Error>where
T: ToStatement + ?Sized,
pub async fn query_one<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Row, Error>where
T: ToStatement + ?Sized,
Like Client::query_one
.
sourcepub async fn query_opt<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Option<Row>, Error>where
T: ToStatement + ?Sized,
pub async fn query_opt<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Option<Row>, Error>where
T: ToStatement + ?Sized,
Like Client::query_opt
.
sourcepub async fn query_raw<T, P, I>(
&self,
statement: &T,
params: I
) -> Result<RowStream, Error>where
T: ToStatement + ?Sized,
P: BorrowToSql,
I: IntoIterator<Item = P>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
pub async fn query_raw<T, P, I>(
&self,
statement: &T,
params: I
) -> Result<RowStream, Error>where
T: ToStatement + ?Sized,
P: BorrowToSql,
I: IntoIterator<Item = P>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Like Client::query_raw
.
sourcepub async fn execute<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<u64, Error>where
T: ToStatement + ?Sized,
pub async fn execute<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<u64, Error>where
T: ToStatement + ?Sized,
Like Client::execute
.
sourcepub async fn execute_raw<P, I, T>(
&self,
statement: &T,
params: I
) -> Result<u64, Error>where
T: ToStatement + ?Sized,
P: BorrowToSql,
I: IntoIterator<Item = P>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
pub async fn execute_raw<P, I, T>(
&self,
statement: &T,
params: I
) -> Result<u64, Error>where
T: ToStatement + ?Sized,
P: BorrowToSql,
I: IntoIterator<Item = P>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Like Client::execute_iter
.
sourcepub async fn bind<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Portal, Error>where
T: ToStatement + ?Sized,
pub async fn bind<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Portal, Error>where
T: ToStatement + ?Sized,
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.
sourcepub async fn bind_raw<P, T, I>(
&self,
statement: &T,
params: I
) -> Result<Portal, Error>where
T: ToStatement + ?Sized,
P: BorrowToSql,
I: IntoIterator<Item = P>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
pub async fn bind_raw<P, T, I>(
&self,
statement: &T,
params: I
) -> Result<Portal, Error>where
T: ToStatement + ?Sized,
P: BorrowToSql,
I: IntoIterator<Item = P>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
A maximally flexible version of bind
.
sourcepub async fn query_portal(
&self,
portal: &Portal,
max_rows: i32
) -> Result<Vec<Row>, Error>
pub async fn query_portal( &self, portal: &Portal, max_rows: i32 ) -> Result<Vec<Row>, Error>
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.
sourcepub async fn query_portal_raw(
&self,
portal: &Portal,
max_rows: i32
) -> Result<RowStream, Error>
pub async fn query_portal_raw( &self, portal: &Portal, max_rows: i32 ) -> Result<RowStream, Error>
The maximally flexible version of query_portal
.
sourcepub async fn copy_in<T, U>(&self, statement: &T) -> Result<CopyInSink<U>, Error>
pub async fn copy_in<T, U>(&self, statement: &T) -> Result<CopyInSink<U>, Error>
Like Client::copy_in
.
sourcepub async fn copy_out<T>(&self, statement: &T) -> Result<CopyOutStream, Error>where
T: ToStatement + ?Sized,
pub async fn copy_out<T>(&self, statement: &T) -> Result<CopyOutStream, Error>where
T: ToStatement + ?Sized,
Like Client::copy_out
.
sourcepub async fn simple_query(
&self,
query: &str
) -> Result<Vec<SimpleQueryMessage>, Error>
pub async fn simple_query( &self, query: &str ) -> Result<Vec<SimpleQueryMessage>, Error>
Like Client::simple_query
.
sourcepub async fn batch_execute(&self, query: &str) -> Result<(), Error>
pub async fn batch_execute(&self, query: &str) -> Result<(), Error>
Like Client::batch_execute
.
sourcepub fn cancel_token(&self) -> CancelToken
pub fn cancel_token(&self) -> CancelToken
Like Client::cancel_token
.
sourcepub 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>,
Like Client::cancel_query
.
sourcepub async fn cancel_query_raw<S, T>(
&self,
stream: S,
tls: T
) -> Result<(), Error>
👎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>
Like Client::cancel_query_raw
.
sourcepub async fn transaction(&mut self) -> Result<Transaction<'_>, Error>
pub async fn transaction(&mut self) -> Result<Transaction<'_>, Error>
Like Client::transaction
, but creates a nested transaction via a savepoint.
sourcepub async fn savepoint<I>(&mut self, name: I) -> Result<Transaction<'_>, Error>
pub async fn savepoint<I>(&mut self, name: I) -> Result<Transaction<'_>, Error>
Like Client::transaction
, but creates a nested transaction via a savepoint with the specified name.
Trait Implementations§
source§impl<'a> Debug for Transaction<'a>
impl<'a> Debug for Transaction<'a>
source§impl<'a> Deref for Transaction<'a>
impl<'a> Deref for Transaction<'a>
§type Target = Transaction<'a>
type Target = Transaction<'a>
source§fn deref(&self) -> &PgTransaction<'a>
fn deref(&self) -> &PgTransaction<'a>
source§impl<'a> DerefMut for Transaction<'a>
impl<'a> DerefMut for Transaction<'a>
source§fn deref_mut(&mut self) -> &mut PgTransaction<'a>
fn deref_mut(&mut self) -> &mut PgTransaction<'a>
source§impl GenericClient for Transaction<'_>
impl GenericClient for Transaction<'_>
source§async fn execute<T>(
&self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<u64, Error>
async fn execute<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)] ) -> Result<u64, Error>
Client::execute
.source§async fn execute_raw<P, I, T>(
&self,
statement: &T,
params: I
) -> Result<u64, Error>where
T: ?Sized + ToStatement + Sync + Send,
P: BorrowToSql,
I: IntoIterator<Item = P> + Sync + Send,
I::IntoIter: ExactSizeIterator,
async fn execute_raw<P, I, T>(
&self,
statement: &T,
params: I
) -> Result<u64, Error>where
T: ?Sized + ToStatement + Sync + Send,
P: BorrowToSql,
I: IntoIterator<Item = P> + Sync + Send,
I::IntoIter: ExactSizeIterator,
Client::execute_raw
.source§async fn query<T>(
&self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Vec<Row>, Error>
async fn query<T>( &self, query: &T, params: &[&(dyn ToSql + Sync)] ) -> Result<Vec<Row>, Error>
Client::query
.source§async fn query_one<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Row, Error>
async fn query_one<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)] ) -> Result<Row, Error>
Client::query_one
.source§async fn query_opt<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Option<Row>, Error>
async fn query_opt<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)] ) -> Result<Option<Row>, Error>
Client::query_opt
.source§async fn query_raw<T, P, I>(
&self,
statement: &T,
params: I
) -> Result<RowStream, Error>where
T: ?Sized + ToStatement + Sync + Send,
P: BorrowToSql,
I: IntoIterator<Item = P> + Sync + Send,
I::IntoIter: ExactSizeIterator,
async fn query_raw<T, P, I>(
&self,
statement: &T,
params: I
) -> Result<RowStream, Error>where
T: ?Sized + ToStatement + Sync + Send,
P: BorrowToSql,
I: IntoIterator<Item = P> + Sync + Send,
I::IntoIter: ExactSizeIterator,
Client::query_raw
.source§async fn prepare_typed(
&self,
query: &str,
parameter_types: &[Type]
) -> Result<Statement, Error>
async fn prepare_typed( &self, query: &str, parameter_types: &[Type] ) -> Result<Statement, Error>
Client::prepare_typed
.source§async fn prepare_cached(&self, query: &str) -> Result<Statement, Error>
async fn prepare_cached(&self, query: &str) -> Result<Statement, Error>
Client::prepare_cached
.source§async fn prepare_typed_cached(
&self,
query: &str,
types: &[Type]
) -> Result<Statement, Error>
async fn prepare_typed_cached( &self, query: &str, types: &[Type] ) -> Result<Statement, Error>
source§async fn transaction<'a>(&'a mut self) -> Result<Transaction<'a>, Error>
async fn transaction<'a>(&'a mut self) -> Result<Transaction<'a>, Error>
Client::transaction
.