postgresql/src/bin
Tom Lane 248c3a937d Clean up error handling in pg_basebackup's walmethods.c.
The error handling here was a mess, as a result of a fundamentally
bad design (relying on errno to keep its value much longer than is
safe to assume) as well as a lot of just plain sloppiness, both as
to noticing errors at all and as to reporting the correct errno.
Moreover, the recent addition of LZ4 compression broke things
completely, because liblz4 doesn't use errno to report errors.

To improve matters, keep the error state in the DirectoryMethodData or
TarMethodData struct, and add a string field so we can handle cases
that don't set errno.  (The tar methods already had a version of this,
but it can be done more efficiently since all these cases use a
constant error string.)  Make the dir and tar methods handle errors
in basically identical ways, which they didn't before.

This requires copying errno into the state struct in a lot of places,
which is a bit tedious, but it has the virtue that we can get rid of
ad-hoc code to save and restore errno in a number of places ... not
to mention that it fixes other places that should've saved/restored
errno but neglected to.

In passing, fix some pointlessly static buffers to be ordinary
local variables.

There remains an issue about exactly how to handle errors from
fsync(), but that seems like material for its own patch.

While the LZ4 problems are new, all the rest of this is fixes for
old bugs, so backpatch to v10 where walmethods.c was introduced.

Patch by me; thanks to Michael Paquier for review.

Discussion: https://postgr.es/m/1343113.1636489231@sss.pgh.pa.us
2021-11-17 14:16:34 -05:00
..
initdb Fix incorrect format placeholder 2021-11-03 07:34:28 +01:00
pg_amcheck Remove tests added by bd807be693. 2021-11-07 15:32:32 -05:00
pg_archivecleanup Move Perl test modules to a better namespace 2021-10-24 10:28:19 -04:00
pg_basebackup Clean up error handling in pg_basebackup's walmethods.c. 2021-11-17 14:16:34 -05:00
pg_checksums Move Perl test modules to a better namespace 2021-10-24 10:28:19 -04:00
pg_config Move Perl test modules to a better namespace 2021-10-24 10:28:19 -04:00
pg_controldata Move Perl test modules to a better namespace 2021-10-24 10:28:19 -04:00
pg_ctl Move Perl test modules to a better namespace 2021-10-24 10:28:19 -04:00
pg_dump Handle close() failures more robustly in pg_dump and pg_basebackup. 2021-11-17 13:08:25 -05:00
pg_resetwal Move Perl test modules to a better namespace 2021-10-24 10:28:19 -04:00
pg_rewind Move Perl test modules to a better namespace 2021-10-24 10:28:19 -04:00
pg_test_fsync Move Perl test modules to a better namespace 2021-10-24 10:28:19 -04:00
pg_test_timing Move Perl test modules to a better namespace 2021-10-24 10:28:19 -04:00
pg_upgrade Fix tests of pg_upgrade across different major versions 2021-10-13 09:22:00 +09:00
pg_verifybackup Move Perl test modules to a better namespace 2021-10-24 10:28:19 -04:00
pg_waldump Move Perl test modules to a better namespace 2021-10-24 10:28:19 -04:00
pgbench pgbench: Fix typo in comment. 2021-11-02 23:08:02 +09:00
pgevent Update copyright for 2021 2021-01-02 13:06:25 -05:00
psql Make psql's \password default to CURRENT_USER, not PQuser(conn). 2021-11-12 14:55:32 -05:00
scripts Clarify that --system reindexes system catalogs *only* 2021-10-27 16:28:11 +02:00
Makefile Add pg_amcheck, a CLI for contrib/amcheck. 2021-03-12 13:00:01 -05:00