1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Properly report errno/out-of-disk-space error from pg_upgrade when in

copy mode, per report from depstein@alliedtesting.com.

Patch suggestion from Magnus.

Backpatch to 9.0.X.
This commit is contained in:
Bruce Momjian
2010-07-09 16:51:23 +00:00
parent f4122a8d50
commit a0d7c5f689
2 changed files with 12 additions and 10 deletions

View File

@ -4,7 +4,7 @@
* file system operations
*
* Copyright (c) 2010, PostgreSQL Global Development Group
* $PostgreSQL: pgsql/contrib/pg_upgrade/file.c,v 1.13 2010/07/06 19:18:55 momjian Exp $
* $PostgreSQL: pgsql/contrib/pg_upgrade/file.c,v 1.14 2010/07/09 16:51:23 momjian Exp $
*/
#include "pg_upgrade.h"
@ -170,6 +170,8 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
if (nbytes < 0)
{
int save_errno = errno;
if (buffer != NULL)
free(buffer);
@ -179,6 +181,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
if (dest_fd != 0)
close(dest_fd);
errno = save_errno;
return -1;
}
@ -190,8 +193,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
if (write(dest_fd, buffer, nbytes) != nbytes)
{
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
errno = ENOSPC;
int save_errno = errno ? errno : ENOSPC;
if (buffer != NULL)
free(buffer);
@ -202,6 +204,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
if (dest_fd != 0)
close(dest_fd);
errno = save_errno;
return -1;
}
}