postgresql/src/bin
Tom Lane f002ed2b8e Improve error reporting in pg_upgrade's file copying/linking/rewriting.
The previous design for this had copyFile(), linkFile(), and
rewriteVisibilityMap() returning strerror strings, with the caller
producing one-size-fits-all error messages based on that.  This made it
impossible to produce messages that described the failures with any degree
of precision, especially not short-read problems since those don't set
errno at all.

Since pg_upgrade has no intention of continuing after any error in this
area, let's fix this by just letting these functions call pg_fatal() for
themselves, making it easy for each point of failure to have a suitable
error message.  Taking this approach also allows dropping cleanup code
that was unnecessary and was often rather sloppy about preserving errno.
To not lose relevant info that was reported before, pass in the schema name
and table name of the current table so that they can be included in the
error reports.

An additional problem was the use of getErrorText(), which was flat out
wrong for all but a couple of call sites, because it unconditionally did
"_dosmaperr(GetLastError())" on Windows.  That's only appropriate when
reporting an error from a Windows-native API, which only a couple of
the callers were actually doing.  Thus, even the reported strerror string
would be unrelated to the actual failure in many cases on Windows.
To fix, get rid of getErrorText() altogether, and just have call sites
do strerror(errno) instead, since that's the way all the rest of our
frontend programs do it.  Add back the _dosmaperr() calls in the two
places where that's actually appropriate.

In passing, make assorted messages hew more closely to project style
guidelines, notably by removing initial capitals in not-complete-sentence
primary error messages.  (I didn't make any effort to clean up places
I didn't have another reason to touch, though.)

Per discussion of a report from Thomas Kellerer.  Back-patch to 9.6,
but no further; given the relative infrequency of reports of problems
here, it's not clear it's worth adapting the patch to older branches.

Patch by me, but with credit to Alvaro Herrera for spotting the issue
with getErrorText's misuse of _dosmaperr().

Discussion: <nsjrbh$8li$1@blaine.gmane.org>
2016-09-30 20:40:56 -04:00
..
initdb Move fsync routines of initdb into src/common/ 2016-09-29 12:00:00 -04:00
pg_archivecleanup Fix a bunch of places that called malloc and friends with no NULL check. 2016-08-30 18:22:43 -04:00
pg_basebackup pg_basebackup: Add --nosync option 2016-09-29 12:00:00 -04:00
pg_config Translation updates 2016-08-08 11:08:00 -04:00
pg_controldata Fix CRC check handling in get_controlfile 2016-09-28 12:00:00 -04:00
pg_ctl Fix CRC check handling in get_controlfile 2016-09-28 12:00:00 -04:00
pg_dump Make struct ParallelSlot private within pg_dump/parallel.c. 2016-09-27 14:29:12 -04:00
pg_resetxlog Translation updates 2016-08-08 11:08:00 -04:00
pg_rewind Add tests for various connection string issues 2016-09-22 12:00:00 -04:00
pg_test_fsync Move pg_test_fsync from contrib/ to src/bin/ 2015-04-19 22:20:49 -04:00
pg_test_timing Move pg_test_timing from contrib/ to src/bin/ 2015-04-20 21:30:12 -04:00
pg_upgrade Improve error reporting in pg_upgrade's file copying/linking/rewriting. 2016-09-30 20:40:56 -04:00
pg_xlogdump Retry opening new segments in pg_xlogdump --folllow 2016-09-30 11:22:00 +02:00
pgbench Fix newly-introduced issues in pgbench. 2016-09-26 20:23:50 -04:00
pgevent Update copyright for 2016 2016-01-02 13:33:40 -05:00
psql Refer to OS X as "macOS", except for the port name which is still "darwin". 2016-09-25 15:40:57 -04:00
scripts Include <sys/select.h> where needed 2016-09-27 01:05:21 -03:00
Makefile Update copyright for 2016 2016-01-02 13:33:40 -05:00