| From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | Evgeniy Gorbanev <gorbanyoves(at)basealt(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: No error checking when reading from file using zstd in pg_dump |
| Date: | 2025-06-16 14:11:58 |
| Message-ID: | 3815B6CD-924B-40FA-823A-55E2F8F24602@yesql.se |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On 16 Jun 2025, at 15:56, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I've not checked to see what the other users of this API do, but
> if they're all like this then we need to fix that comment.
AFAICT all other callers of this API are throwing an error with pg_fatal, and
so does the function in question for ZStd decompression errors. If we handle
the case of fread() returning 0 to indicate an error like the below *untested
sketch* (with a better error message) this function is fully API compliant as
well.
/* If we have no more input to consume, we're done */
if (cnt == 0)
+ {
+ if (ferror(unconstify(void *, input->src)))
+ pg_fatal("could not read data to decompress: %m");
+
break;
+ }
If this seems like a good approach then Zstd_getc can be simplified as well as
it no longer needs to call ferror, it still needs to check feof though.
--
Daniel Gustafsson
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2025-06-16 14:20:07 | Re: No error checking when reading from file using zstd in pg_dump |
| Previous Message | Tom Lane | 2025-06-16 14:09:28 | Re: [PATCH] Remove unused #include's in src/backend/utils/adt/* |