Skip to content

Commit

Permalink
fix(postgres): use checked decrement on pending_ready_for_query_count
Browse files Browse the repository at this point in the history
  • Loading branch information
abonander committed Aug 24, 2024
1 parent 823261a commit 9e3ece4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sqlx-postgres/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ impl PgConnection {

#[inline(always)]
fn handle_ready_for_query(&mut self, message: ReceivedMessage) -> Result<(), Error> {
self.pending_ready_for_query_count -= 1;
self.pending_ready_for_query_count = self
.pending_ready_for_query_count
.checked_sub(1)
.ok_or_else(|| err_protocol!("received more ReadyForQuery messages than expected"))?;

self.transaction_status = message.decode::<ReadyForQuery>()?.transaction_status;

Ok(())
Expand Down

0 comments on commit 9e3ece4

Please sign in to comment.