[−][src]Struct postgres::Transaction
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 safepoints.
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]
&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]
) -> Result<u64, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&dyn ToSql]
) -> Result<u64, Error> where
T: ToStatement,
Like Client::execute
.
pub fn query<T: ?Sized>(
&mut self,
query: &T,
params: &[&dyn ToSql]
) -> Result<Vec<Row>, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&dyn ToSql]
) -> Result<Vec<Row>, Error> where
T: ToStatement,
Like Client::query
.
pub fn query_iter<T: ?Sized>(
&mut self,
query: &T,
params: &[&dyn ToSql]
) -> Result<QueryIter, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&dyn ToSql]
) -> Result<QueryIter, Error> where
T: ToStatement,
Like Client::query_iter
.
pub fn bind<T: ?Sized>(
&mut self,
query: &T,
params: &[&dyn ToSql]
) -> Result<Portal, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&dyn ToSql]
) -> 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_iter(
&mut self,
portal: &Portal,
max_rows: i32
) -> Result<QueryPortalIter, Error>
[src]
&mut self,
portal: &Portal,
max_rows: i32
) -> Result<QueryPortalIter, Error>
Like query_portal
, except that it returns a fallible iterator over the resulting rows rather than buffering
the entire response in memory.
pub fn copy_in<T: ?Sized, R>(
&mut self,
query: &T,
params: &[&dyn ToSql],
reader: R
) -> Result<u64, Error> where
T: ToStatement,
R: Read,
[src]
&mut self,
query: &T,
params: &[&dyn ToSql],
reader: R
) -> Result<u64, Error> where
T: ToStatement,
R: Read,
Like Client::copy_in
.
pub fn copy_out<T: ?Sized>(
&mut self,
query: &T,
params: &[&dyn ToSql]
) -> Result<CopyOutReader, Error> where
T: ToStatement,
[src]
&mut self,
query: &T,
params: &[&dyn ToSql]
) -> 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 simple_query_iter(
&mut self,
query: &str
) -> Result<SimpleQueryIter, Error>
[src]
&mut self,
query: &str
) -> Result<SimpleQueryIter, Error>
Like Client::simple_query_iter
.
pub fn transaction(&mut self) -> Result<Transaction, Error>
[src]
Like Client::transaction
.
Trait Implementations
impl<'a> Drop for Transaction<'a>
[src]
Auto Trait Implementations
impl<'a> Send for Transaction<'a>
impl<'a> Sync for Transaction<'a>
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto 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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<T> Same for T
type Output = T
Should always be Self