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.96) (envelope-from ) id 1w14p7-002XOe-0d for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2026 15:53:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w14p4-004tgx-2F for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2026 15:53:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w14p3-004tgn-1r for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2026 15:53:10 +0000 Received: from fout-b7-smtp.messagingengine.com ([202.12.124.150]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w14oy-00000001yQr-07Pe for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2026 15:53:09 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id A34E21D00049; Fri, 13 Mar 2026 11:53:02 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Fri, 13 Mar 2026 11:53:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.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 :references:reply-to:subject:subject:to:to; s=fm1; t=1773417182; x=1773503582; bh=pS6cc9b6by8bHPf1nSo+op/TDk/gST/qhN8weAcFPeQ=; b= dRJDox4Mqm6nSUKBWb2/g0VXjwWs+VXKT45uRtDlprWoo4JMMkmnTg5by30nNrrN wrBi8w+mm0wg63vzGfzYxrrgVEFOCiLdTrle9nJ5gxGfO7MhlGgoKUVyzsIdZgTx +tSNkVpfnVldy6ACR1MX00Knxt6MA2i0uYYI5sUxO7Jh/2+C4xZoqcKOdlujUd+1 U+VjpZTwtukzzLVISfSdMdCrTWerqg59WAfzHGV1e60A7os5zEOBiD1KOR1ZI7gF s0wII+OaZ9U8WdmFM+YWq88FFNf6GI8w1YRjtEMWb8bkvg+7u6Ug/oXsK5O15Qrt 5NrBT5QK6emMXPX9qysFQg== 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 :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1773417182; x= 1773503582; bh=pS6cc9b6by8bHPf1nSo+op/TDk/gST/qhN8weAcFPeQ=; b=t YdrF/t8kPEBxlfMalL6crDEcktCFZe1hjrr3QF7f9Tp5jlasvKZRCZT+hhV+GNqU 5mdzNrJZdWN18M5IdLA9Khzl3ptNTquWtX9uAInGp6uGCImkxzwUEd4TB7jtePOi ZqGmm43Ww+465TAg8AszZNyFaBj3DvJNOPHCRLVFUdmrEbckNtdCMO85d6Vwfy+x rbaeEidxYS3JWWA90QbRpyK4JLXcowk/W1T7JV/KCTBB+4cTpURBuF5CBWZJiHXd +BnMNtEDAPmLvCxg7UGwl4j5chackty/sMnkh+caUXj/yc7fFBEFh2VWx38UgQKq SOXaE01KFRViZbEWY4HpA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvledttdejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggugfgjsehmkefsredttddunecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpeegjeffgeeuueeiuddvgeevheetvdeuvdfhudejiedtudevvdejvefgvdek jedvtdenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgr iigvlhdruggvpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtph htthhopegrlhhvhhgvrhhrvgeskhhurhhilhgvmhhurdguvgdprhgtphhtthhopehpghhs qhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 13 Mar 2026 11:53:01 -0400 (EDT) Date: Fri, 13 Mar 2026 11:53:00 -0400 From: Andres Freund To: =?utf-8?Q?=C3=81lvaro?= Herrera Cc: Pg Hackers Subject: Re: some more include removal from headers Message-ID: References: <202603131240.ihwqdxnj7w2o@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="oaf4egjku6f6i2la" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202603131240.ihwqdxnj7w2o@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --oaf4egjku6f6i2la Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi, On 2026-03-13 14:05:24 +0100, Álvaro Herrera wrote: > execnodes.h is a very large source of other headers for no very good > reasons anymore. Fortunately there's a few of the files it includes > that we can remove very easily with just a small number of additional > typedefs. Some proposed patches attached; it's all very > straightforward, just add typedefs for structs > Tuplesortstate > Tuplestorestate > TupleConversionMap > TupleTableSlot > TupleTableSlotOps > TIDBitmap > This also requires to add some headers to a bunch of .c files, which is > a good indicator that we're making progress. > > It's especially nice when the new #include line we have to add in some > .c file is not the one that was removed from the .h file -- for instance > in 0001 we have to add pg_type_d.h when removing tuplestore.h/ > tuplesort.h, and if you look at the chart here > https://doxygen.postgresql.org/tuplesort_8h.html it becomes very clear > we're saving quite a lot of useless indirect inclusions. (This is also > seen in 0004: we remove tuptable.h and have to add sysattr.h to three .c > files). Nice. > From 47d5e30b00ce8c0c37c8b905223f1b70a5020bfa Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?=C3=81lvaro=20Herrera?= > Date: Thu, 5 Mar 2026 18:00:54 +0100 > Subject: [PATCH 1/6] remove tuplestore.h and tuplesort.h from execnodes.h > diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c > index 31e19fbc697..ada782f98f5 100644 > --- a/contrib/amcheck/verify_heapam.c > +++ b/contrib/amcheck/verify_heapam.c > @@ -29,6 +29,7 @@ > #include "utils/builtins.h" > #include "utils/fmgroids.h" > #include "utils/rel.h" > +#include "utils/tuplestore.h" > > PG_FUNCTION_INFO_V1(verify_heapam); > Kinda wonder if funcapi.h should export tuplestore.h. That'd avoid needing adding the dedicated tuplestore.h in so many places, and as the use of tuplestore is basically required for funcapi.h users, it seems like it'd be fine semantically? But it also doesn't really matter. If we could go back in time I'd wrap the tuplestore_puttuple() for the SRF use case into an SRF specific wrapper, but my time travel capabilities have not developed, despite no lack of trying. > Subject: [PATCH 2/6] remove tupconvert.h from execnodes.h > diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h > index b259c4141ed..e475e278aa8 100644 > --- a/src/include/catalog/index.h > +++ b/src/include/catalog/index.h > @@ -14,6 +14,7 @@ > #ifndef INDEX_H > #define INDEX_H > > +#include "access/attmap.h" > #include "catalog/objectaddress.h" > #include "nodes/execnodes.h" A bit sad to include attmap.h here. Looks like it'd not be hard to instead forward declare AttrMap instead? I've attached a version of your patches that does so in a followup commit. > diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h > index 41ac0259b32..8c03498180f 100644 > --- a/src/include/nodes/execnodes.h > +++ b/src/include/nodes/execnodes.h > @@ -30,9 +30,9 @@ > #define EXECNODES_H > > #include "access/skey.h" > -#include "access/tupconvert.h" > #include "executor/instrument.h" > #include "executor/instrument_node.h" > +#include "executor/tuptable.h" > #include "fmgr.h" > #include "lib/ilist.h" > #include "lib/pairingheap.h" > @@ -58,6 +58,7 @@ typedef struct ExprState ExprState; > typedef struct ExprContext ExprContext; > typedef struct Tuplesortstate Tuplesortstate; > typedef struct Tuplestorestate Tuplestorestate; > +typedef struct TupleConversionMap TupleConversionMap; I was about to complain about growing that tuptable.h include, but I see that's transient... LGTM. > Subject: [PATCH 3/6] don't include sharedtuplestore.h in execnodes.h LGTM, certainly the missing fd.h includes seem like structurally better. > Subject: [PATCH 4/6] don't include tuptable.h in execnodes.h LGTM. Smaller after the patch to not include attmap.h that I added above, as that also triggered needing to add those sysattr.h includes. > Subject: [PATCH 5/6] don't include tidbitmap.h in execnodes.h > diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h > index 82bd5dcb683..652cc316067 100644 > --- a/src/include/nodes/execnodes.h > +++ b/src/include/nodes/execnodes.h > @@ -39,10 +39,10 @@ > #include "nodes/miscnodes.h" > #include "nodes/params.h" > #include "nodes/plannodes.h" > -#include "nodes/tidbitmap.h" > #include "partitioning/partdefs.h" > #include "storage/buf.h" > #include "storage/condition_variable.h" > +#include "utils/dsa.h" > #include "utils/hsearch.h" > #include "utils/queryenvironment.h" > #include "utils/reltrigger.h" > @@ -56,6 +56,7 @@ typedef struct PlanState PlanState; > typedef struct ExecRowMark ExecRowMark; > typedef struct ExprState ExprState; > typedef struct ExprContext ExprContext; > +typedef struct TIDBitmap TIDBitmap; > typedef struct Tuplesortstate Tuplesortstate; > typedef struct Tuplestorestate Tuplestorestate; > typedef struct TupleConversionMap TupleConversionMap; > -- > 2.47.3 Sad to add dsa.h this widely. But I don't immediately see a better way, at least not as part of this commit. LGTM. The need for dsa.h and condition_variable.h just is from ParallelBitmapHeapState - which isn't actually an executor node and never needed outside of nodeBitmapHeapscan.c - so it seems better to move it there? Added a commit for that. Your patch numbering says 5/6, but there's only 5 attached, I assume that was intentional? I couldn't help myself to slim down execnodes.h further. Not sure if all of them are quite worth it. With all the commits combined very little low-level stuff is still included. The worst is probably instr_time.h. Greetings, Andres Freund --oaf4egjku6f6i2la Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-remove-tuplestore.h-and-tuplesort.h-from-execnode.patch"