Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uzhG7-006FC0-Lo for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Sep 2025 19:59:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uzhG4-00945k-MB for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Sep 2025 19:59:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uzhG3-00945c-S0 for pgsql-hackers@lists.postgresql.org; Fri, 19 Sep 2025 19:59:04 +0000 Received: from fout-b5-smtp.messagingengine.com ([202.12.124.148]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uzhFy-001kyA-39 for pgsql-hackers@postgresql.org; Fri, 19 Sep 2025 19:59:03 +0000 Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfout.stl.internal (Postfix) with ESMTP id 53C6D1D00152; Fri, 19 Sep 2025 15:58:57 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Fri, 19 Sep 2025 15:58:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm3; t=1758311937; x= 1758398337; bh=HIHe+ZIA8NtjDvtBUjM0OKGwMG2kBDcDVboIBmeEgzk=; b=G W2rGRgtN+npNcsHEw1Xdj+O8zIzRvUxLDSasJpgyIDxOvT39JFtUFJxsnutrGfdc cJJ8p9cTPrGx4XEKfxvPCH7HZJzKtWy6zS5gL3Jgt8g1K8Y2m3yn2nxX+wCD9X4g q/h4Ht5dDVWrfvw4FjsjcxPVDmsKBGsX3+bV//ZEon3CYACDHf2n8JmBI2raz2QX azqr9vIF5LAdqzZnGtieMNzJHcg72W/28HnATURorHcKQ3a1ufDj9TYkgi4S2tQg ISXE6P2oFCM2ezWxJAuZ25mY2rxjWHfCcExhkxQU+cU7KJahU6Ux2ccrUcq1HZaV lifIPdGtRvOPQTcUBm2QA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1758311937; x=1758398337; bh=H IHe+ZIA8NtjDvtBUjM0OKGwMG2kBDcDVboIBmeEgzk=; b=J03cDD95lf8yLIC// DyuUfWkQVcRTAkx7pF8N5Ei+QgMJswNg3hrsCo3rkSyAAa1sN2WkFTxQrtsKtsv8 tfkCVoKgDDPgK9zFNNGHFV/n1mj51+GD0q/NRWkQ+xLEL3gO0v0WnhtMiG2seUNx VG7vD509x6A0JZtGPfyuz5qPSfn2HRbbqFjAvNtbO9c+031ZDb4TeKEbqep8bV60 NwQIrjWxsEGp/G77ejKGOpla7Fuss5L5LVuJak5oMHE+ZHqgL2a7u5z+YQZqs3z8 kS2GJYrXfimaBXoGy86AS535QDiHOp/fEyX4hA6vBfse9yGu9awg7e9CzHygSdwY HYIKg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdehtdduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfggtggugfgjsehmkeerredttdejnecuhfhrohhmpemllhhvrghrohcu jfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgeskhhurhhilhgvmhhurdguvgeqnecuggftrf grthhtvghrnhepgedutedujeehudevveegheejgeelveevvedvuedtjedtkeeuhfehheeg vedtjeetnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvges khhurhhilhgvmhhurdguvgdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouh htpdhrtghpthhtohepphgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhgpdhrtghpthht ohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 19 Sep 2025 15:58:56 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1758311934; bh=R4jXPAeMO4Eve/CEMqPnff5+DtpiJ00owWlCl594uIk=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=MqkOYXbNeCycTcxyXzgopeOuO6jvtPCNDhjlZafrzMGCzi32nFEWW2ga0jEKgVUJf BCZtFk/0GVu+Argqrwihjij0Pqlb2MZZaA0UkdROUvYCfX/SiDIvgszdEPDytWRmDz nRFeqonwVIuOqeTOhmfNYJEakKoDpWI3OjQ04Fc+YvKJA2ghCBdrPS+j0eU8A2B4A5 pIhl9uQ57bO6twEunA6RRYTd8AhykrPkWiM5ClQHLgZHBEKza8+EnqM5aXxvSf1hTv HHH3F1xidmE/tZPExdhqIf6Zq1UZefKC3R838qwAdvmajL+oSHlZyhTf+6LmZkIX1t uJIp48otjdi9w== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id 052C258; Fri, 19 Sep 2025 21:58:53 +0200 (CEST) Date: Fri, 19 Sep 2025 21:58:53 +0200 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Peter Eisentraut Cc: pgsql-hackers Subject: Re: allow benign typedef redefinitions (C11) Message-ID: <202509191927.uj2ijwmho7nv@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="az6rtwqlicg2ysru" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202509191025.22agk3fvpilc@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --az6rtwqlicg2ysru Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit I happened to realize that brin_tuple.h (a somewhat nasty header which was only supposed to be used by BRIN itself and stuff like amcheck) recently somehow snuck into tuplesort.h with some nefarious consequences: that one has polluted execnodes.h, which means that header now depends on struct definitions that appear in genam.h. We should fix this. This patch is not the full solution, just a way to show the problem; for a definitive solution, IMO the definitions of structs IndexScanInstrumentation and SharedIndexScanInstrumentation should be elsewhere so that execnodes.h doesn't have to include genam.h. (gin_tuple.h is also there, but that one's much less of a problem.) Oh, and replication/conflict.h including all of execnodes.h is kind of ridiculous. Looks like that's easily solved with something like this though: diff --git a/src/include/pgstat.h b/src/include/pgstat.h index f402b17295c..7bcb4c68e18 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" #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 e516caa5c73..e71b3c8f3d3 100644 --- a/src/include/replication/conflict.h +++ b/src/include/replication/conflict.h @@ -9,9 +9,14 @@ #ifndef CONFLICT_H #define CONFLICT_H -#include "nodes/execnodes.h" +#include "access/xlogdefs.h" +#include "nodes/pg_list.h" #include "utils/timestamp.h" +typedef struct EState EState; +typedef struct ResultRelInfo ResultRelInfo; +typedef struct TupleTableSlot TupleTableSlot; + /* * Conflict types that could occur while applying remote changes. * -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "La espina, desde que nace, ya pincha" (Proverbio africano) --az6rtwqlicg2ysru Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="nobrintuple.patch" diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c index e9d4b27427e..43c007b6204 100644 --- a/src/backend/access/gin/gininsert.c +++ b/src/backend/access/gin/gininsert.c @@ -29,10 +29,11 @@ #include "storage/bufmgr.h" #include "storage/predicate.h" #include "tcop/tcopprot.h" +#include "utils/builtins.h" #include "utils/datum.h" #include "utils/memutils.h" #include "utils/rel.h" -#include "utils/builtins.h" +#include "utils/typcache.h" /* Magic numbers for parallel state sharing */ diff --git a/src/backend/executor/execReplication.c b/src/backend/executor/execReplication.c index b409d4ecbf5..ab585aa9819 100644 --- a/src/backend/executor/execReplication.c +++ b/src/backend/executor/execReplication.c @@ -14,6 +14,7 @@ #include "postgres.h" +#include "access/amapi.h" #include "access/commit_ts.h" #include "access/genam.h" #include "access/gist.h" diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index e1979a80c19..eebea694dda 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -37,6 +37,7 @@ #include "utils/fmgroids.h" #include "utils/lsyscache.h" #include "utils/timestamp.h" +#include "utils/typcache.h" #include "utils/xml.h" /* GUC parameters */ diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c index f59046ad620..85f55b75c66 100644 --- a/src/backend/replication/logical/relation.c +++ b/src/backend/replication/logical/relation.c @@ -29,6 +29,7 @@ #include "utils/inval.h" #include "utils/lsyscache.h" #include "utils/syscache.h" +#include "utils/typcache.h" static MemoryContext LogicalRepRelMapContext = NULL; diff --git a/src/backend/statistics/attribute_stats.c b/src/backend/statistics/attribute_stats.c index 1db6a7f784c..4e8efcdf55b 100644 --- a/src/backend/statistics/attribute_stats.c +++ b/src/backend/statistics/attribute_stats.c @@ -29,6 +29,7 @@ #include "utils/fmgroids.h" #include "utils/lsyscache.h" #include "utils/syscache.h" +#include "utils/typcache.h" #define DEFAULT_NULL_FRAC Float4GetDatum(0.0) #define DEFAULT_AVG_WIDTH Int32GetDatum(0) /* unknown */ diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index daa6c44a9ac..b72084b7aaa 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -29,6 +29,7 @@ #ifndef EXECNODES_H #define EXECNODES_H +#include "access/genam.h" /* FIXME */ #include "access/tupconvert.h" #include "executor/instrument.h" #include "fmgr.h" @@ -59,6 +60,10 @@ struct ExprEvalStep; /* avoid including execExpr.h everywhere */ struct CopyMultiInsertBuffer; struct LogicalTapeSet; +typedef struct ScanKeyData ScanKeyData; +typedef struct SharedIndexScanInstrumentation SharedIndexScanInstrumentation; +typedef struct IndexScanInstrumentation IndexScanInstrumentation; + /* ---------------- * ExprState node diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h index ef79f259f93..38821b5cdbb 100644 --- a/src/include/utils/tuplesort.h +++ b/src/include/utils/tuplesort.h @@ -21,7 +21,6 @@ #ifndef TUPLESORT_H #define TUPLESORT_H -#include "access/brin_tuple.h" #include "access/gin_tuple.h" #include "access/itup.h" #include "executor/tuptable.h" @@ -38,6 +37,9 @@ typedef struct Tuplesortstate Tuplesortstate; typedef struct Sharedsort Sharedsort; +/* avoid including brin_tuple.h here */ +typedef struct BrinTuple BrinTuple; + /* * Tuplesort parallel coordination state, allocated by each participant in * local memory. Participant caller initializes everything. See usage notes --az6rtwqlicg2ysru--