From: Tom Lane <tgl@sss.pgh.pa.us>
To: alias <postgres.rocks@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: domain type with create cast not working on pg15, but work on pg14
Date: Mon, 25 Apr 2022 09:47:25 -0400
Message-ID: <38098.1650894445@sss.pgh.pa.us> (raw)
In-Reply-To: <CAJA4AWTdyc15kVwHpEFG7u9FMVuExEQdAi9Mf9tCK778sKwToQ@mail.gmail.com>
References: <CAJA4AWTdyc15kVwHpEFG7u9FMVuExEQdAi9Mf9tCK778sKwToQ@mail.gmail.com>
alias <postgres.rocks@gmail.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, postgres.rocks@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: domain type with create cast not working on pg15, but work on pg14
In-Reply-To: <38098.1650894445@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox