]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix another buglet in archive_waldump.c.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 22 Mar 2026 22:48:38 +0000 (18:48 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 22 Mar 2026 22:48:38 +0000 (18:48 -0400)
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

index 067cb85c36ba9629dd1bb48c655ecee05bb27375..50a5eb426fec45cba2cbef83b69170641c76242e 100644 (file)
@@ -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);