pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Prevent redeclaration of typedef TocEntry.
4+ messages / 4 participants
[nested] [flat]

Commits from this thread:
  2025-04-05 4be6a74cfb  pg_dump: Tiny header cleanup
* pgsql: Prevent redeclaration of typedef TocEntry.
@ 2025-04-04 20:56  Nathan Bossart <nathan@postgresql.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Nathan Bossart @ 2025-04-04 20:56 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Prevent redeclaration of typedef TocEntry.

Commit 9c02e3a986 added a forward declaration for this typedef that
caused redeclarations, which is not valid in C99.  To fix, add some
preprocessor guards to avoid a redefinition, as is done elsewhere
(e.g., commit 382092a0cd).

Per buildfarm.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8ec0aaeae09482925d2d15ce4a91f6953bdb1566

Modified Files
--------------
src/bin/pg_dump/pg_backup.h          | 3 +++
src/bin/pg_dump/pg_backup_archiver.h | 3 +++
2 files changed, 6 insertions(+)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Prevent redeclaration of typedef TocEntry.
@ 2025-04-04 21:40  Álvaro Herrera <alvherre@alvh.no-ip.org>
  parent: Nathan Bossart <nathan@postgresql.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Álvaro Herrera @ 2025-04-04 21:40 UTC (permalink / raw)
  To: Nathan Bossart <nathan@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org

On 2025-Apr-04, Nathan Bossart wrote:

> Prevent redeclaration of typedef TocEntry.
> 
> Commit 9c02e3a986 added a forward declaration for this typedef that
> caused redeclarations, which is not valid in C99.  To fix, add some
> preprocessor guards to avoid a redefinition, as is done elsewhere
> (e.g., commit 382092a0cd).

Hmm, I have the impression that this results from some very old
untidyness in the pg_dump headers in general.  The fact that
DataDumperPtr is in pg_backup.h seems now more of an accident than
something we would really choose to do nowadays -- it's been that way
since pg_dump was introduced in commit 500b62b0570f apparently.  I'm
sure there were good reasons to have it there then.  But we've
restructured the pg_dump headers at least once, and as far as I can see
there aren't anymore.  AFAICS we could move both DefnDumperPtr and
DataDumperPtr typedefs to pg_backup_archiver.h, together with struct
_tocEntry (the only place where they are used), and we'd have less of a
mess here.  Then we don't need struct TocEntry in pg_backup.h anymore.

Plus, these function typedefs aren't really "public interface" for
pg_dump anyway (which is what pg_backup.h claims to be), so I think it
would be a sensible cleanup.  Patch attached.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
Thou shalt check the array bounds of all strings (indeed, all arrays), for
surely where thou typest "foo" someone someday shall type
"supercalifragilisticexpialidocious" (5th Commandment for C programmers)

Attachments:

  0001-cleanup-pg_dump-headers-a-bit.patch (text/x-diff, 0B) download

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Prevent redeclaration of typedef TocEntry.
@ 2025-04-05 06:10  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Álvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2025-04-05 06:10 UTC (permalink / raw)
  To: Álvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: Nathan Bossart <nathan@postgresql.org>; pgsql-committers@lists.postgresql.org

=?utf-8?Q?=C3=81lvaro?= Herrera <alvherre@alvh.no-ip.org> writes:
> ... AFAICS we could move both DefnDumperPtr and
> DataDumperPtr typedefs to pg_backup_archiver.h, together with struct
> _tocEntry (the only place where they are used), and we'd have less of a
> mess here.  Then we don't need struct TocEntry in pg_backup.h anymore.

+1 for this simplification.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Prevent redeclaration of typedef TocEntry.
@ 2025-04-05 13:13  Nathan Bossart <nathandbossart@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Nathan Bossart @ 2025-04-05 13:13 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Álvaro Herrera <alvherre@alvh.no-ip.org>; Nathan Bossart <nathan@postgresql.org>; pgsql-committers@lists.postgresql.org

Sorry, I missed this one last night.

On Sat, Apr 05, 2025 at 02:10:10AM -0400, Tom Lane wrote:
> =?utf-8?Q?=C3=81lvaro?= Herrera <alvherre@alvh.no-ip.org> writes:
>> ... AFAICS we could move both DefnDumperPtr and
>> DataDumperPtr typedefs to pg_backup_archiver.h, together with struct
>> _tocEntry (the only place where they are used), and we'd have less of a
>> mess here.  Then we don't need struct TocEntry in pg_backup.h anymore.
> 
> +1 for this simplification.

This is a better fix.  Thanks for taking care of it.

-- 
nathan





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2025-04-05 13:13 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-04-04 20:56 pgsql: Prevent redeclaration of typedef TocEntry. Nathan Bossart <nathan@postgresql.org>
2025-04-04 21:40 ` Álvaro Herrera <alvherre@alvh.no-ip.org>
2025-04-05 06:10   ` Tom Lane <tgl@sss.pgh.pa.us>
2025-04-05 13:13     ` Nathan Bossart <nathandbossart@gmail.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