Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p3Joh-0003tR-Uy for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Dec 2022 16:32:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p3Jof-0002sO-40 for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Dec 2022 16:32:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p3Joe-0002sE-R9 for pgsql-hackers@lists.postgresql.org; Thu, 08 Dec 2022 16:32:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p3Joc-0007Fp-4y for pgsql-hackers@lists.postgresql.org; Thu, 08 Dec 2022 16:32:07 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 2B8GVxNF186289; Thu, 8 Dec 2022 11:31:59 -0500 From: Tom Lane To: Andres Freund cc: Andrew Dunstan , "David G. Johnston" , Corey Huinker , Alvaro Herrera , Joe Conway , Robert Haas , Nikita Glukhov , PostgreSQL Hackers Subject: Re: Error-safe user functions In-reply-to: <20221207233518.sudtaxn6omtvpzvr@awork3.anarazel.de> References: <3523582.1670288815@sss.pgh.pa.us> <40ff1ed1-4245-e343-bffa-c7755b031492@dunslane.net> <3889877.1670358069@sss.pgh.pa.us> <4009543.1670422833@sss.pgh.pa.us> <6acddf68-7cb7-e9e7-a5a7-0abc87b3c55b@dunslane.net> <4111458.1670444176@sss.pgh.pa.us> <3211.1670452341@sss.pgh.pa.us> <20221207233518.sudtaxn6omtvpzvr@awork3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Wed, 07 Dec 2022 15:35:18 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <186287.1670517119.1@sss.pgh.pa.us> Date: Thu, 08 Dec 2022 11:31:59 -0500 Message-ID: <186288.1670517119@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > On 2022-12-07 17:32:21 -0500, Tom Lane wrote: >> +typedef struct Node *NodePtr; > Seems like it'd be easier to just forward declare the struct, and use the > non-typedef'ed name in the header than to have to deal with these > interdependencies and the differing typenames. I've been having second thoughts about how to handle this issue. As we convert more and more datatypes, references to "Node *" are going to be needed in assorted headers that don't currently have any reason to #include nodes.h. Rather than bloating their include footprints, we'll want to use the alternate spelling, whichever it is. (I already had to do this in array.h.) Some of these headers might be things that are also read by frontend compiles, in which case they won't have access to elog.h either, so that NodePtr in this formulation won't work for them. (I ran into a variant of that with an early draft of this patch series.) If we stick with NodePtr we'll probably end by putting that typedef into c.h so that it's accessible in frontend as well as backend. I don't have a huge problem with that, but I concede it's a little ugly. If we go with "struct Node *" then we can solve such problems by just repeating "struct Node;" forward-declarations in as many headers as we have to. This is a bit ugly too, but maybe less so, and it's a method we use elsewhere. The main downside I can see to it is that we will probably not find out all the places where we need such declarations until we get field complaints that "header X doesn't compile for me". elog.h will have a struct Node declaration, and that will be visible in every backend compilation we do as well as every cpluspluscheck/headerscheck test. Another notational point I'm wondering about is whether we want to create hundreds of direct references to fcinfo->context. Is it time to invent #define PG_GET_CONTEXT() (fcinfo->context) and write that instead in all these input functions? Thoughts? regards, tom lane