Re: pgstat include expansion

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Alvaro Herrera <alvherre@kurilemu.de>, Heikki Linnakangas <hlinnaka@iki.fi>
Cc: pgsql-hackers@postgresql.org, Amit Kapila <amit.kapila16@gmail.com>, Michael Paquier <michael@paquier.xyz>
Date: 2026-02-26T15:14:37Z
Lists: pgsql-hackers
Hi,

Thanks for pushing the pgstat.h slimdown patch - I should have gotten to that
... but didn't.

On 2026-02-26 14:52:10 +0100, Alvaro Herrera wrote:
> This one removes wait_event.h from pgstat.h.  The only difference from
> the previous one, aside from the fact that I had to add pgstat.h to a
> few more .c files, is that xlogreader.c needs to include it inside the
> #ifndef FRONTEND; otherwise, "ninja -t missingdeps" complain about the
> file being used in pg_rewind and pg_waldump (seen in CI).

I'm somewhat worried about the amount of breakage this will cause in
extensions.  Many extensions use something like
   WaitLatch(wait_event_info = WAIT_EVENT_EXTENSION)
and many of them won't have included wait_event.h.

OTOH, Heikki's interrupt patch will already cause widespread breakage in just
such code, so maybe this is the time to do it.

Greetings,

Andres Freund



Commits

  1. Don't include wait_event.h in pgstat.h

  2. Don't include proc.h in shm_mq.h

  3. Don't include latch.h in libpq/libpq.h

  4. Reduce includes in pgstat.h

  5. Avoid including utils/timestamp.h in conflict.h.

  6. Avoid including worker_internal.h in pgstat.h.

  7. Add seq_sync_error_count to subscription statistics.

  8. Don't include execnodes.h in replication/conflict.h

  9. Collect statistics about conflicts in logical replication.