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.
This commit is contained in:
Nikhil Benesch 2020-04-01 13:55:38 -04:00
parent 70ca1b4fa0
commit dd0c39e041
No known key found for this signature in database
GPG Key ID: FCF98542083C5A69

View File

@ -34,7 +34,7 @@ impl Read for CopyOutReader<'_> {
impl BufRead for CopyOutReader<'_> {
fn fill_buf(&mut self) -> io::Result<&[u8]> {
if !self.cur.has_remaining() {
while !self.cur.has_remaining() {
let mut stream = self.stream.pinned();
match self
.connection
@ -42,7 +42,7 @@ impl BufRead for CopyOutReader<'_> {
{
Ok(Some(cur)) => self.cur = cur,
Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)),
Ok(None) => {}
Ok(None) => break,
};
}