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 1p40iZ-0003ZV-62 for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Dec 2022 14:20:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p40iW-0008Rg-Ho for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Dec 2022 14:20:40 +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 1p40iW-0008RW-8Y for pgsql-hackers@lists.postgresql.org; Sat, 10 Dec 2022 14:20:40 +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 1p40iT-0003BL-EH for pgsql-hackers@lists.postgresql.org; Sat, 10 Dec 2022 14:20:39 +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 2BAEKRBR1260232; Sat, 10 Dec 2022 09:20:28 -0500 From: Tom Lane To: Alvaro Herrera cc: Andrew Dunstan , Andres Freund , Alexander Korotkov , Robert Haas , "David G. Johnston" , Corey Huinker , Joe Conway , Nikita Glukhov , PostgreSQL Hackers Subject: Re: Error-safe user functions In-reply-to: <20221210122013.swbpo63go6ty2fcn@alvherre.pgsql> References: <20221210122013.swbpo63go6ty2fcn@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Sat, 10 Dec 2022 13:20:13 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1260230.1670682027.1@sss.pgh.pa.us> Date: Sat, 10 Dec 2022 09:20:27 -0500 Message-ID: <1260231.1670682027@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera writes: > On 2022-Dec-09, Tom Lane wrote: >> ... So I think it might be >> okay to say "if you want soft error treatment for a domain, >> make sure its check constraints don't throw errors". > I think that's fine. If the user does, say "CHECK (value > 0)" and that > results in a soft error, that seems to me enough support for now. If > they want to do something more elaborate, they can write C functions. > Maybe eventually we'll want to offer some other mechanism that doesn't > require C, but let's figure out what the requirements are. I don't > think we know that, at this point. A fallback we can offer to anyone with such a problem is "write a plpgsql function and wrap the potentially-failing bit in an exception block". Then they get to pay the cost of the subtransaction, while we're not imposing one on everybody else. regards, tom lane