pg_dump: Have _EndLO report errno after CFH->write_func() failure
authorAlvaro Herrera <[email protected]>
Wed, 17 May 2023 16:55:51 +0000 (18:55 +0200)
committerAlvaro Herrera <[email protected]>
Wed, 17 May 2023 16:55:51 +0000 (18:55 +0200)
Other callers of that function do things this way, but this one didn't
get the memo.

src/bin/pg_dump/pg_backup_directory.c

index 2177d5ff425b782136d972eb6796f596f7000028..7f2ac7c7fd1912b71c9d2bc0793af842f8847956 100644 (file)
@@ -697,7 +697,13 @@ _EndLO(ArchiveHandle *AH, TocEntry *te, Oid oid)
        /* register the LO in blobs.toc */
        len = snprintf(buf, sizeof(buf), "%u blob_%u.dat\n", oid, oid);
        if (!CFH->write_func(buf, len, CFH))
-               pg_fatal("could not write to LOs TOC file");
+       {
+               /* if write didn't set errno, assume problem is no disk space */
+               if (errno == 0)
+                       errno = ENOSPC;
+               pg_fatal("could not write to LOs TOC file: %s",
+                                CFH->get_error_func(CFH));
+       }
 }
 
 /*