pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Rosenberg <richrosenberg@earthlink.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: polymorphic function in 7.4 vs. 8.3
Date: Thu, 11 Jun 2009 16:02:48 -0700
Message-ID: <200906111602.48353.richrosenberg@earthlink.net> (raw)
In-Reply-To: <20491.1244756986@sss.pgh.pa.us>
References: <200906111442.17861.richrosenberg@earthlink.net>
	<20491.1244756986@sss.pgh.pa.us>

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



view thread (6+ messages)  latest in thread

Message-ID: <200906111602.48353.richrosenberg@earthlink.net>
Permalink:  ../200906111602.48353.richrosenberg@earthlink.net/
Also on:    postgresql.org/message-id/200906111602.48353.richrosenberg@earthlink.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: richrosenberg@earthlink.net, tgl@sss.pgh.pa.us
  Subject: Re: polymorphic function in 7.4 vs. 8.3
  In-Reply-To: <200906111602.48353.richrosenberg@earthlink.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox