sentinel_driver/connection/
transaction_impl.rs1use super::{notify, Connection, Result, TransactionConfig};
2
3impl Connection {
4 pub async fn begin(&mut self) -> Result<()> {
6 self.begin_with(TransactionConfig::new()).await
7 }
8
9 pub async fn begin_with(&mut self, config: TransactionConfig) -> Result<()> {
11 self.simple_query(&config.begin_sql()).await?;
12 Ok(())
13 }
14
15 pub async fn commit(&mut self) -> Result<()> {
17 self.simple_query("COMMIT").await?;
18 Ok(())
19 }
20
21 pub async fn rollback(&mut self) -> Result<()> {
23 self.simple_query("ROLLBACK").await?;
24 Ok(())
25 }
26
27 pub async fn savepoint(&mut self, name: &str) -> Result<()> {
29 self.simple_query(&format!("SAVEPOINT {}", notify::quote_identifier(name)))
30 .await?;
31 Ok(())
32 }
33
34 pub async fn rollback_to(&mut self, name: &str) -> Result<()> {
36 self.simple_query(&format!(
37 "ROLLBACK TO SAVEPOINT {}",
38 notify::quote_identifier(name)
39 ))
40 .await?;
41 Ok(())
42 }
43}