pgsql: Prevent redeclaration of typedef TocEntry.
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(+)
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.patchtext/x-diff; charset=utf-8Download+4-14
=?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
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