Skip to content

Commit

Permalink
fix(postgres): fix buffer management in PgCopyIn.read_from (#2630)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsing committed Jul 24, 2023
1 parent f2bb464 commit 94379d8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sqlx-core/src/net/socket/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl WriteBuffer {
self.buf.truncate(self.bytes_written);
self.buf.extend_from_slice(slice);
}

self.advance(slice.len());
self.sanity_check();
}

Expand Down
2 changes: 1 addition & 1 deletion sqlx-postgres/src/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
let buf = conn.stream.write_buffer_mut();

// CopyData format code and reserved space for length
buf.put_slice(b"d\0\0\0\0");
buf.put_slice(b"d\0\0\0\x04");

let read = match () {
// Tokio lets us read into the buffer without zeroing first
Expand Down

0 comments on commit 94379d8

Please sign in to comment.