Обсуждение: testing nested case-when scoping

Поиск
Список
Период
Сортировка

testing nested case-when scoping

От
Pavel Stehule
Дата:
Hello Heikki,

probably I found a bug in patch:

CREATE FUNCTION fx(i integer) RETURNS integer   LANGUAGE plpgsql   AS $$begin raise notice '>>%<<', i; return i;
end;$$;

CREATE FUNCTION fx1(integer) RETURNS text   LANGUAGE sql   AS $_$ select case $1 when 1 then 'A' else 'B' end$_$;

CREATE FUNCTION fx2(text) RETURNS text   LANGUAGE sql   AS $_$ select case $1 when 'A' then 'a' else 'b' end$_$;

CREATE TABLE foo (   a integer
);

COPY foo (a) FROM stdin;
1
0
\.

postgres=# select fx2(fx1(fx(a))) from foo;
NOTICE:  >>1<<
ERROR:  invalid expression parameter reference (1 levels up, while
stack is only 1 elements deep)

Regards

Pavel


Re: testing nested case-when scoping

От
Robert Haas
Дата:
On Wed, Jun 15, 2011 at 7:43 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> Hello Heikki,
>
> probably I found a bug in patch:
>
> CREATE FUNCTION fx(i integer) RETURNS integer
>    LANGUAGE plpgsql
>    AS $$begin raise notice '>>%<<', i; return i; end;$$;
>
> CREATE FUNCTION fx1(integer) RETURNS text
>    LANGUAGE sql
>    AS $_$ select case $1 when 1 then 'A' else 'B' end$_$;
>
> CREATE FUNCTION fx2(text) RETURNS text
>    LANGUAGE sql
>    AS $_$ select case $1 when 'A' then 'a' else 'b' end$_$;
>
> CREATE TABLE foo (
>    a integer
> );
>
> COPY foo (a) FROM stdin;
> 1
> 0
> \.
>
> postgres=# select fx2(fx1(fx(a))) from foo;
> NOTICE:  >>1<<
> ERROR:  invalid expression parameter reference (1 levels up, while
> stack is only 1 elements deep)

I can't reproduce this.  Perhaps it was fixed by one of the later commits?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: testing nested case-when scoping

От
Pavel Stehule
Дата:
2011/7/5 Robert Haas <robertmhaas@gmail.com>:
> On Wed, Jun 15, 2011 at 7:43 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>> Hello Heikki,
>>
>> probably I found a bug in patch:
>>
>> CREATE FUNCTION fx(i integer) RETURNS integer
>>    LANGUAGE plpgsql
>>    AS $$begin raise notice '>>%<<', i; return i; end;$$;
>>
>> CREATE FUNCTION fx1(integer) RETURNS text
>>    LANGUAGE sql
>>    AS $_$ select case $1 when 1 then 'A' else 'B' end$_$;
>>
>> CREATE FUNCTION fx2(text) RETURNS text
>>    LANGUAGE sql
>>    AS $_$ select case $1 when 'A' then 'a' else 'b' end$_$;
>>
>> CREATE TABLE foo (
>>    a integer
>> );
>>
>> COPY foo (a) FROM stdin;
>> 1
>> 0
>> \.
>>
>> postgres=# select fx2(fx1(fx(a))) from foo;
>> NOTICE:  >>1<<
>> ERROR:  invalid expression parameter reference (1 levels up, while
>> stack is only 1 elements deep)
>
> I can't reproduce this.  Perhaps it was fixed by one of the later commits?
>

I don't checked it again, because Tom rejected Heikki's design.

Regards

Pavel

> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>