pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[PATCH v2] Replace the hard-coded dump headers with macros
1+ messages / 1 participants
[nested] [flat]

* [PATCH v2] Replace the hard-coded dump headers with macros
@ 2026-06-03 07:18  Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 1+ messages in thread

From: Japin Li @ 2026-06-03 07:18 UTC (permalink / raw)

This commit repleaces the hard-coded dump headers with the existing macros to
improve maintainability and consistency:

  - In pg_backup_archiver.c, use TEXT_DUMP_HEADER instead of a duplicate
    hard-coded string for database dump header.
  - Move TEXT_DUMPALL_HEADER from pg_backup_archiver.c to pg_backup_archiver.h
    so it can be shared across files.
  - In pg_dumpall.c, replace the hard-coded cluster dump header with the newly
    exposed TEXT_DUMPALL_HEADER macro.

This avoids unnecessary duplication and ensures that any future changes to the
header text only need to be made in one place.

Author: Japin Li <japinli@hotmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
---
 src/bin/pg_dump/pg_backup_archiver.c | 3 +--
 src/bin/pg_dump/pg_backup_archiver.h | 2 ++
 src/bin/pg_dump/pg_dumpall.c         | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

inline patch 1: src/bin/pg_dump/pg_backup_archiver.c, src/bin/pg_dump/pg_backup_archiver.h, src/bin/pg_dump/pg_dumpall.c (+4/-3 lines) download inline-1.patchdiff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 2fd773ad84f..85d103464be 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -47,7 +47,6 @@ #include "pgtar.h" #define TEXT_DUMP_HEADER "--\n-- PostgreSQL database dump\n--\n\n" -#define TEXT_DUMPALL_HEADER "--\n-- PostgreSQL database cluster dump\n--\n\n" #define TOC_PREFIX_NONE "" #define TOC_PREFIX_DATA "Data for " @@ -466,7 +465,7 @@ RestoreArchive(Archive *AHX, bool append_data) if (ropt->filename || ropt->compression_spec.algorithm != PG_COMPRESSION_NONE) SetOutput(AH, ropt->filename, ropt->compression_spec, append_data); - ahprintf(AH, "--\n-- PostgreSQL database dump\n--\n\n"); + ahprintf(AH, TEXT_DUMP_HEADER); /* * If generating plain-text output, enter restricted mode to block any diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h index 1218bf6a6a1..21f226295a5 100644 --- a/src/bin/pg_dump/pg_backup_archiver.h +++ b/src/bin/pg_dump/pg_backup_archiver.h @@ -30,6 +30,8 @@ #include "pg_backup.h" #include "pqexpbuffer.h" +#define TEXT_DUMPALL_HEADER "--\n-- PostgreSQL database cluster dump\n--\n\n" + #define LOBBUFSIZE 16384 /* Data block types */ diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index c1f43113c53..49ae222211e 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -740,7 +740,7 @@ main(int argc, char *argv[]) } else { - fprintf(OPF, "--\n-- PostgreSQL database cluster dump\n--\n\n"); + fprintf(OPF, TEXT_DUMPALL_HEADER); if (verbose) dumpTimestamp("Started on"); -- 2.53.0
--=-=-=-- ^ permalink raw reply [nested|flat] 1+ messages in thread


only message in thread

Thread overview: 1+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-06-03 07:18 [PATCH v2] Replace the hard-coded dump headers with macros Japin Li <japinli@hotmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox