Re: polymorphic function in 7.4 vs. 8.3 - Mailing list pgsql-sql

From Richard Rosenberg
Subject Re: polymorphic function in 7.4 vs. 8.3
Date
Msg-id 200906111602.48353.richrosenberg@earthlink.net
Whole thread Raw
In response to Re: polymorphic function in 7.4 vs. 8.3  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: polymorphic function in 7.4 vs. 8.3  (Rob Sargent <robjsargent@gmail.com>)
List pgsql-sql
On Thursday 11 June 2009 14:49:46 Tom Lane wrote:

> Sure you can't move the DB off 7.4?  There would be pretty considerable
> benefits from adopting some recent release instead.
>
>             regards, tom lane

Don't I know it. I am SOL as the machine is hosted/shared out by an external 
provider. I can do it by getting rid of the polymorphism - breaking the 
columns into separate args - as you say:

CREATE OR REPLACE FUNCTION public.test1_trg() RETURNS "trigger" AS
'
DECLARE   some_rec public.atest1;

BEGIN
some_rec.id := NEW.id;
some_rec.descr := NEW.descr;
select into some_rec * from dd_test(some_rec.id, some_rec.descr, TG_RELNAME) 
as (id int, descr text);
--some_rec := dd_test(some_rec)::public.atest1;
RETURN some_rec;
END;
' LANGUAGE 'plpgsql' VOLATILE;


CREATE OR REPLACE FUNCTION public.dd_test(int, text, text) RETURNS record AS
'
DECLARE   any_id alias for $1;   any_descr alias for $2;   tablename alias for $3;   some_id integer;   some_descr
text;  some_row record;
 

BEGIN   some_id := any_id;   if some_id < 0 then       raise notice ''id is < 0!'';       some_descr := ''some other
value'';  end if;
 
for some_row in execute ''select * from ''||tablename||'' where 1 = 0'' loop
end loop;
some_row.id := some_id;
some_row.descr := some_descr;    
RETURN some_row;
END;
' LANGUAGE 'plpgsql' VOLATILE;

Oh well, I'm glad I tested the approach out before going too far down this  
road. Thanks again for your timely help. 

Richard


pgsql-sql by date:

Previous
From: Richard Rosenberg
Date:
Subject: Re: polymorphic function in 7.4 vs. 8.3
Next
From: Rob Sargent
Date:
Subject: Re: polymorphic function in 7.4 vs. 8.3