Commit a0d7c5f6 authored by Bruce Momjian's avatar Bruce Momjian

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.
parent f4122a8d
$PostgreSQL: pgsql/contrib/pg_upgrade/TESTING,v 1.2 2010/07/03 14:23:13 momjian Exp $ $PostgreSQL: pgsql/contrib/pg_upgrade/TESTING,v 1.3 2010/07/09 16:51:23 momjian Exp $
The most effective way to test pg_upgrade, aside from testing on user The most effective way to test pg_upgrade, aside from testing on user
data, is by upgrading the PostgreSQL regression database. data, is by upgrading the PostgreSQL regression database.
...@@ -22,11 +22,6 @@ Here are the steps needed to create a regression database dump file: ...@@ -22,11 +22,6 @@ Here are the steps needed to create a regression database dump file:
a) Change CREATE FUNCTION shared object paths to use '$libdir' a) Change CREATE FUNCTION shared object paths to use '$libdir'
The old and new cluster will have different shared object paths. The old and new cluster will have different shared object paths.
b) Remove 'regex_flavor' (not supported in Postgres 9.0)
c) Change CREATE OR REPLACE LANGUAGE to CREATE LANGUAGE
The former syntax is only supported in Postgres 9.0.
d) Perform the load/dump twice d) Perform the load/dump twice
This fixes problems with the ordering of COPY columns for This fixes problems with the ordering of COPY columns for
inherited tables. inherited tables.
...@@ -35,7 +30,11 @@ Here are the steps needed to create a regression database dump file: ...@@ -35,7 +30,11 @@ Here are the steps needed to create a regression database dump file:
Commands like CREATE TRIGGER and ALTER TABLE sometimes have Commands like CREATE TRIGGER and ALTER TABLE sometimes have
differences. differences.
f) Adjust extra_float_digits c) For pre-9.0, change CREATE OR REPLACE LANGUAGE to CREATE LANGUAGE
b) For pre-9.0, remove 'regex_flavor'
f) For pre-9.0, adjust extra_float_digits
Postgres 9.0 pg_dump uses extra_float_digits=-2 for pre-9.0 Postgres 9.0 pg_dump uses extra_float_digits=-2 for pre-9.0
databases, and extra_float_digits=-3 for >= 9.0 databases. databases, and extra_float_digits=-3 for >= 9.0 databases.
It is necessary to modify 9.0 pg_dump to always use -3, and It is necessary to modify 9.0 pg_dump to always use -3, and
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* file system operations * file system operations
* *
* Copyright (c) 2010, PostgreSQL Global Development Group * 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" #include "pg_upgrade.h"
...@@ -170,6 +170,8 @@ copy_file(const char *srcfile, const char *dstfile, bool force) ...@@ -170,6 +170,8 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
if (nbytes < 0) if (nbytes < 0)
{ {
int save_errno = errno;
if (buffer != NULL) if (buffer != NULL)
free(buffer); free(buffer);
...@@ -179,6 +181,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force) ...@@ -179,6 +181,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
if (dest_fd != 0) if (dest_fd != 0)
close(dest_fd); close(dest_fd);
errno = save_errno;
return -1; return -1;
} }
...@@ -190,8 +193,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force) ...@@ -190,8 +193,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
if (write(dest_fd, buffer, nbytes) != nbytes) if (write(dest_fd, buffer, nbytes) != nbytes)
{ {
/* if write didn't set errno, assume problem is no disk space */ /* if write didn't set errno, assume problem is no disk space */
if (errno == 0) int save_errno = errno ? errno : ENOSPC;
errno = ENOSPC;
if (buffer != NULL) if (buffer != NULL)
free(buffer); free(buffer);
...@@ -202,6 +204,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force) ...@@ -202,6 +204,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
if (dest_fd != 0) if (dest_fd != 0)
close(dest_fd); close(dest_fd);
errno = save_errno;
return -1; return -1;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment