summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/pg_basebackup/pg_basebackup.c5
-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, 7 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index ac07a0ef009..095953b1c96 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -1160,10 +1160,11 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
#ifdef HAVE_LIBZ
if (ztarfile != NULL)
{
+ errno = 0; /* in case gzclose() doesn't set it */
if (gzclose(ztarfile) != 0)
{
- pg_log_error("could not close compressed file \"%s\": %s",
- filename, get_gz_error(ztarfile));
+ pg_log_error("could not close compressed file \"%s\": %m",
+ filename);
exit(1);
}
}
diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c
index de0d9ae0d05..8dfce7d1ca5 100644
--- a/src/bin/pg_basebackup/receivelog.c
+++ b/src/bin/pg_basebackup/receivelog.c
@@ -74,7 +74,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 f55651e4e51..c437b68aca0 100644
--- a/src/bin/pg_basebackup/walmethods.c
+++ b/src/bin/pg_basebackup/walmethods.c
@@ -236,7 +236,10 @@ dir_close(Walfile f, WalCloseMethod method)
#ifdef HAVE_LIBZ
if (dir_data->compression > 0)
+ {
+ errno = 0; /* in case gzclose() doesn't set it */
r = gzclose(df->gzfp);
+ }
else
#endif
r = close(df->fd);
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index d98623e7f07..651adfdcc95 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -269,6 +269,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)
@@ -1582,6 +1583,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 90670a6e209..eef864df211 100644
--- a/src/bin/pg_dump/pg_backup_directory.c
+++ b/src/bin/pg_dump/pg_backup_directory.c
@@ -371,7 +371,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;
}
@@ -686,7 +687,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 */
@@ -705,7 +707,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 7e7625a39de..8c4037aca1a 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 */