From: | Vik Fearing <vik(at)postgresfriends(dot)org> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions |
Date: | 2025-07-24 14:19:34 |
Message-ID: | dd12489b-12af-40f1-ab9f-602f927f7bd2@postgresfriends.org |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 24/07/2025 15:44, jian he wrote:
> just want to confirm my understanding of ``[ FORMAT <cast template> ]``.
>
> SELECT CAST('2022-13-32' AS DATE FORMAT 'YYYY-MM-DD' DEFAULT NULL ON
> CONVERSION ERROR);
> will return NULL.
> because ``SELECT to_date('2022-13-32', 'YYYY-MM-DD');``
> will error out, so the above query will fall back to the DEFAULT
> expression evaluation.
That is correct. Any error produced during typecasting will fall back
to the DEFAULT value. If not supplied, the behavior is ERROR ON ERROR
as it currently is.
Any error produced while converting the DEFAULT value to the requested
type is raised as an error.
--
Vik Fearing
From | Date | Subject | |
---|---|---|---|
Next Message | Mircea Cadariu | 2025-07-24 14:30:06 | Re: Add os_page_num to pg_buffercache |
Previous Message | Vik Fearing | 2025-07-24 14:10:16 | Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions |