fix(postgres): fix buffer management in PgCopyIn.read_from (#2630)

This commit is contained in:
Jesse Wang 2023-07-25 11:07:29 +12:00 committed by GitHub
parent f2bb464bcd
commit 94379d88b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

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

View File

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