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 1p34Db-00065V-I6 for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Dec 2022 23:52:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p34Da-0006xN-C6 for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Dec 2022 23:52:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p34Da-0006xE-2x for pgsql-hackers@lists.postgresql.org; Wed, 07 Dec 2022 23:52:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p34DX-0002hK-QK for pgsql-hackers@lists.postgresql.org; Wed, 07 Dec 2022 23:52:49 +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 2B7NqfV8011185; Wed, 7 Dec 2022 18:52:41 -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: <11183.1670457161.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 07 Dec 2022 18:52:41 -0500 Message-ID: <11184.1670457161@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > I wonder if there are potential use-cases for levels other than ERROR. I= can > potentially see us wanting to defer some FATALs, e.g. when they occur in > process exit hooks. I thought about that early on, and concluded not. The whole thing is moot for levels less than ERROR, of course, and I'm having a hard time seeing how it could be useful for FATAL or PANIC. Maybe I just lack imagination, but if a call is specifying FATAL rather than just ERROR then it seems to me it's already a special snowflake rather than something we could fold into a generic non-error behavior. > For a moment I was worried that it could lead to odd behaviour that we d= on't > do get_error_stack_entry() when !details_wanted, due to not raising an e= rror > we'd otherwise raise. But that's a should-never-be-reached case, so ... I don't see how. Returning false out of errsave_start causes the errsave macro to immediately give control back to the caller, which will go on about its business. > It seems somewhat ugly transport this knowledge via edata->elevel, but i= t's > not too bad. The LOG-vs-ERROR business, you mean? Yeah. I considered adding another bool flag to ErrorData, but couldn't convince myself it was worth the trouble. If we find a problem we can do that sometime in future. >> +/* >> + * We cannot include nodes.h yet, so make a stub reference. (This is = also >> + * used by fmgr.h, which doesn't want to depend on nodes.h either.) >> + */ >> +typedef struct Node *NodePtr; > Seems like it'd be easier to just forward declare the struct, and use th= e > non-typedef'ed name in the header than to have to deal with these > interdependencies and the differing typenames. Meh. I'm a little allergic to writing "struct foo *" in function argument lists, because I so often see gcc pointing out that if struct foo isn't yet known then that can silently mean something different than you intended. With the typedef, it either works or is an error, no halfway about it. And the struct way isn't really much better in terms of having two different notations to use rather than only one. > Perhaps worth noting here that the reason why the errsave_start/errsave_= finish > split exist differs a bit from the reason in ereport_domain()? "Over the= re" > it's just about not wanting to incur overhead when the message isn't log= ged, > but here we'll always have >=3D ERROR, but ->details_wanted can still le= ad to > not wanting to incur the overhead. Hmmm ... it seems like the same reason to me, we don't want to incur the overhead if the "start" function says not to. > Is it ok that we throw an error in lookup_rowtype_tupdesc()? Yeah, that should fall in the category of internal errors I think. I don't see how you'd reach that from a bad input string. (Or to be more precise, the point of pg_input_is_valid is to tell you whether the input string is valid, not to tell you whether the type name is valid; if you're worried about the latter you need a separate and earlier test.) regards, tom lane