Skip to content

Commit dd0c39e

Browse files
committed
Don't accidentally return early from CopyOutReader
The COPY OUT protocol allows sending CopyData packets that have no data. The (synchronous) CopyOutReader needs to be careful not to return an empty slice in this case, but instead request more data, since an empty slice is taken to mean EOF.
1 parent 70ca1b4 commit dd0c39e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

postgres/src/copy_out_reader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ impl Read for CopyOutReader<'_> {
3434

3535
impl BufRead for CopyOutReader<'_> {
3636
fn fill_buf(&mut self) -> io::Result<&[u8]> {
37-
if !self.cur.has_remaining() {
37+
while !self.cur.has_remaining() {
3838
let mut stream = self.stream.pinned();
3939
match self
4040
.connection
4141
.block_on({ async { stream.next().await.transpose() } })
4242
{
4343
Ok(Some(cur)) => self.cur = cur,
4444
Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)),
45-
Ok(None) => {}
45+
Ok(None) => break,
4646
};
4747
}
4848

0 commit comments

Comments
 (0)