Use TEXT_DUMP_HEADER macro instead of hard-coded string in pg_backup_archiver.c

Поиск
Список
Период
Сортировка
Искать

Use TEXT_DUMP_HEADER macro instead of hard-coded string in pg_backup_archiver.c

От:
Japin Li <japinli@hotmail.com>
Дата:
Вложения:

Hi,

I noticed that in pg_backup_archiver.c, RestoreArchive() writes the dump header
using a hard-coded string:

       ahprintf(AH, "--\n-- PostgreSQL database dump\n--\n\n");

However, the macro TEXT_DUMP_HEADER (defined in the same file) already contains
exactly the same content.  To keep the code consistent and maintainable, this
patch replaces the hard-coded string with the macro.

A hard-coded version of TEXT_DUMPALL_HEADER exists in pg_dumpall.c, but since
it spans multiple files, it is left untouched.

-- 
Regards,
Japin Li
ChengDu WenWu Information Technology Co., Ltd.

Re: Use TEXT_DUMP_HEADER macro instead of hard-coded string in pg_backup_archiver.c

От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 3 Jun 2026, at 09:58, Japin Li  wrote:
> 
> 
> Hi,
> 
> I noticed that in pg_backup_archiver.c, RestoreArchive() writes the dump header
> using a hard-coded string:
> 
>       ahprintf(AH, "--\n-- PostgreSQL database dump\n--\n\n");
> 
> However, the macro TEXT_DUMP_HEADER (defined in the same file) already contains
> exactly the same content.  To keep the code consistent and maintainable, this
> patch replaces the hard-coded string with the macro.

Seems reasonable.

> A hard-coded version of TEXT_DUMPALL_HEADER exists in pg_dumpall.c, but since
> it spans multiple files, it is left untouched.

The alternative would be to move the definitions to pg_backup_archiver.h and
use them consistently.

--
Daniel Gustafsson



Re: Use TEXT_DUMP_HEADER macro instead of hard-coded string in pg_backup_archiver.c

От:
Japin Li <japinli@hotmail.com>
Дата:
Вложения:

Hi, Daniel

On Wed, 03 Jun 2026 at 10:14, Daniel Gustafsson  wrote:
>> On 3 Jun 2026, at 09:58, Japin Li  wrote:
>> 
>> 
>> Hi,
>> 
>> I noticed that in pg_backup_archiver.c, RestoreArchive() writes the dump header
>> using a hard-coded string:
>> 
>>       ahprintf(AH, "--\n-- PostgreSQL database dump\n--\n\n");
>> 
>> However, the macro TEXT_DUMP_HEADER (defined in the same file) already contains
>> exactly the same content.  To keep the code consistent and maintainable, this
>> patch replaces the hard-coded string with the macro.
>
> Seems reasonable.
>

Thanks for your review.

>> A hard-coded version of TEXT_DUMPALL_HEADER exists in pg_dumpall.c, but since
>> it spans multiple files, it is left untouched.
>
> The alternative would be to move the definitions to pg_backup_archiver.h and
> use them consistently.
>

Fixed as you suggested.

> --
> Daniel Gustafsson

-- 
Regards,
Japin Li
ChengDu WenWu Information Technology Co., Ltd.

FAQ