Re: No error checking when reading from file using zstd in pg_dump
От | Daniel Gustafsson |
---|---|
Тема | Re: No error checking when reading from file using zstd in pg_dump |
Дата | |
Msg-id | 3815B6CD-924B-40FA-823A-55E2F8F24602@yesql.se обсуждение исходный текст |
Ответ на | Re: No error checking when reading from file using zstd in pg_dump (Evgeniy Gorbanev <gorbanyoves@basealt.ru>) |
Список | pgsql-hackers |
> On 16 Jun 2025, at 15:56, Tom Lane <tgl@sss.pgh.pa.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
В списке pgsql-hackers по дате отправления: