From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Tomas Vondra <tomas(at)vondra(dot)me>, 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-26 12:19:01 |
Message-ID: | A9EB5A06-6C77-418B-B582-AFE5F027B4B3@yesql.se |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> On 25 Jun 2025, at 17:58, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I looked over this patchset briefly, and found a couple of nits:
Thanks for looking!
> v5-0002, in compress_io.h:
>
> + * Returns true on success and throws error for all error conditions.
>
> It doesn't return true anymore. Should be more like
>
> + * Returns nothing. Exits via pg_fatal for all error conditions.
Instead of this I changed the write_func signature to return the number of
bytes written as size_t. The API is loosely modelled around the libc stream API so
going to void seemed less justifiable than size_t, even if the actual
returnvalue is fairly useless due to erroring out via pg_fatal.
> In LZ4Stream_write: you dropped the bit about
>
> - errno = (errno) ? errno : ENOSPC;
>
> but I think that's still necessary: we must assume ENOSPC if fwrite
> doesn't set errno.
Doh, of course, fixed in the attached.
> Other fwrite callers (write_none, Zstd_write) need
> this too. v5-0004 has an instance too, in Zstd_close. I did not check
> to see if other fwrite calls are OK, but it'd be good to verify
> that they all follow the pattern of presetting errno to 0 and then
> replacing that with ENOSPC.
I went over all the fwrite callsites *in this patchset* and made sure they
follow the pattern. There are a number of more fwrite calls in pg_dump (and
elsewhere) which might need the same treatment but I left those for a separate
patch to keep this focused on the compression API.
--
Daniel Gustafsson
Attachment | Content-Type | Size |
---|---|---|
v6-0001-Initial-patch-by-Tom-Lane.patch | application/octet-stream | 8.3 KB |
v6-0002-pg_dump-compression-API-write_func.patch | application/octet-stream | 8.2 KB |
v6-0003-pg_dump-compression-API-open_func.patch | application/octet-stream | 4.9 KB |
v6-0004-pg_dump-compression-API-close_func.patch | application/octet-stream | 4.9 KB |
v6-0005-pg_dump-compression-API-LZ4Stream_init.patch | application/octet-stream | 1.3 KB |
v6-0006-pg_dump-compression-API-read_func-gets_func.patch | application/octet-stream | 7.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Aleksander Alekseev | 2025-06-26 12:46:15 | Re: PG18 protocol version |
Previous Message | Álvaro Herrera | 2025-06-26 12:06:34 | Re: Remove HeapTupleheaderSetXmin{Committed,Invalid} functions |