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

From Vik Fearing
Subject Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
Date
Msg-id dd12489b-12af-40f1-ab9f-602f927f7bd2@postgresfriends.org
Whole thread Raw
In response to Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions  (jian he <jian.universality@gmail.com>)
List 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 by date:

Previous
From: Vik Fearing
Date:
Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
Next
From: Mircea Cadariu
Date:
Subject: Re: Add os_page_num to pg_buffercache