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

2025-07-24 Thread Vik Fearing
On 24/07/2025 15:44, jian he wrote: just want to confirm my understanding of ``[ FORMAT ]``. SELECT CAST('2022-13-32' AS DATE FORMAT '-MM-DD' DEFAULT NULL ON CONVERSION ERROR); will return NULL. because ``SELECT to_date('2022-13-32', '-MM-DD');`` will error out, so the above query wi

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

2025-07-24 Thread Vik Fearing
On 24/07/2025 03:22, jian he wrote: +SELECT CAST('a' as int DEFAULT sum(1) ON CONVERSION ERROR); --error +SELECT CAST('a' as int DEFAULT sum(1) over() ON CONVERSION ERROR); --error This seems like an arbitrary restriction.  Can you explain why this is necessary?  Those same expressions are a

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

2025-07-24 Thread jian he
On Tue, Jul 22, 2025 at 8:26 PM Vik Fearing wrote: > > > On 22/07/2025 12:19, jian he wrote: > > On Tue, Jul 22, 2025 at 2:45 PM Vik Fearing > > wrote: > >> It was accepted into the standard after 2023 was released. I am the > >> author of this change in the standard, so feel free to ask me any

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

2025-07-23 Thread jian he
On Tue, Jul 22, 2025 at 8:26 PM Vik Fearing wrote: > > The actual syntax is: > > > ::= > CAST > AS > [ FORMAT ] > [ ON CONVERSION ERROR ] > > > > "CONVERSION" is probably a noise word, but it is there because A) Oracle > wanted it there, and B) it ma

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

2025-07-22 Thread Corey Huinker
On Tue, Jul 22, 2025 at 2:45 AM Vik Fearing wrote: > > On 22/07/2025 03:59, jian he wrote: > > Based on my reading of [4], it seems CAST(EXPRESSION AS TYPE DEFAULT > > def_expr ON ERROR) > > is not included in SQL:2023. > > > > [4] > https://peter.eisentraut.org/blog/2023/04/04/sql-2023-is-finish

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

2025-07-22 Thread Vik Fearing
On 22/07/2025 14:26, Vik Fearing wrote: The is: ::=     ERROR   | NULL   | DEFAULT but I am planning on removing the NULL variant in favor of having the be a .  So it would be either ERROR ON CONVERSION ERROR (postgres's current behavior), or DEFAULT NULL ON CONVERSION ERROR. Sorry

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

2025-07-22 Thread Vik Fearing
On 22/07/2025 12:19, jian he wrote: On Tue, Jul 22, 2025 at 2:45 PM Vik Fearing wrote: It was accepted into the standard after 2023 was released. I am the author of this change in the standard, so feel free to ask me anything you're unsure about. is the generally syntax as mentioned in thi

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

2025-07-22 Thread jian he
On Tue, Jul 22, 2025 at 2:45 PM Vik Fearing wrote: > > It was accepted into the standard after 2023 was released. I am the > author of this change in the standard, so feel free to ask me anything > you're unsure about. > is the generally syntax as mentioned in this thread: CAST(source_expression

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

2025-07-21 Thread Vik Fearing
On 22/07/2025 03:59, jian he wrote: Based on my reading of [4], it seems CAST(EXPRESSION AS TYPE DEFAULT def_expr ON ERROR) is not included in SQL:2023. [4]https://peter.eisentraut.org/blog/2023/04/04/sql-2023-is-finished-here-is-whats-new It was accepted into the standard after 2023 was re

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

2025-07-21 Thread jian he
hi. more preparation work has been committed. 1. SQL/JSON patch [1] added keyword ERROR 2. CoerceViaIo, CoerceToDomain can be evaluated error safe. see commit [2]. 3. ExprState added ErrorSaveContext point, so before calling ExecInitExprRec set valid ErrorSaveContext for ExprState->escontext we sh

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

2023-03-28 Thread Corey Huinker
On Tue, Mar 28, 2023 at 3:25 PM Isaac Morland wrote: > On Mon, 19 Dec 2022 at 17:57, Corey Huinker > wrote: > >> >> Attached is my work in progress to implement the changes to the CAST() >> function as proposed by Vik Fearing. >> >> CAST(expr AS typename NULL ON ERROR) >> will use error-safe

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

2023-03-28 Thread Corey Huinker
On Tue, Mar 28, 2023 at 2:53 PM Gregory Stark (as CFM) wrote: > On Tue, 3 Jan 2023 at 14:16, Tom Lane wrote: > > > > Vik Fearing writes: > > > > > I don't think we should add that syntax until I do get it through the > > > committee, just in case they change something. > > > > Agreed. So this

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

2023-03-28 Thread Isaac Morland
On Mon, 19 Dec 2022 at 17:57, Corey Huinker wrote: > > Attached is my work in progress to implement the changes to the CAST() > function as proposed by Vik Fearing. > > CAST(expr AS typename NULL ON ERROR) > will use error-safe functions to do the cast of expr, and will return > NULL if the c

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

2023-03-28 Thread Gregory Stark (as CFM)
On Tue, 3 Jan 2023 at 14:16, Tom Lane wrote: > > Vik Fearing writes: > > > I don't think we should add that syntax until I do get it through the > > committee, just in case they change something. > > Agreed. So this is something we won't be able to put into v16; > it'll have to wait till there's

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

2023-01-03 Thread Tom Lane
Vik Fearing writes: > I have not posted my paper to the committee yet, but I plan to do so > before the working group's meeting early February. Just like with > posting patches here, I cannot guarantee that it will get accepted but I > will be arguing for it. > I don't think we should add tha

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

2023-01-03 Thread Vik Fearing
On 1/3/23 19:14, Tom Lane wrote: Corey Huinker writes: On Mon, Jan 2, 2023 at 10:57 AM Tom Lane wrote: While I approve of trying to get some functionality in this area, I'm not sure that extending CAST is a great idea, because I'm afraid that the SQL committee will do something that conflicts

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

2023-01-03 Thread Tom Lane
Corey Huinker writes: > On Mon, Jan 2, 2023 at 10:57 AM Tom Lane wrote: >> While I approve of trying to get some functionality in this area, >> I'm not sure that extending CAST is a great idea, because I'm afraid >> that the SQL committee will do something that conflicts with it. > I'm going off

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

2023-01-03 Thread Corey Huinker
On Mon, Jan 2, 2023 at 10:57 AM Tom Lane wrote: > Corey Huinker writes: > > The proposed changes are as follows: > > CAST(expr AS typename) > > continues to behave as before. > > CAST(expr AS typename ERROR ON ERROR) > > has the identical behavior as the unadorned CAST() above. > > CAST(

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

2023-01-03 Thread Andrew Dunstan
On 2023-01-02 Mo 10:57, Tom Lane wrote: > Corey Huinker writes: >> The proposed changes are as follows: >> CAST(expr AS typename) >> continues to behave as before. >> CAST(expr AS typename ERROR ON ERROR) >> has the identical behavior as the unadorned CAST() above. >> CAST(expr AS typena

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

2023-01-03 Thread vignesh C
On Tue, 20 Dec 2022 at 04:27, Corey Huinker wrote: > > > Attached is my work in progress to implement the changes to the CAST() > function as proposed by Vik Fearing. > > This work builds upon the Error-safe User Functions work currently ongoing. > > The proposed changes are as follows: > > CAST(

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

2023-01-02 Thread Tom Lane
Corey Huinker writes: > The proposed changes are as follows: > CAST(expr AS typename) > continues to behave as before. > CAST(expr AS typename ERROR ON ERROR) > has the identical behavior as the unadorned CAST() above. > CAST(expr AS typename NULL ON ERROR) > will use error-safe functi

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

2022-12-19 Thread Corey Huinker
Attached is my work in progress to implement the changes to the CAST() function as proposed by Vik Fearing. This work builds upon the Error-safe User Functions work currently ongoing. The proposed changes are as follows: CAST(expr AS typename) continues to behave as before. CAST(expr AS typ