Skip to content

Commit

Permalink
use fetch_add in create_savepoint methods
Browse files Browse the repository at this point in the history
  • Loading branch information
LucianBuzzo committed Jan 9, 2025
1 parent 9a07442 commit ef22dfd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
4 changes: 1 addition & 3 deletions quaint/src/connector/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ impl Transaction for DefaultTransaction<'_> {

/// Creates a savepoint in the transaction
async fn create_savepoint(&self) -> crate::Result<()> {
let current_depth = self.depth.load(Ordering::SeqCst);
let new_depth = current_depth + 1;
self.depth.store(new_depth, Ordering::SeqCst);
let new_depth = self.depth.fetch_add(1, Ordering::SeqCst) + 1;

let create_savepoint_statement = self.inner.create_savepoint_statement(new_depth);
self.inner.raw_cmd(&create_savepoint_statement).await?;
Expand Down
6 changes: 1 addition & 5 deletions query-engine/driver-adapters/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,7 @@ impl QuaintTransaction for JsTransaction {
}

async fn create_savepoint(&self) -> quaint::Result<()> {
let current_depth = self.depth.load(Ordering::SeqCst);
let new_depth = current_depth + 1;

// Increment the depth value
self.depth.fetch_add(1, Ordering::SeqCst);
let new_depth = self.depth.fetch_add(1, Ordering::SeqCst) + 1;

let create_savepoint_statement = self.create_savepoint_statement(new_depth);
if self.options().use_phantom_query {
Expand Down

0 comments on commit ef22dfd

Please sign in to comment.