array handling on 8.0.3

From: Daniel Drotos <drdani(at)mazsola(dot)iit(dot)uni-miskolc(dot)hu>
To: pgsql-sql(at)postgresql(dot)org
Subject: array handling on 8.0.3
Date: 2007-10-09 13:11:44
Message-ID: Pine.LNX.4.64.0710091506550.7196@mazsola.iit.uni-miskolc.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message George Pavlov 2007-10-09 18:58:49 Re: finding unused indexes?
Previous Message Rodrigo De León 2007-10-08 14:46:40 Re: UNIQUEness and time interval