Struct postgres::Transaction [−][src]
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
impl<'a> Transaction<'a>
[src]
pub fn commit(self) -> Result<(), Error>
[src]
Consumes the transaction, committing all changes made within it.
pub fn rollback(self) -> Result<(), Error>
[src]
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.
pub fn prepare(&mut self, query: &str) -> Result<Statement, Error>
[src]
Like Client::prepare
.
pub fn prepare_typed(
&mut self,
query: &str,
types: &[Type]
) -> Result<Statement, Error>
[src]
&mut self,
query: &str,
types: &[Type]
) -> Result<Statement, Error>
Like Client::prepare_typed
.
pub fn execute<T: ?Sized>(
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<u64, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<u64, Error> where
T: ToStatement,
Like Client::execute
.
pub fn query<T: ?Sized>(
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Vec<Row>, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Vec<Row>, Error> where
T: ToStatement,
Like Client::query
.
pub fn query_one<T: ?Sized>(
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Row, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Row, Error> where
T: ToStatement,
Like Client::query_one
.
pub fn query_opt<T: ?Sized>(
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Option<Row>, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Option<Row>, Error> where
T: ToStatement,
Like Client::query_opt
.
pub fn query_raw<T: ?Sized, P, I>(
&mut self,
query: &T,
params: I
) -> Result<RowIter<'_>, Error> where
T: ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
[src]
&mut self,
query: &T,
params: I
) -> Result<RowIter<'_>, Error> where
T: ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
Like Client::query_raw
.
pub fn bind<T: ?Sized>(
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Portal, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Portal, Error> where
T: ToStatement,
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.
pub fn query_portal(
&mut self,
portal: &Portal,
max_rows: i32
) -> Result<Vec<Row>, Error>
[src]
&mut self,
portal: &Portal,
max_rows: i32
) -> Result<Vec<Row>, Error>
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.
pub fn query_portal_raw(
&mut self,
portal: &Portal,
max_rows: i32
) -> Result<RowIter<'_>, Error>
[src]
&mut self,
portal: &Portal,
max_rows: i32
) -> Result<RowIter<'_>, Error>
The maximally flexible version of query_portal
.
pub fn copy_in<T: ?Sized>(
&mut self,
query: &T
) -> Result<CopyInWriter<'_>, Error> where
T: ToStatement,
[src]
&mut self,
query: &T
) -> Result<CopyInWriter<'_>, Error> where
T: ToStatement,
Like Client::copy_in
.
pub fn copy_out<T: ?Sized>(
&mut self,
query: &T
) -> Result<CopyOutReader<'_>, Error> where
T: ToStatement,
[src]
&mut self,
query: &T
) -> Result<CopyOutReader<'_>, Error> where
T: ToStatement,
Like Client::copy_out
.
pub fn simple_query(
&mut self,
query: &str
) -> Result<Vec<SimpleQueryMessage>, Error>
[src]
&mut self,
query: &str
) -> Result<Vec<SimpleQueryMessage>, Error>
Like Client::simple_query
.
pub fn batch_execute(&mut self, query: &str) -> Result<(), Error>
[src]
Like Client::batch_execute
.
pub fn cancel_token(&self) -> CancelToken
[src]
Like Client::cancel_token
.
pub fn transaction(&mut self) -> Result<Transaction<'_>, Error>
[src]
Like Client::transaction
, but creates a nested transaction via a savepoint.
pub fn savepoint<I>(&mut self, name: I) -> Result<Transaction<'_>, Error> where
I: Into<String>,
[src]
I: Into<String>,
Like Client::transaction
, but creates a nested transaction via a savepoint with the specified name.
Trait Implementations
impl<'a> Drop for Transaction<'a>
[src]
impl GenericClient for Transaction<'_>
[src]
fn execute<T: ?Sized>(
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<u64, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<u64, Error> where
T: ToStatement,
fn query<T: ?Sized>(
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Vec<Row>, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Vec<Row>, Error> where
T: ToStatement,
fn query_one<T: ?Sized>(
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Row, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Row, Error> where
T: ToStatement,
fn query_opt<T: ?Sized>(
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Option<Row>, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&(dyn ToSql + Sync)]
) -> Result<Option<Row>, Error> where
T: ToStatement,
fn query_raw<T: ?Sized, P, I>(
&mut self,
query: &T,
params: I
) -> Result<RowIter<'_>, Error> where
T: ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
[src]
&mut self,
query: &T,
params: I
) -> Result<RowIter<'_>, Error> where
T: ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
fn prepare(&mut self, query: &str) -> Result<Statement, Error>
[src]
fn prepare_typed(
&mut self,
query: &str,
types: &[Type]
) -> Result<Statement, Error>
[src]
&mut self,
query: &str,
types: &[Type]
) -> Result<Statement, Error>
fn copy_in<T: ?Sized>(&mut self, query: &T) -> Result<CopyInWriter<'_>, Error> where
T: ToStatement,
[src]
T: ToStatement,
fn copy_out<T: ?Sized>(&mut self, query: &T) -> Result<CopyOutReader<'_>, Error> where
T: ToStatement,
[src]
T: ToStatement,
fn simple_query(
&mut self,
query: &str
) -> Result<Vec<SimpleQueryMessage>, Error>
[src]
&mut self,
query: &str
) -> Result<Vec<SimpleQueryMessage>, Error>
fn batch_execute(&mut self, query: &str) -> Result<(), Error>
[src]
fn transaction(&mut self) -> Result<Transaction<'_>, Error>
[src]
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Transaction<'a>
impl<'a> Send for Transaction<'a>
impl<'a> !Sync for Transaction<'a>
impl<'a> Unpin for Transaction<'a>
impl<'a> !UnwindSafe for Transaction<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,