Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 9A749634C95 for ; Thu, 11 Jun 2009 17:24:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 49206-08 for ; Thu, 11 Jun 2009 17:24:44 -0300 (ADT) X-Greylist: delayed 00:08:19.472787 by SQLgrey-1.7.6 Received: from QMTA11.emeryville.ca.mail.comcast.net (qmta11.emeryville.ca.mail.comcast.net [76.96.27.211]) by mail.postgresql.org (Postfix) with ESMTP id 0D66B63617E for ; Thu, 11 Jun 2009 17:24:47 -0300 (ADT) Received: from OMTA03.emeryville.ca.mail.comcast.net ([76.96.30.27]) by QMTA11.emeryville.ca.mail.comcast.net with comcast id 2ibH1c0040b6N64ABkGGl0; Thu, 11 Jun 2009 20:16:16 +0000 Received: from dbn8.local ([98.246.113.228]) by OMTA03.emeryville.ca.mail.comcast.net with comcast id 2kGF1c0024vjreA8PkGFzP; Thu, 11 Jun 2009 20:16:16 +0000 From: Richard Rosenberg Reply-To: Richard Rosenberg To: pgsql-sql@postgresql.org Subject: polymorphic function in 7.4 vs. 8.3 Date: Thu, 11 Jun 2009 13:16:12 -0700 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200906111316.12662.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/55 X-Sequence-Number: 32660 I have the following setup which works great in version 8.3 but throws an error in 7.4: CREATE TABLE atest1 ( id integer NOT NULL, descr text, CONSTRAINT atest1_pkey PRIMARY KEY (id) ); CREATE OR REPLACE FUNCTION test_trg() RETURNS "trigger" AS ' DECLARE any_rec wfsys.atest1; BEGIN any_rec.id := NEW.id; any_rec.descr := NEW.descr; select into any_rec * from dd_test(any_rec); --any_rec := dd_test(any_rec); RETURN any_rec; END; ' LANGUAGE 'plpgsql' VOLATILE; CREATE OR REPLACE FUNCTION dd_test(anyelement) RETURNS record AS ' DECLARE any_rec alias for $1; some_row record; BEGIN some_row := any_rec; if some_row.id < 0 then raise notice ''id is < 0!''; some_row.descr := ''some other value''; end if; RETURN some_row; END; ' LANGUAGE 'plpgsql' VOLATILE; CREATE TRIGGER trg_atest1 BEFORE INSERT ON atest1 FOR EACH ROW EXECUTE PROCEDURE test_trg(); Finally, firing the trigger like so: insert into wfsys.atest1 values(123, 'some text'); Gives the following error: ERROR: column "any_rec" does not exist CONTEXT: PL/pgSQL function "test_trg" line 7 at select into variables ********** Error ********** ERROR: column "any_rec" does not exist SQL state: 42703 Context: PL/pgSQL function "test_trg" line 7 at select into variables It works great on 8.3 (my dev server), but throws the error on the machine I am forced to work with, which is running version 7.4. I realize that polymorphic functions were pretty new in v7.4, is there a workaround or am I making a silly mistake? Or both? Incidentally, I get the same error when I change the polymorphic function's argument from "anyelement" to "wfsys.atest1" so it seems that it is occurring in the trigger function. Thanks for any help. Richard