fix(postgres): use checked decrement on pending_ready_for_query_count

This commit is contained in:
Austin Bonander 2024-08-23 22:03:19 -07:00
parent 823261aefc
commit 9e3ece49d7

View file

@ -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(())