Re: pgstat include expansion
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers@postgresql.org, Amit Kapila <amit.kapila16@gmail.com>, Alvaro Herrera <alvherre@kurilemu.de>
Date: 2026-02-16T17:18:41Z
Lists: pgsql-hackers
Hi, On 2026-02-16 13:36:02 +0900, Michael Paquier wrote: > On Fri, Feb 13, 2026 at 05:14:01PM -0500, Andres Freund wrote: > > I think now that we rely on C11, we actually could also forward-declare enum > > typedefs. That would allow us to avoid including > > worker_internal.h. Unfortunately I think C++ might throw a wrench in the mix > > for that - IIUC it only allows forward declaring enums when using 'enum > > class', but I don't think we can rely on that. I think the best solution > > would be to move the typedef to a more suitable header, but baring that, I > > guess just passing an int would do. > > > > -extern void pgstat_report_subscription_error(Oid subid, > > - LogicalRepWorkerType wtype); > > +extern void pgstat_report_subscription_error(Oid subid, int wtype); > > FWIW, I like some type enforcements when it comes to such report > routines. That avoids some careless assignments. In theory I agree (I after all did suggest moving the typedef to a better header). However, the type enforcement argument IMO is somewhat bogus, as C doesn't really have strong enum types, therefore you can just pass pretty random stuff. I do wish C enums could be stronger... > This is usually a sign of header refactoring to me, where the "light" > declarations ought to be moved into an independent header that can be fed > back to other places, like this one. An enum declaration or a set of > constants can be usually worth a split if their knowledge gets a lot across > the tree. That's just to say that while I agree about reducing the header > footprint, I don't find the result presented here to be the best thing we > can do. I literally wrote that it isn't the best solution in the quoted portion above and suggested moving the typedef to a different header? I was hoping the author of the code would do that... Greetings, Andres Freund
Commits
-
Don't include wait_event.h in pgstat.h
- 868825aaeb40 19 (unreleased) landed
-
Don't include proc.h in shm_mq.h
- a2c89835f512 19 (unreleased) landed
-
Don't include latch.h in libpq/libpq.h
- 7b9b620d8fc7 19 (unreleased) landed
-
Reduce includes in pgstat.h
- 7bb50dd7d6b9 19 (unreleased) landed
-
Avoid including utils/timestamp.h in conflict.h.
- 308622edf174 19 (unreleased) landed
-
Avoid including worker_internal.h in pgstat.h.
- 9842e8aca096 19 (unreleased) landed
-
Add seq_sync_error_count to subscription statistics.
- f6a4c498dcf6 19 (unreleased) cited
-
Don't include execnodes.h in replication/conflict.h
- 7e638d7f5093 19 (unreleased) cited
-
Collect statistics about conflicts in logical replication.
- 6c2b5edecc0d 18.0 cited