"Oliver Elphick" <olly(at)lfix(dot)co(dot)uk> writes:
> I found the answer to this: the partition had filled up, and so the problem
> was lack of disk space.
> Could we have a more helpful error message?
Indeed. I don't like your solution however, since it's just papering
over the real problem which is lack of a suitable error code from
write(). Evidently write() isn't setting errno as long as it's able
to write at least some data. Perhaps we could do
errno = 0;
if (write(...) != expectedbytecount)
{
int save_errno = errno;
unlink(tmp);
errno = save_errno ? save_errno : ENOSPC;
elog(...);
}
Comments? Is it reasonable to guess that the problem must be ENOSPC
if write doesn't write all the bytes but also doesn't set errno?
Are there any systems that don't define ENOSPC?
regards, tom lane