Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id BEF1E6351A0 for ; Thu, 11 Jun 2009 18:50:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 85368-08 for ; Thu, 11 Jun 2009 18:50:42 -0300 (ADT) X-Greylist: delayed 00:08:19.631487 by SQLgrey-1.7.6 Received: from QMTA08.emeryville.ca.mail.comcast.net (qmta08.emeryville.ca.mail.comcast.net [76.96.30.80]) by mail.postgresql.org (Postfix) with ESMTP id 4592F634953 for ; Thu, 11 Jun 2009 18:50:42 -0300 (ADT) Received: from OMTA01.emeryville.ca.mail.comcast.net ([76.96.30.11]) by QMTA08.emeryville.ca.mail.comcast.net with comcast id 2iUa1c0050EPchoA8liMuC; Thu, 11 Jun 2009 21:42:21 +0000 Received: from dbn8.local ([98.246.113.228]) by OMTA01.emeryville.ca.mail.comcast.net with comcast id 2liL1c0064vjreA8MliLYK; Thu, 11 Jun 2009 21:42:21 +0000 From: Richard Rosenberg Reply-To: Richard Rosenberg To: Tom Lane , pgsql-sql@postgresql.org Subject: Re: polymorphic function in 7.4 vs. 8.3 Date: Thu, 11 Jun 2009 14:42:17 -0700 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200906111442.17861.richrosenberg@earthlink.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200906/58 X-Sequence-Number: 32663 Tom, thanks for your prompt reply. I think I may have my head on straight n= ow,=20 this should work: CREATE TABLE atest1 ( =A0 id integer NOT NULL, =A0 descr text, =A0 CONSTRAINT atest1_pkey PRIMARY KEY (id) ); CREATE OR REPLACE FUNCTION test1_trg() =A0 RETURNS trigger AS ' DECLARE =A0 =A0 some_rec public.atest1; BEGIN some_rec.id :=3D NEW.id; some_rec.descr :=3D NEW.descr; select into some_rec * from dd_test(some_rec) as (id int4, descr text); =2D-some_rec :=3D dd_test(some_rec); RETURN some_rec; END; ' =A0 LANGUAGE 'plpgsql' VOLATILE; CREATE OR REPLACE FUNCTION dd_test(anyelement) =A0 RETURNS record AS ' DECLARE =A0 =A0 any_row alias for $1; =A0 =A0 some_row record; BEGIN =A0 =A0 some_row :=3D any_row; =A0 =A0 if some_row.id < 0 then =A0 =A0 =A0 =A0 raise notice ''id is < 0!''; =A0 =A0 =A0 =A0 some_row.descr :=3D ''some other value''; =A0 =A0 end if; =A0 =A0=20 RETURN some_row; END; ' =A0 LANGUAGE 'plpgsql' VOLATILE; CREATE TRIGGER trg_atest1 =A0 BEFORE INSERT =A0 ON atest1 =A0 FOR EACH ROW =A0 EXECUTE PROCEDURE test1_trg(); insert into public.atest1 values(123, 'some text'); insert into public.atest1 values(-90, 'some text'); This gives the same result. Also in the trigger function test1_trg the synt= ax=20 of the call to the polymorphic function makes a difference in terms of the= =20 error that is thrown. A simple assignment like: =2E . . some_rec :=3D dd_test(some_rec); =2E . . Throws a syntax error, while a 'SELECT INTO. . .' like: =2E . . select into some_rec * from dd_test(some_rec) as (id int4, descr text); =2E . . Throws this: =A0ERROR: column "some_rec" does not exist SQL state: 42703 Context: PL/pgSQL function "test1_trg" line 7 at select into variables Sorry for the earlier typo(s), and thanks for any help.=20 Richard