When pg_upgrade encounters a full disk while copying relation files,
it reports this as:
error while copying relation "xyz" (...): Success
because it doesn't set errno in some error cases. In other places we
treat short writes as ENOSPC, so here is a patch to do that for
pg_upgrade as well.
diff --git a/contrib/pg_upgrade/file.c b/contrib/pg_upgrade/file.c
index dfeb79f..b35034b 100644
--- a/contrib/pg_upgrade/file.c
+++ b/contrib/pg_upgrade/file.c
@@ -136,16 +136,22 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
int save_errno = 0;
if ((srcfile == NULL) || (dstfile == NULL))
+ {
+ errno = EINVAL;
return -1;
+ }
if ((src_fd = open(srcfile, O_RDONLY, 0)) < 0)
return -1;
if ((dest_fd = open(dstfile, O_RDWR | O_CREAT | (force ? 0 : O_EXCL), S_IRUSR | S_IWUSR)) < 0)
{
+ save_errno = errno;
+
if (src_fd != 0)
close(src_fd);
+ errno = save_errno;
return -1;
}
@@ -170,6 +176,8 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
if (write(dest_fd, buffer, nbytes) != nbytes)
{
+ if (errno == 0)
+ errno = ENOSPC;
save_errno = errno;
ret = -1;
break;
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers