Re: Nested CASE-WHEN scoping

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Nested CASE-WHEN scoping
Дата
Msg-id 4DDCF44D.2020604@enterprisedb.com
обсуждение исходный текст
Ответ на Nested CASE-WHEN scoping  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Список pgsql-hackers
On 25.05.2011 14:57, Heikki Linnakangas wrote:
> Here's a bit contrived example:
>
> CREATE FUNCTION evileq (timestamptz, int4) returns boolean AS $$
> SELECT case $2 WHEN length($1::text) THEN true ELSE false END;
> $$ language sql;
> CREATE OPERATOR = (procedure = evileq, leftarg = timestamptz, rightarg =
> int4);
>
> postgres=# SELECT now() = 29, CASE now() WHEN 29 THEN 'foo' ELSE 'bar' END;
> ?column? | case
> ----------+------
> t | bar
> (1 row)
>
> Direct call to the operator, "now () = 29" returns true, but when used
> in CASE-WHEN, which implicitly does the same comparison, the result is
> false. Admittedly that's pretty far-fetched, but nevertheless it's a bug.

I should add that this works fine if the function is not an SQL function 
that gets inlined. But inlining is desirable, we don't want to give up 
on that, and inhibiting it in that case would need some extra 
bookkeeping anyway.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Nested CASE-WHEN scoping
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Proposal: Another attempt at vacuum improvements