From 47da1745244b25ba8b9396326d7f36e4ed1fb701 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=81lvaro=20Herrera?= Date: Thu, 25 Sep 2025 14:45:08 +0200 Subject: [PATCH] Don't include execnodes.h in replication/conflict.h ... which silently propagates a lot of headers into many places via pgstat.h, as evidenced by the variety of headers that this patch needs to add to seemingly random places. Add a minimum of typedefs to conflict.h to be able to remove execnodes.h, and fix the fallout. Backpatch to 18, where conflict.h first appeared. Discussion: https://postgr.es/m/202509191927.uj2ijwmho7nv@alvherre.pgsql --- src/backend/access/transam/multixact.c | 1 + src/backend/access/transam/xlogrecovery.c | 1 + src/backend/storage/ipc/waiteventset.c | 1 + src/backend/utils/activity/pgstat_backend.c | 1 + src/include/pgstat.h | 1 + src/include/replication/conflict.h | 24 ++++++++++++++------- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index 3c06ac45532..f94445bdd07 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -84,6 +84,7 @@ #include "pg_trace.h" #include "pgstat.h" #include "postmaster/autovacuum.h" +#include "storage/condition_variable.h" #include "storage/pmsignal.h" #include "storage/proc.h" #include "storage/procarray.h" diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index 6ce979f2d8b..efbe77a5747 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -45,6 +45,7 @@ #include "commands/tablespace.h" #include "common/file_utils.h" #include "miscadmin.h" +#include "nodes/miscnodes.h" #include "pgstat.h" #include "postmaster/bgwriter.h" #include "postmaster/startup.h" diff --git a/src/backend/storage/ipc/waiteventset.c b/src/backend/storage/ipc/waiteventset.c index 7c0e66900f9..b0746521ae4 100644 --- a/src/backend/storage/ipc/waiteventset.c +++ b/src/backend/storage/ipc/waiteventset.c @@ -67,6 +67,7 @@ #include "libpq/pqsignal.h" #include "miscadmin.h" #include "pgstat.h" +#include "port/atomics.h" #include "portability/instr_time.h" #include "postmaster/postmaster.h" #include "storage/fd.h" diff --git a/src/backend/utils/activity/pgstat_backend.c b/src/backend/utils/activity/pgstat_backend.c index 07a1116671b..a864ae8e6a6 100644 --- a/src/backend/utils/activity/pgstat_backend.c +++ b/src/backend/utils/activity/pgstat_backend.c @@ -25,6 +25,7 @@ #include "postgres.h" #include "access/xlog.h" +#include "executor/instrument.h" #include "storage/bufmgr.h" #include "storage/proc.h" #include "storage/procarray.h" diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 378f2f2c2ba..3a302c2cab0 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -11,6 +11,7 @@ #ifndef PGSTAT_H #define PGSTAT_H +#include "access/transam.h" /* for FullTransactionId */ #include "datatype/timestamp.h" #include "portability/instr_time.h" #include "postmaster/pgarch.h" /* for MAX_XFN_CHARS */ diff --git a/src/include/replication/conflict.h b/src/include/replication/conflict.h index f6448ce4ada..4d4e817b0f2 100644 --- a/src/include/replication/conflict.h +++ b/src/include/replication/conflict.h @@ -9,9 +9,16 @@ #ifndef CONFLICT_H #define CONFLICT_H -#include "nodes/execnodes.h" +#include "access/xlogdefs.h" +#include "nodes/pg_list.h" #include "utils/timestamp.h" +/* Avoid including execnodes.h here */ +struct EState; +struct ResultRelInfo; +struct TupleTableSlot; + + /* * Conflict types that could occur while applying remote changes. * @@ -58,8 +65,8 @@ typedef enum */ typedef struct ConflictTupleInfo { - TupleTableSlot *slot; /* tuple slot holding the conflicting local - * tuple */ + struct TupleTableSlot *slot; /* tuple slot holding the conflicting + * local tuple */ Oid indexoid; /* OID of the index where the conflict * occurred */ TransactionId xmin; /* transaction ID of the modification causing @@ -69,14 +76,15 @@ typedef struct ConflictTupleInfo * conflicting local row occurred */ } ConflictTupleInfo; -extern bool GetTupleTransactionInfo(TupleTableSlot *localslot, +extern bool GetTupleTransactionInfo(struct TupleTableSlot *localslot, TransactionId *xmin, RepOriginId *localorigin, TimestampTz *localts); -extern void ReportApplyConflict(EState *estate, ResultRelInfo *relinfo, +extern void ReportApplyConflict(struct EState *estate, struct ResultRelInfo *relinfo, int elevel, ConflictType type, - TupleTableSlot *searchslot, - TupleTableSlot *remoteslot, + struct TupleTableSlot *searchslot, + struct TupleTableSlot *remoteslot, List *conflicttuples); -extern void InitConflictIndexes(ResultRelInfo *relInfo); +extern void InitConflictIndexes(struct ResultRelInfo *relInfo); + #endif -- 2.47.3