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 1niz3r-0007XF-Hb for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Apr 2022 13:47:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1niz3q-0006wO-32 for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Apr 2022 13:47:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1niz3p-0006vY-Qz for pgsql-bugs@lists.postgresql.org; Mon, 25 Apr 2022 13:47:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1niz3n-0004sr-Ew for pgsql-bugs@lists.postgresql.org; Mon, 25 Apr 2022 13:47:28 +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 23PDlPo1038099; Mon, 25 Apr 2022 09:47:25 -0400 From: Tom Lane To: alias cc: pgsql-bugs@lists.postgresql.org Subject: Re: domain type with create cast not working on pg15, but work on pg14 In-reply-to: References: Comments: In-reply-to alias message dated "Mon, 25 Apr 2022 11:37:49 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <38097.1650894445.1@sss.pgh.pa.us> Date: Mon, 25 Apr 2022 09:47:25 -0400 Message-ID: <38098.1650894445@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk alias writes: > create domain isodow as integer check(value between 1 and 7); > create function testcast(in a timestamptz ,out isodow) > as $$ select extract(dow from a ) $$ language sql; > CREATE CAST (timestamptz AS isodow) WITH FUNCTION testcast(timestamptz) AS > ASSIGNMENT; For me, on either v14 or v15 that draws an informative warning: WARNING: cast will be ignored because the target data type is a domain and that makes it unsurprising that this fails: =# select '2022-04-23 19:00:01 +5:30'::timestamptz::isodow; ERROR: cannot cast type timestamp with time zone to isodow LINE 1: select '2022-04-23 19:00:01 +5:30'::timestamptz::isodow; ^ I don't see any difference in behavior between v13, v14, v15 on this. The test case fails outright before v13, because older versions wouldn't do the implied cast here: =# create function testcast(in a timestamptz ,out isodow) as $$ select extract(dow from a ) $$ language sql; ERROR: return type mismatch in function declared to return isodow DETAIL: Actual return type is double precision. CONTEXT: SQL function "testcast" but with that corrected, the warning appears at least back to v10. regards, tom lane