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.