Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id B09B863331A for ; Thu, 22 Oct 2009 11:33:47 -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 26470-04 for ; Thu, 22 Oct 2009 14:33:39 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 11F716331B5 for ; Thu, 22 Oct 2009 11:33:39 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n9MEXZpY029936; Thu, 22 Oct 2009 10:33:35 -0400 (EDT) To: Denis BUCHER cc: pgsql-sql@postgresql.org Subject: Re: Problem with return type of function ??? (corrected) In-reply-to: <4AE046E4.8010205@hsolutions.ch> References: <4AE046E4.8010205@hsolutions.ch> Comments: In-reply-to Denis BUCHER message dated "Thu, 22 Oct 2009 13:49:56 +0200" Date: Thu, 22 Oct 2009 10:33:35 -0400 Message-ID: <29935.1256222015@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200910/103 X-Sequence-Number: 33302 Denis BUCHER writes: > I have a strange problem, because it worked in a fonction for a table, > and now I created the same (?) function for another table and it doesn't > work... > The function is accepted but at runtime I get : > ERREUR: wrong record type supplied in RETURN NEXT > CONTEXTE : PL/pgSQL function "find_sn_live" line 26 at return next Does that table have any dropped columns? If you don't remember whether you ever dropped any columns, a quick look into pg_attribute will tell you: select attname from pg_attribute where attrelid = 'rma.serial_number'::regclass; plpgsql isn't tremendously good with rowtypes that contain dropped columns. I believe this particular case is fixed in CVS HEAD, but the patch was a bit invasive and won't get back-ported to existing releases. The workaround is to drop and recreate the table without any dropped columns. regards, tom lane