From 69c57466a7521ee146cfdde766713181d45a2d36 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 22 Mar 2026 18:48:38 -0400 Subject: [PATCH] Fix another buglet in archive_waldump.c. While re-reading 860359ea0, I noticed another problem: when spilling to a temp file, it did not bother to check the result of fclose(). This is bad since write errors (like ENOSPC) may not be reported until close time. --- src/bin/pg_waldump/archive_waldump.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_waldump/archive_waldump.c b/src/bin/pg_waldump/archive_waldump.c index 067cb85c36b..50a5eb426fe 100644 --- a/src/bin/pg_waldump/archive_waldump.c +++ b/src/bin/pg_waldump/archive_waldump.c @@ -510,7 +510,9 @@ get_archive_wal_entry(const char *fname, XLogDumpPrivate *privateInfo) /* Write out the completed WAL file contents to a temp file. */ write_fp = prepare_tmp_write(entry->fname, privateInfo); perform_tmp_write(entry->fname, entry->buf, write_fp); - fclose(write_fp); + if (fclose(write_fp) != 0) + pg_fatal("could not close file \"%s/%s\": %m", + TmpWalSegDir, entry->fname); /* resetStringInfo won't release storage, so delete/recreate. */ destroyStringInfo(entry->buf);