Re: Fix some error handling for read() and errno

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us, magnus(at)hagander(dot)net, hlinnaka(at)iki(dot)fi
Subject: Re: Fix some error handling for read() and errno
Date: 2018-05-25 07:04:58
Message-ID: 20180525070458.GC15634@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
read-errno-handling-v3.patch text/x-diff 17.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Arseny Sher 2018-05-25 07:08:34 Re: Fix slot's xmin advancement and subxact's lost snapshots in decoding.
Previous Message Arseny Sher 2018-05-25 06:57:18 Re: Possible bug in logical replication.