Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a0d7c5f

Browse files
committed
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.
1 parent f4122a8 commit a0d7c5f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

contrib/pg_upgrade/TESTING

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$PostgreSQL: pgsql/contrib/pg_upgrade/TESTING,v 1.2 2010/07/03 14:23:13 momjian Exp $
1+
$PostgreSQL: pgsql/contrib/pg_upgrade/TESTING,v 1.3 2010/07/09 16:51:23 momjian Exp $
22

33
The most effective way to test pg_upgrade, aside from testing on user
44
data, is by upgrading the PostgreSQL regression database.
@@ -22,11 +22,6 @@ Here are the steps needed to create a regression database dump file:
2222
a) Change CREATE FUNCTION shared object paths to use '$libdir'
2323
The old and new cluster will have different shared object paths.
2424

25-
b) Remove 'regex_flavor' (not supported in Postgres 9.0)
26-
27-
c) Change CREATE OR REPLACE LANGUAGE to CREATE LANGUAGE
28-
The former syntax is only supported in Postgres 9.0.
29-
3025
d) Perform the load/dump twice
3126
This fixes problems with the ordering of COPY columns for
3227
inherited tables.
@@ -35,7 +30,11 @@ Here are the steps needed to create a regression database dump file:
3530
Commands like CREATE TRIGGER and ALTER TABLE sometimes have
3631
differences.
3732

38-
f) Adjust extra_float_digits
33+
c) For pre-9.0, change CREATE OR REPLACE LANGUAGE to CREATE LANGUAGE
34+
35+
b) For pre-9.0, remove 'regex_flavor'
36+
37+
f) For pre-9.0, adjust extra_float_digits
3938
Postgres 9.0 pg_dump uses extra_float_digits=-2 for pre-9.0
4039
databases, and extra_float_digits=-3 for >= 9.0 databases.
4140
It is necessary to modify 9.0 pg_dump to always use -3, and

contrib/pg_upgrade/file.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* file system operations
55
*
66
* Copyright (c) 2010, PostgreSQL Global Development Group
7-
* $PostgreSQL: pgsql/contrib/pg_upgrade/file.c,v 1.13 2010/07/06 19:18:55 momjian Exp $
7+
* $PostgreSQL: pgsql/contrib/pg_upgrade/file.c,v 1.14 2010/07/09 16:51:23 momjian Exp $
88
*/
99

1010
#include "pg_upgrade.h"
@@ -170,6 +170,8 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
170170

171171
if (nbytes < 0)
172172
{
173+
int save_errno = errno;
174+
173175
if (buffer != NULL)
174176
free(buffer);
175177

@@ -179,6 +181,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
179181
if (dest_fd != 0)
180182
close(dest_fd);
181183

184+
errno = save_errno;
182185
return -1;
183186
}
184187

@@ -190,8 +193,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
190193
if (write(dest_fd, buffer, nbytes) != nbytes)
191194
{
192195
/* if write didn't set errno, assume problem is no disk space */
193-
if (errno == 0)
194-
errno = ENOSPC;
196+
int save_errno = errno ? errno : ENOSPC;
195197

196198
if (buffer != NULL)
197199
free(buffer);
@@ -202,6 +204,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
202204
if (dest_fd != 0)
203205
close(dest_fd);
204206

207+
errno = save_errno;
205208
return -1;
206209
}
207210
}

0 commit comments

Comments
 (0)