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 1p2y6E-0005Bj-Vc for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Dec 2022 17:20:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p2y6D-0002WZ-TB for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Dec 2022 17:20:49 +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 1p2y3B-00048A-8u for pgsql-hackers@lists.postgresql.org; Wed, 07 Dec 2022 17:17:41 +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 1p2y39-0007Xc-Ax for pgsql-hackers@lists.postgresql.org; Wed, 07 Dec 2022 17:17:40 +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 2B7HHY9Q4038713; Wed, 7 Dec 2022 12:17:34 -0500 From: Tom Lane To: Corey Huinker cc: Andrew Dunstan , Andres Freund , Alvaro Herrera , Joe Conway , Robert Haas , Nikita Glukhov , PostgreSQL Hackers Subject: Re: Error-safe user functions In-reply-to: References: <20221205174231.6wpmbuxafnfzlbuh@alvherre.pgsql> <85e40849-4458-bbb9-62ee-d9e7faf0c7dc@dunslane.net> <3323802.1670263204@sss.pgh.pa.us> <3496391.1670276406@sss.pgh.pa.us> <20221205234734.sab3fuxy6q2sokjd@alap3.anarazel.de> <3518534.1670285891@sss.pgh.pa.us> <20221206005607.lxcrazckoalptwds@alap3.anarazel.de> <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> Comments: In-reply-to Corey Huinker message dated "Wed, 07 Dec 2022 12:01:11 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4038711.1670433454.1@sss.pgh.pa.us> Date: Wed, 07 Dec 2022 12:17:34 -0500 Message-ID: <4038712.1670433454@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Corey Huinker writes: > In my attempt to implement CAST...DEFAULT, I noticed that I immediately > needed an > OidInputFunctionCallSafe, which was trivial but maybe something we want to > add to the infra patch, but the comments around that function also somewhat > indicate that we might want to just do the work in-place and call > InputFunctionCallSafe directly. Open to both ideas. I'm a bit skeptical of that. IMO using OidInputFunctionCall is only appropriate in places that will be executed just once per query. Otherwise, unless you have zero concern for performance, you should be caching the function lookup. (The test functions in my 0003 patch illustrate the standard way to do that within SQL-callable functions. If you're implementing CAST as a new kind of executable expression, the lookup would likely happen in expression compilation.) I don't say that OidInputFunctionCallSafe won't ever be useful, but I doubt it's what we want in CAST. regards, tom lane