aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_basebackup/bbstreamer_file.c6
-rw-r--r--src/bin/pg_basebackup/receivelog.c7
-rw-r--r--src/bin/pg_basebackup/walmethods.c3
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c2
-rw-r--r--src/bin/pg_dump/pg_backup_directory.c9
-rw-r--r--src/bin/pg_dump/pg_backup_tar.c5
6 files changed, 24 insertions, 8 deletions
diff --git a/src/bin/pg_basebackup/bbstreamer_file.c b/src/bin/pg_basebackup/bbstreamer_file.c
index eba173f6889..5dc828f742b 100644
--- a/src/bin/pg_basebackup/bbstreamer_file.c
+++ b/src/bin/pg_basebackup/bbstreamer_file.c
@@ -303,11 +303,11 @@ bbstreamer_gzip_writer_finalize(bbstreamer *streamer)
mystreamer = (bbstreamer_gzip_writer *) streamer;
+ errno = 0; /* in case gzclose() doesn't set it */
if (gzclose(mystreamer->gzfile) != 0)
{
- pg_log_error("could not close compressed file \"%s\": %s",
- mystreamer->pathname,
- get_gz_error(mystreamer->gzfile));
+ pg_log_error("could not close compressed file \"%s\": %m",
+ mystreamer->pathname);
exit(1);
}
diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c
index e9489f7dcbd..d0ca1f2a7f2 100644
--- a/src/bin/pg_basebackup/receivelog.c
+++ b/src/bin/pg_basebackup/receivelog.c
@@ -70,7 +70,12 @@ mark_file_as_archived(StreamCtl *stream, const char *fname)
return false;
}
- stream->walmethod->close(f, CLOSE_NORMAL);
+ if (stream->walmethod->close(f, CLOSE_NORMAL) != 0)
+ {
+ pg_log_error("could not close archive status file \"%s\": %s",
+ tmppath, stream->walmethod->getlasterror());
+ return false;
+ }
return true;
}
diff --git a/src/bin/pg_basebackup/walmethods.c b/src/bin/pg_basebackup/walmethods.c
index f1ba2a828a0..5cc10c6eba0 100644
--- a/src/bin/pg_basebackup/walmethods.c
+++ b/src/bin/pg_basebackup/walmethods.c
@@ -355,7 +355,10 @@ dir_close(Walfile f, WalCloseMethod method)
#ifdef HAVE_LIBZ
if (dir_data->compression_method == COMPRESSION_GZIP)
+ {
+ errno = 0; /* in case gzclose() doesn't set it */
r = gzclose(df->gzfp);
+ }
else
#endif
#ifdef HAVE_LIBLZ4
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 2c4cfb9457e..59f4fbb2cc1 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -268,6 +268,7 @@ CloseArchive(Archive *AHX)
AH->ClosePtr(AH);
/* Close the output */
+ errno = 0; /* in case gzclose() doesn't set it */
if (AH->gzOut)
res = GZCLOSE(AH->OF);
else if (AH->OF != stdout)
@@ -1567,6 +1568,7 @@ RestoreOutput(ArchiveHandle *AH, OutputContext savedContext)
{
int res;
+ errno = 0; /* in case gzclose() doesn't set it */
if (AH->gzOut)
res = GZCLOSE(AH->OF);
else
diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c
index 8aff6bce387..4e0fb7d2d36 100644
--- a/src/bin/pg_dump/pg_backup_directory.c
+++ b/src/bin/pg_dump/pg_backup_directory.c
@@ -369,7 +369,8 @@ _EndData(ArchiveHandle *AH, TocEntry *te)
lclContext *ctx = (lclContext *) AH->formatData;
/* Close the file */
- cfclose(ctx->dataFH);
+ if (cfclose(ctx->dataFH) != 0)
+ fatal("could not close data file: %m");
ctx->dataFH = NULL;
}
@@ -680,7 +681,8 @@ _EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
int len;
/* Close the BLOB data file itself */
- cfclose(ctx->dataFH);
+ if (cfclose(ctx->dataFH) != 0)
+ fatal("could not close blob data file: %m");
ctx->dataFH = NULL;
/* register the blob in blobs.toc */
@@ -699,7 +701,8 @@ _EndBlobs(ArchiveHandle *AH, TocEntry *te)
{
lclContext *ctx = (lclContext *) AH->formatData;
- cfclose(ctx->blobsTocFH);
+ if (cfclose(ctx->blobsTocFH) != 0)
+ fatal("could not close blobs TOC file: %m");
ctx->blobsTocFH = NULL;
}
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index 65bcb41a2f8..5c351acda01 100644
--- a/src/bin/pg_dump/pg_backup_tar.c
+++ b/src/bin/pg_dump/pg_backup_tar.c
@@ -438,8 +438,11 @@ tarClose(ArchiveHandle *AH, TAR_MEMBER *th)
* Close the GZ file since we dup'd. This will flush the buffers.
*/
if (AH->compression != 0)
+ {
+ errno = 0; /* in case gzclose() doesn't set it */
if (GZCLOSE(th->zFH) != 0)
- fatal("could not close tar member");
+ fatal("could not close tar member: %m");
+ }
if (th->mode == 'w')
_tarAddFile(AH, th); /* This will close the temp file */