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 1p0pQs-0002NS-6j for pgsql-hackers@arkaria.postgresql.org; Thu, 01 Dec 2022 19:41:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p0pQr-0007ji-1F for pgsql-hackers@arkaria.postgresql.org; Thu, 01 Dec 2022 19:41:17 +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 1p0pQq-0007jJ-Nr for pgsql-hackers@lists.postgresql.org; Thu, 01 Dec 2022 19:41:16 +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 1p0pQo-0007dy-DL for pgsql-hackers@lists.postgresql.org; Thu, 01 Dec 2022 19:41:16 +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 2B1JfB4C1695761; Thu, 1 Dec 2022 14:41:11 -0500 From: Tom Lane To: Robert Haas cc: Andrew Dunstan , Corey Huinker , Nikita Glukhov , PostgreSQL Hackers Subject: Re: Error-safe user functions In-reply-to: References: <3bbbb0df-7382-bf87-9737-340ba096e034@postgrespro.ru> <3190059.1665164276@sss.pgh.pa.us> <57b7cc2e-1215-3f43-84e4-6d9f8ad575df@dunslane.net> <3049337.1669008405@sss.pgh.pa.us> <469338a3-da38-160f-23b9-813c261bc1d6@dunslane.net> <1677334.1669918475@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Thu, 01 Dec 2022 14:04:00 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1695759.1669923671.1@sss.pgh.pa.us> Date: Thu, 01 Dec 2022 14:41:11 -0500 Message-ID: <1695760.1669923671@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > It sounds like you're imagining that ereturn doesn't return, which > seems confusing. But I don't know that I'd like it better if it did. The spec I had in mind was that it would behave as ereport(ERROR) unless a suitable FuncErrorContext node is passed, in which case it'd store the error data into that node and return. This leaves the invoker with only the job of passing control back afterwards, if it gets control back. I'd be the first to agree that "ereturn" doesn't capture that detail very well, but I don't have a better name. (And I do like the fact that this name is the same length as "ereport", so that we won't end up with lots of reindentation to do.) > Magic return statements hidden inside macros seem not too fun. What > I'd like to see is a macro that takes a pointer to an ErrorData and > the rest of the arguments like ereport() and stuffs everything in > there. And then you can pass that to ThrowErrorData() later if you > like. That way it's visible when you're using the macro where you're > putting the error. I think that would make the code more readable. I think that'd just complicate the places that are having to report such errors --- of which there are likely to be hundreds by the time we are done. I will not accept a solution that requires more than the absolute minimum of additions to the error-reporting spots. regards, tom lane