[][src]Struct postgres::Transaction

pub struct Transaction<'a> { /* fields omitted */ }

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.

Methods

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]

Like Client::prepare_typed.

pub fn execute<T: ?Sized>(
    &mut self,
    query: &T,
    params: &[&(dyn ToSql + Sync)]
) -> Result<u64, Error> where
    T: ToStatement
[src]

Like Client::execute.

pub fn query<T: ?Sized>(
    &mut self,
    query: &T,
    params: &[&(dyn ToSql + Sync)]
) -> Result<Vec<Row>, Error> where
    T: ToStatement
[src]

Like Client::query.

pub fn query_one<T: ?Sized>(
    &mut self,
    query: &T,
    params: &[&(dyn ToSql + Sync)]
) -> Result<Row, Error> where
    T: ToStatement
[src]

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]

Like Client::query_opt.

pub fn query_raw<'b, T: ?Sized, I>(
    &mut self,
    query: &T,
    params: I
) -> Result<RowIter, Error> where
    T: ToStatement,
    I: IntoIterator<Item = &'b dyn ToSql>,
    I::IntoIter: ExactSizeIterator
[src]

Like Client::query_raw.

pub fn bind<T: ?Sized>(
    &mut self,
    query: &T,
    params: &[&(dyn ToSql + Sync)]
) -> Result<Portal, Error> where
    T: ToStatement
[src]

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]

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]

The maximally flexible version of query_portal.

pub fn copy_in<T: ?Sized>(&mut self, query: &T) -> Result<CopyInWriter, Error> where
    T: ToStatement
[src]

Like Client::copy_in.

pub fn copy_out<T: ?Sized>(&mut self, query: &T) -> Result<CopyOutReader, Error> where
    T: ToStatement
[src]

Like Client::copy_out.

pub fn simple_query(
    &mut self,
    query: &str
) -> Result<Vec<SimpleQueryMessage>, Error>
[src]

Like Client::simple_query.

pub fn batch_execute(&mut self, query: &str) -> Result<(), Error>[src]

Like Client::batch_execute.

pub fn transaction(&mut self) -> Result<Transaction, Error>[src]

Like Client::transaction.

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,