Re: Fix some error handling for read() and errno - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Fix some error handling for read() and errno
Date
Msg-id 20180525070458.GC15634@paquier.xyz
Whole thread Raw
In response to Re: Fix some error handling for read() and errno  (Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>)
Responses Re: Fix some error handling for read() and errno  (Robbie Harwood <rharwood@redhat.com>)
List pgsql-hackers
On Fri, May 25, 2018 at 01:19:58PM +0900, Kyotaro HORIGUCHI wrote:
> The case is not of an empty file. read() reads 0 bytes without
> error while lseek have told that the file has *more* data. I
> don't think that can happen. How about just commenting with
> something like the following?

Actually it can be useful to report that no data has been read and that
more data was expected, like that:
+       else if (nread == 0)
+           ereport(ERROR,
+                   (errmsg("no data read from file \"%s\": expected %zu more bytes",
+                           path, bytesleft)));
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Arseny Sher
Date:
Subject: Re: Possible bug in logical replication.
Next
From: Arseny Sher
Date:
Subject: Re: Fix slot's xmin advancement and subxact's lost snapshots in decoding.