Re: %ROWTYPE as PL/pgsql argument - Mailing list pgsql-general

From Tom Lane
Subject Re: %ROWTYPE as PL/pgsql argument
Date
Msg-id 28182.1017785613@sss.pgh.pa.us
Whole thread Raw
In response to Re: %ROWTYPE as PL/pgsql argument  (Jan Wieck <janwieck@yahoo.com>)
List pgsql-general
Jan Wieck <janwieck@yahoo.com> writes:
>     it  doesn't  work.  Actually, giving just a relname as 'some-
>     row-type' crashes  the  backend.  Will  take  a  look  at  it
>     tomorrow.

I already did.  It looks like plpgsql is mistakenly treating the type
as a scalar type (eg, using oidin/oidout to convert it ... which after
all is what pg_type says to do).  The callee then crashes because it's
expecting a pointer to a tuple, and isn't getting one.  Probably the
right fix is to implicitly assume %ROWTYPE behavior if we see that a
variable's type is marked typtype = 'c' in pg_type.

Meanwhile, passing a rowtype variable to a function doesn't work either.
The initial problem is that the reference to the rowtype variable never
gets replaced by an expression parameter reference, because
read_sql_construct() doesn't do anything with T_RECORD or T_ROW items;
I dunno if there are more problems beyond that one.  (There are a lot
of other places that treat T_VARIABLE but not T_RECORD or T_ROW, too;
probably all of them need to be looked at.)

            regards, tom lane

pgsql-general by date:

Previous
From: Jan Wieck
Date:
Subject: Re: %ROWTYPE as PL/pgsql argument
Next
From: Peter Sojan
Date:
Subject: Problem with referential integrity within functions (bug?)