Re: implement CAST(expr AS type FORMAT 'template') - Mailing list pgsql-hackers

From jian he
Subject Re: implement CAST(expr AS type FORMAT 'template')
Date
Msg-id CACJufxFVMYuVz63DteEjbMdvx2neoYcwSRb5vhO-03Tzx=B8Jw@mail.gmail.com
Whole thread
In response to Re: implement CAST(expr AS type FORMAT 'template')  (Zsolt Parragi <zsolt.parragi@percona.com>)
Responses Re: implement CAST(expr AS type FORMAT 'template')
List pgsql-hackers
On Tue, Mar 24, 2026 at 2:31 PM Zsolt Parragi <zsolt.parragi@percona.com> wrote:
> Hello!
>
> There's some inconsistency in deparse, it displays to_char for intervals:
>
> I also see a similar to_char leak in the error message - wouldn't this
> confuse users, as they never wrote to_char?
>
> postgres=# SELECT cast('2012-12-12 12:00'::timetz as text format
> 'YYYY-MM-DD HH:MI:SS TZ');
> ERROR:  function pg_catalog.to_char(time with time zone, text) does not exist
> DETAIL:  No function of that name accepts the given argument types.
> HINT:  You might need to add explicit type casts.

The nearby v6 fixed these two issues, but,
src1=# SELECT cast('2012-12-12 12:00'::timetz as text format
'YYYY-MM-DD HH:MI:SS TZ');
ERROR:  cannot cast type time with time zone to text using formatted template
LINE 1: SELECT cast('2012-12-12 12:00'::timetz as text format
               ^
DETAIL:  Only categories of numeric, string, datetime, and timespan
source data types are supported for formatted type casting

The errdeatil above is not good and needs further improvement, since
timetz is a datetime category data type.



pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: Re: implement CAST(expr AS type FORMAT 'template')
Next
From: "Zhijie Hou (Fujitsu)"
Date:
Subject: RE: Bug: wrong relname in RemoveSubscriptionRel() error detail