| От | Tom Lane |
|---|---|
| Тема | Re: Needed function IF(expr, expr, expr) |
| Дата | |
| Msg-id | 1178.1062897207@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: Needed function IF(expr, expr, expr) (Greg Stark <gsstark@mit.edu>) |
| Список | pgsql-general |
Greg Stark <gsstark@mit.edu> writes:
> For 7.4 you'll be able to define it something like this:
> (I'm not sure why "anyelement" works but "any" doesn't work.)
Because "any" doesn't imply anything about relationships between
datatypes of arguments and results. You need "anyelement" to inform
the parser that the result type is the same as the second and third
argument types. "any" is just a wildcard.
> slo=> create or replace function iff(boolean,"anyelement","anyelement") returns "anyelement" language sql strict
immutableas 'select case when $1 then $2 else $3 end' ;
You don't want this to be STRICT: "if(true,33,null)" should yield 33 not
null, no?
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера