array handling on 8.0.3 - Mailing list pgsql-sql

From Daniel Drotos
Subject array handling on 8.0.3
Date
Msg-id Pine.LNX.4.64.0710091506550.7196@mazsola.iit.uni-miskolc.hu
Whole thread Raw
Responses Re: array handling on 8.0.3
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Rodrigo De León
Date:
Subject: Re: UNIQUEness and time interval
Next
From: "George Pavlov"
Date:
Subject: Re: finding unused indexes?