Re: No error checking when reading from file using zstd in pg_dump

From: Evgeniy Gorbanev <gorbanyoves(at)basealt(dot)ru>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: 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 09:27:13
Message-ID: 9170123a-4612-42f8-8a7f-87ccac30d8f7@basealt.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

16.06.2025 15:00, Daniel Gustafsson пишет:
>> On 16 Jun 2025, at 10:52, Evgeniy Gorbanev <gorbanyoves(at)basealt(dot)ru> wrote:
>>
>> 16.06.2025 14:25, Daniel Gustafsson пишет:
>>>> On 16 Jun 2025, at 10:14, Evgeniy Gorbanev <gorbanyoves(at)basealt(dot)ru> wrote:
>>>> In src/bin/pg_dump/compress_zstd.c, the Zstd_read function always
>>>> returns true. But if you look at the Zstd_gets and Zstd_getc functions,
>>>> where Zstd_read is called via CFH->read_func, it is expected that
>>>> the Zstd_read function can also return false. In case of
>>>> a read-from-file error, the process is expected to terminate, but
>>>> pg_dump will continue the process.
>>>> I assume that after checking
>>>> if (cnt == 0)
>>>> should be
>>>> return false;
>>> if (cnt == 0)
>>> - break;
>>> + return false;
>>>
>>> As cnt is coming from fread() returning false here would be wrong as you cannot
>>> from 0 alone know if it's EOF or an error. Instead it needs to inspect the
>>> stream with feof() and ferror() to know how to proceed.
>> The feof() check is in the calling functions, e.g. in the Zstd_getc
>> function.
> That function is using feof/ferror to log an appropriate error message, what
> you are proposing is to consider all cases of EOF as an error. If you test
> that you will see lots of test starting to fail.
>
> --
> Daniel Gustafsson

I ran tests for pg_dump and they all passed. Logs attached.
Please check.

Attachment Content-Type Size
pg_dump_tests.log text/x-log 3.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-06-16 09:33:52 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Previous Message Amit Kapila 2025-06-16 09:20:18 Re: pglogical3 : support