Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions

Поиск
Список
Период
Сортировка
От Vik Fearing
Тема Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
Дата
Msg-id dd12489b-12af-40f1-ab9f-602f927f7bd2@postgresfriends.org
обсуждение исходный текст
Ответ на Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions  (jian he <jian.universality@gmail.com>)
Список 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





В списке pgsql-hackers по дате отправления: