Re: Problem with return type of function ??? (corrected) - Mailing list pgsql-sql

From Tom Lane
Subject Re: Problem with return type of function ??? (corrected)
Date
Msg-id 29935.1256222015@sss.pgh.pa.us
Whole thread Raw
In response to Problem with return type of function ??? (corrected)  (Denis BUCHER <dbucherml@hsolutions.ch>)
Responses Re: Problem with return type of function ??? (corrected)  (Denis BUCHER <dbucherml@hsolutions.ch>)
Re: Problem with return type of function ??? (corrected)  (Richard Huxton <dev@archonet.com>)
Re: Problem with return type of function ??? (corrected)  (Denis BUCHER <dbucherml@hsolutions.ch>)
List pgsql-sql
Denis BUCHER <dbucherml@hsolutions.ch> 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


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Problem with return type of function ???
Next
From: Denis BUCHER
Date:
Subject: Re: Problem with return type of function ???