| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{selfrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#}; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#, DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut#}; |
| 4 | |
| 5 | use futures_corerust-analyzer cargo futures-core 0.3.34 crate/::futurerust-analyzer cargo futures-core 0.3.34 future/::BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#; |
| 6 | |
| 7 | use craterust-analyzer cargo sqlx-core 0.8.3 crate/::databaserust-analyzer cargo sqlx-core 0.8.3 database/::Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#; |
| 8 | use craterust-analyzer cargo sqlx-core 0.8.3 crate/::errorrust-analyzer cargo sqlx-core 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#; |
| 9 | use craterust-analyzer cargo sqlx-core 0.8.3 crate/::poolrust-analyzer cargo sqlx-core 0.8.3 pool/::MaybePoolConnectionrust-analyzer cargo sqlx-core 0.8.3 pool/maybe/MaybePoolConnection#; |
| 10 | |
| 11 | /// Generic management of database transactions. |
| 12 | /// |
| 13 | /// This trait should not be used, except when implementing [`Connection`]. |
| 14 | #[doc(hidden)] |
| 15 | pub trait TransactionManagerrust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager# { |
| 16 | type Databaserust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#Database#: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#; |
| 17 | |
| 18 | /// Begin a new transaction or establish a savepoint within the active transaction. |
| 19 | fn beginrust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#begin().( |
| 20 | conn: &mut <Self::Databaserust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#Database# as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection#, |
| 21 | ) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>>; |
| 22 | |
| 23 | /// Commit the active transaction or release the most recent savepoint. |
| 24 | fn commitrust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#commit().( |
| 25 | conn: &mut <Self::Databaserust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#Database# as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection#, |
| 26 | ) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>>; |
| 27 | |
| 28 | /// Abort the active transaction or restore from the most recent savepoint. |
| 29 | fn rollbackrust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#rollback().( |
| 30 | conn: &mut <Self::Databaserust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#Database# as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection#, |
| 31 | ) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>>; |
| 32 | |
| 33 | /// Starts to abort the active transaction or restore from the most recent snapshot. |
| 34 | fn start_rollbackrust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#start_rollback().(conn: &mut <Self::Databaserust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#Database# as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection#); |
| 35 | } |
| 36 | |
| 37 | /// An in-progress database transaction or savepoint. |
| 38 | /// |
| 39 | /// A transaction starts with a call to [`Pool::begin`] or [`Connection::begin`]. |
| 40 | /// |
| 41 | /// A transaction should end with a call to [`commit`] or [`rollback`]. If neither are called |
| 42 | /// before the transaction goes out-of-scope, [`rollback`] is called. In other |
| 43 | /// words, [`rollback`] is called on `drop` if the transaction is still in-progress. |
| 44 | /// |
| 45 | /// A savepoint is a special mark inside a transaction that allows all commands that are |
| 46 | /// executed after it was established to be rolled back, restoring the transaction state to |
| 47 | /// what it was at the time of the savepoint. |
| 48 | /// |
| 49 | /// A transaction can be used as an [`Executor`] when performing queries: |
| 50 | /// ```rust,no_run |
| 51 | /// # use sqlx_core::acquire::Acquire; |
| 52 | /// # async fn example() -> sqlx::Result<()> { |
| 53 | /// # let id = 1; |
| 54 | /// # let mut conn: sqlx::PgConnection = unimplemented!(); |
| 55 | /// let mut tx = conn.begin().await?; |
| 56 | /// |
| 57 | /// let result = sqlx::query("DELETE FROM \"testcases\" WHERE id = $1") |
| 58 | /// .bind(id) |
| 59 | /// .execute(&mut *tx) |
| 60 | /// .await? |
| 61 | /// .rows_affected(); |
| 62 | /// |
| 63 | /// tx.commit().await |
| 64 | /// # } |
| 65 | /// ``` |
| 66 | /// [`Executor`]: crate::executor::Executor |
| 67 | /// [`Connection::begin`]: crate::connection::Connection::begin() |
| 68 | /// [`Pool::begin`]: crate::pool::Pool::begin() |
| 69 | /// [`commit`]: Self::commit() |
| 70 | /// [`rollback`]: Self::rollback() |
| 71 | pub struct Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#<'c, DB> |
| 72 | where |
| 73 | DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#, |
| 74 | { |
| 75 | connectionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#connection.: MaybePoolConnectionrust-analyzer cargo sqlx-core 0.8.3 pool/maybe/MaybePoolConnection#<'c, DB>, |
| 76 | openrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#open.: bool, |
| 77 | } |
| 78 | |
| 79 | impl<'c, DB> Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#<'c, DB> |
| 80 | where |
| 81 | DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#, |
| 82 | { |
| 83 | #[doc(hidden)] |
| 84 | pub fn beginrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`]begin().( |
| 85 | conn: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<MaybePoolConnectionrust-analyzer cargo sqlx-core 0.8.3 pool/maybe/MaybePoolConnection#<'c, DB>>, |
| 86 | ) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'c, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`], Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> { |
| 87 | let mut conn = conn.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(); |
| 88 | |
| 89 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::pinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]pin().(async move { |
| 90 | DB::TransactionManagerrust-analyzer cargo sqlx-core 0.8.3 database/Database#TransactionManager#::beginrust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#begin().(&mut conn).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 91 | |
| 92 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`] { |
| 93 | connectionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#connection.: conn, |
| 94 | openrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#open.: true, |
| 95 | }) |
| 96 | }) |
| 97 | } |
| 98 | |
| 99 | /// Commits this transaction or savepoint. |
| 100 | pub async fn commitrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`]commit().(mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 101 | DB::TransactionManagerrust-analyzer cargo sqlx-core 0.8.3 database/Database#TransactionManager#::commitrust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#commit().(&mut self.connectionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#connection.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 102 | self.openrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#open. = false; |
| 103 | |
| 104 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 105 | } |
| 106 | |
| 107 | /// Aborts this transaction or savepoint. |
| 108 | pub async fn rollbackrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`]rollback().(mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 109 | DB::TransactionManagerrust-analyzer cargo sqlx-core 0.8.3 database/Database#TransactionManager#::rollbackrust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#rollback().(&mut self.connectionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#connection.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 110 | self.openrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#open. = false; |
| 111 | |
| 112 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // NOTE: fails to compile due to lack of lazy normalization |
| 117 | // impl<'c, 't, DB: Database> crate::executor::Executor<'t> |
| 118 | // for &'t mut crate::transaction::Transaction<'c, DB> |
| 119 | // where |
| 120 | // &'c mut DB::Connection: Executor<'c, Database = DB>, |
| 121 | // { |
| 122 | // type Database = DB; |
| 123 | // |
| 124 | // |
| 125 | // |
| 126 | // fn fetch_many<'e, 'q: 'e, E: 'q>( |
| 127 | // self, |
| 128 | // query: E, |
| 129 | // ) -> futures_core::stream::BoxStream< |
| 130 | // 'e, |
| 131 | // Result< |
| 132 | // crate::Either<<DB as crate::database::Database>::QueryResult, DB::Row>, |
| 133 | // crate::error::Error, |
| 134 | // >, |
| 135 | // > |
| 136 | // where |
| 137 | // 't: 'e, |
| 138 | // E: crate::executor::Execute<'q, Self::Database>, |
| 139 | // { |
| 140 | // (&mut **self).fetch_many(query) |
| 141 | // } |
| 142 | // |
| 143 | // fn fetch_optional<'e, 'q: 'e, E: 'q>( |
| 144 | // self, |
| 145 | // query: E, |
| 146 | // ) -> futures_core::future::BoxFuture<'e, Result<Option<DB::Row>, crate::error::Error>> |
| 147 | // where |
| 148 | // 't: 'e, |
| 149 | // E: crate::executor::Execute<'q, Self::Database>, |
| 150 | // { |
| 151 | // (&mut **self).fetch_optional(query) |
| 152 | // } |
| 153 | // |
| 154 | // fn prepare_with<'e, 'q: 'e>( |
| 155 | // self, |
| 156 | // sql: &'q str, |
| 157 | // parameters: &'e [<Self::Database as crate::database::Database>::TypeInfo], |
| 158 | // ) -> futures_core::future::BoxFuture< |
| 159 | // 'e, |
| 160 | // Result< |
| 161 | // <Self::Database as crate::database::Database>::Statement<'q>, |
| 162 | // crate::error::Error, |
| 163 | // >, |
| 164 | // > |
| 165 | // where |
| 166 | // 't: 'e, |
| 167 | // { |
| 168 | // (&mut **self).prepare_with(sql, parameters) |
| 169 | // } |
| 170 | // |
| 171 | // #[doc(hidden)] |
| 172 | // fn describe<'e, 'q: 'e>( |
| 173 | // self, |
| 174 | // query: &'q str, |
| 175 | // ) -> futures_core::future::BoxFuture< |
| 176 | // 'e, |
| 177 | // Result<crate::describe::Describe<Self::Database>, crate::error::Error>, |
| 178 | // > |
| 179 | // where |
| 180 | // 't: 'e, |
| 181 | // { |
| 182 | // (&mut **self).describe(query) |
| 183 | // } |
| 184 | // } |
| 185 | |
| 186 | impl<'c, DB> Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#<'c, DB> |
| 187 | where |
| 188 | DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#, |
| 189 | { |
| 190 | fn fmtrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`][Debug]fmt().(&self, f: &mut Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 191 | // TODO: Show the full type <..<..<.. |
| 192 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Transaction").finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | impl<'c, DB> Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#<'c, DB> |
| 197 | where |
| 198 | DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#, |
| 199 | { |
| 200 | type Targetrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`][Deref]Target# = DB::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection#; |
| 201 | |
| 202 | #[inline] |
| 203 | fn derefrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`][Deref]deref().(&self) -> &Selfrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`][Deref]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# { |
| 204 | &self.connectionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#connection. |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | impl<'c, DB> DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut# for Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#<'c, DB> |
| 209 | where |
| 210 | DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#, |
| 211 | { |
| 212 | #[inline] |
| 213 | fn deref_mutrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`][DerefMut]deref_mut().(&mut self) -> &mut Selfrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`][DerefMut]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# { |
| 214 | &mut self.connectionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#connection. |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | // Implement `AsMut<DB::Connection>` so `Transaction` can be given to a |
| 219 | // `PgAdvisoryLockGuard`. |
| 220 | // |
| 221 | // See: https://github.com/launchbadge/sqlx/issues/2520 |
| 222 | impl<'c, DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#> AsMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsMut#<DB::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection#> for Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#<'c, DB> { |
| 223 | fn as_mutrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`][`AsMut<<DB as Database>::Connection>`]as_mut().(&mut self) -> &mut DB::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection# { |
| 224 | &mut self.connectionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#connection. |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | impl<'c, 't, DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#> craterust-analyzer cargo sqlx-core 0.8.3 crate/::acquirerust-analyzer cargo sqlx-core 0.8.3 acquire/::Acquirerust-analyzer cargo sqlx-core 0.8.3 acquire/Acquire#<'t> for &'t mut Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#<'c, DB> { |
| 229 | type Databaserust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`&'t mut Transaction<'c, DB>`][`Acquire<'t>`]Database# = DB; |
| 230 | |
| 231 | type Connectionrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`&'t mut Transaction<'c, DB>`][`Acquire<'t>`]Connection# = &'t mut <DB as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection#; |
| 232 | |
| 233 | #[inline] |
| 234 | fn acquirerust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`&'t mut Transaction<'c, DB>`][`Acquire<'t>`]acquire().(self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'t, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`&'t mut Transaction<'c, DB>`][`Acquire<'t>`]::Connectionrust-analyzer cargo sqlx-core 0.8.3 acquire/Acquire#Connection#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> { |
| 235 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::pinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]pin().(futures_utilrust-analyzer cargo futures-util 0.3.34 crate/::futurerust-analyzer cargo futures-util 0.3.34 future/::okrust-analyzer cargo futures-util 0.3.34 future/ready/ok().(&mut *rust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`][DerefMut]deref_mut().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self)) |
| 236 | } |
| 237 | |
| 238 | #[inline] |
| 239 | fn beginrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`&'t mut Transaction<'c, DB>`][`Acquire<'t>`]begin().(self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'t, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#<'t, DB>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> { |
| 240 | Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#::beginrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`]begin().(&mut *rust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`][DerefMut]deref_mut().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self) |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | impl<'c, DB> Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#<'c, DB> |
| 245 | where |
| 246 | DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#, |
| 247 | { |
| 248 | fn droprust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`][Drop]drop().(&mut self) { |
| 249 | if self.openrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#open. { |
| 250 | // starts a rollback operation |
| 251 | |
| 252 | // what this does depends on the database but generally this means we queue a rollback |
| 253 | // operation that will happen on the next asynchronous invocation of the underlying |
| 254 | // connection (including if the connection is returned to a pool) |
| 255 | |
| 256 | DB::TransactionManagerrust-analyzer cargo sqlx-core 0.8.3 database/Database#TransactionManager#::start_rollbackrust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager#start_rollback().(&mut self.connectionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#connection.); |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | pub fn begin_ansi_transaction_sqlrust-analyzer cargo sqlx-core 0.8.3 transaction/begin_ansi_transaction_sql().(depth: usize) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str> { |
| 262 | if depth rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 { |
| 263 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("BEGIN") |
| 264 | } else { |
| 265 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("SAVEPOINT _sqlx_savepoint_{depth}")) |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | pub fn commit_ansi_transaction_sqlrust-analyzer cargo sqlx-core 0.8.3 transaction/commit_ansi_transaction_sql().(depth: usize) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str> { |
| 270 | if depth rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 { |
| 271 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("COMMIT") |
| 272 | } else { |
| 273 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("RELEASE SAVEPOINT _sqlx_savepoint_{}", depth -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). 1)) |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | pub fn rollback_ansi_transaction_sqlrust-analyzer cargo sqlx-core 0.8.3 transaction/rollback_ansi_transaction_sql().(depth: usize) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str> { |
| 278 | if depth rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 { |
| 279 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("ROLLBACK") |
| 280 | } else { |
| 281 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 282 | "ROLLBACK TO SAVEPOINT _sqlx_savepoint_{}", |
| 283 | depth -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). 1 |
| 284 | )) |
| 285 | } |
| 286 | } |