Re: Proposal: is_castable
От | Tom Lane |
---|---|
Тема | Re: Proposal: is_castable |
Дата | |
Msg-id | 23154.1585923560@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Proposal: is_castable (Michał Wadas <michalwadas@gmail.com>) |
Ответы |
Re: Proposal: is_castable
|
Список | pgsql-hackers |
=?UTF-8?Q?Micha=C5=82_Wadas?= <michalwadas@gmail.com> writes: > Currently there is no way to check if CAST will succeed. > Therefore I propose adding new function: is_castable > SELECT is_castable('foo' as time) // false What would you actually do with it? > Similar features are implemented in: > - SQL Server (as TRY_CONVERT) > - Oracle (as CONVERT([val] DEFAULT [expr] ON CONVERSION ERROR) Somehow, I don't think those have the semantics of what you suggest here. I suspect you are imagining that you could write something like CASE WHEN is_castable(x as y) THEN cast(x as y) ELSE ... but that will not work. The THEN condition has to pass parse analysis whether or not execution will ever reach it. regards, tom lane
В списке pgsql-hackers по дате отправления: