Обсуждение: array handling on 8.0.3

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

array handling on 8.0.3

От
Daniel Drotos
Дата:
Hi,

I have to run a function on a 9.0.3 server. Following part 
(of a bigger function):

create or replace function t(p varchar) returns void as
$$
declare    v varchar; f varchar; a varchar[]; i integer;
begin    a:= '{}';    if p like '%/%' then        v:= trim_null(split_part(p, '/', 1));        f:= v; a:= a||v; i:= 2;
     while v != '' loop            v:= trim_null(split_part(p, '/', i));            raise INFO 'splitted=%',v;
 a:= a||v; i:= i+1;            raise INFO 'a=%',a;        end loop;        raise INFO 'a=% ready',a;    else        f:=
p;   end if;    return;
 
end;
$$
language 'plpgsql' volatile;

raises (if called as t('a/b')):

INFO:  splitted=b
INFO:  a={a,b}
INFO:  splitted=<NULL>
INFO:  a=<NULL>
INFO:  a=<NULL> ready

It looks that value of the array `a' is lost after the loop. Is this 
normal? What do I do wrong?

Daniel


Re: array handling on 8.0.3

От
Daniel Drotos
Дата:
On Tue, 9 Oct 2007, Daniel Drotos wrote:

> I have to run a function on a 9.0.3 server. Following part (of a bigger                                ^
          I mean 8.0.3 sorry
 

Daniel


Re: array handling on 8.0.3

От
Daniel Drotos
Дата:
Hi,

I found my bug, please forget my (stupid) question!

Daniel