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 1pCNBv-00037i-Tn for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Jan 2023 15:57:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pCNBt-0001ql-A9 for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Jan 2023 15:57:33 +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 1pCNBt-0001qa-11 for pgsql-hackers@lists.postgresql.org; Mon, 02 Jan 2023 15:57:33 +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 1pCNBp-00088k-Je for pgsql-hackers@lists.postgresql.org; Mon, 02 Jan 2023 15:57:32 +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 302FvRB31432469; Mon, 2 Jan 2023 10:57:27 -0500 From: Tom Lane To: Corey Huinker cc: pgsql-hackers@lists.postgresql.org Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions In-reply-to: References: Comments: In-reply-to Corey Huinker message dated "Mon, 19 Dec 2022 17:56:37 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1432467.1672675047.1@sss.pgh.pa.us> Date: Mon, 02 Jan 2023 10:57:27 -0500 Message-ID: <1432468.1672675047@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Corey Huinker writes: > The proposed changes are as follows: > CAST(expr AS typename) > continues to behave as before. > CAST(expr AS typename ERROR ON ERROR) > has the identical behavior as the unadorned CAST() above. > CAST(expr AS typename NULL ON ERROR) > will use error-safe functions to do the cast of expr, and will return > NULL if the cast fails. > CAST(expr AS typename DEFAULT expr2 ON ERROR) > will use error-safe functions to do the cast of expr, and will return > expr2 if the cast fails. While I approve of trying to get some functionality in this area, I'm not sure that extending CAST is a great idea, because I'm afraid that the SQL committee will do something that conflicts with it. If we know that they are about to standardize exactly this syntax, where is that information available? If we don't know that, I'd prefer to invent some kind of function or other instead of extending the grammar. regards, tom lane