mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-19 08:39:44 +00:00
fix(postgres) use signed int for length prefix in PgCopyIn (#3701)
This commit is contained in:
@@ -230,10 +230,10 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
|
||||
}
|
||||
|
||||
// Write the length
|
||||
let read32 = u32::try_from(read)
|
||||
.map_err(|_| err_protocol!("number of bytes read exceeds 2^32: {}", read))?;
|
||||
let read32 = i32::try_from(read)
|
||||
.map_err(|_| err_protocol!("number of bytes read exceeds 2^31 - 1: {}", read))?;
|
||||
|
||||
(&mut buf.get_mut()[1..]).put_u32(read32 + 4);
|
||||
(&mut buf.get_mut()[1..]).put_i32(read32 + 4);
|
||||
|
||||
conn.inner.stream.flush().await?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user