| From: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
|---|---|
| To: | jian he <jian(dot)universality(at)gmail(dot)com> |
| Cc: | Vik Fearing <vik(at)postgresfriends(dot)org>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: implement CAST(expr AS type FORMAT 'template') |
| Date: | 2026-03-24 06:30:57 |
| Message-ID: | CAN4CZFNnqWbyk3UNr3XAwtKJooH8LnbDUg-f2JD9z_rG=feT7w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello!
There's some inconsistency in deparse, it displays to_char for intervals:
CREATE VIEW test_interval_format AS
SELECT CAST('1 year 2 months'::interval AS text FORMAT 'YYYY-MM') AS
fmt_interval;
CREATE VIEW test_timestamp_format AS
SELECT CAST('2024-01-15 00:00:00'::timestamp AS text FORMAT
'YYYY-MM-DD') AS fmt_timestamp;
SELECT pg_get_viewdef('test_interval_format'::regclass);
SELECT pg_get_viewdef('test_timestamp_format'::regclass);
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');
2026-03-24 06:27:45.792 UTC [5917] ERROR: function
pg_catalog.to_char(time with time zone, text) does not exist
2026-03-24 06:27:45.792 UTC [5917] DETAIL: No function of that name
accepts the given argument types.
2026-03-24 06:27:45.792 UTC [5917] HINT: You might need to add
explicit type casts.
2026-03-24 06:27:45.792 UTC [5917] STATEMENT: 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pavel Stehule | 2026-03-24 06:31:11 | Re: bugfix - fix broken output in expanded aligned format, when data are too short |
| Previous Message | Fujii Masao | 2026-03-24 06:29:55 | Re: [PATCH] Fix unexpected loss of DEFERRABLE property after toggling NOT ENFORCED / ENFORCED |