Re: return can contains any row or record functions

From: Neil Conway <neilc(at)samurai(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)hotmail(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: return can contains any row or record functions
Date: 2005-11-07 23:10:13
Message-ID: 1131405013.6884.129.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

I'm confused by this part of the patch, circa line 1835 of pl_exec.c:

/* coerce type if needed */
if (estate->rsi && IsA(estate->rsi, ReturnSetInfo) &&
estate->rsi->expectedDesc != NULL &&
!compatible_tupdesc(estate->rsi->expectedDesc, in_tupdesc))
{
estate->retval = (Datum) make_tuple_from_tuple(estate,
&td,
in_tupdesc,
estate->rsi->expectedDesc);
if (estate->retval == PointerGetDatum(NULL))
ereport(...);

estate->rettupdesc = estate->rsi->expectedDesc;
}
else
{
estate->retval = (Datum) heap_copytuple(&td);
estate->rettupdesc = in_tupdesc;
}

This is for the "tuple returning function" case of RETURN. estate->rsi
seems to contain information for set-returning functions -- why do we
need to use it to obtain the expected tupledesc of the function's return
value? I'm just wondering if we ought to be fetching this from somewhere
else.

As it stands, this seems plainly wrong:

create type __trt as (x integer, y integer, z text);

create or replace function return_row4() returns __trt as $$
begin
return (1,2,'3'::text,4);
end;
$$ language plpgsql;

select return_row4();
return_row4
-------------
(1,2,3,4)
(1 row)

-Neil

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Pavel Stehule 2005-11-08 07:55:03 Re: return can contains any row or record functions
Previous Message Gregory Maxwell 2005-11-07 20:07:15 Re: Interval aggregate regression failure (expected seems