Re: return can contains any row or record functions

Поиск
Список
Период
Сортировка
Искать
От
Neil Conway
Тема
Re: return can contains any row or record functions
Дата
Msg-id
1131405013.6884.129.camel@localhost.localdomain
Ответ на
Список
Дерево обсуждения
return can contains any row or record functions "Pavel Stehule" <pavel.stehule@hotmail.com>
Re: return can contains any row or record functions Neil Conway <neilc@samurai.com>
Re: return can contains any row or record functions Tom Lane <tgl@sss.pgh.pa.us>
Re: return can contains any row or record functions Neil Conway <neilc@samurai.com>
Re: return can contains any row or record functions "Pavel Stehule" <pavel.stehule@hotmail.com>
Re: return can contains any row or record functions Neil Conway <neilc@samurai.com>
Re: return can contains any row or record functions "Pavel Stehule" <pavel.stehule@hotmail.com>
Re: return can contains any row or record functions Bruce Momjian <pgman@candle.pha.pa.us>
Re: return can contains any row or record functions Bruce Momjian <pgman@candle.pha.pa.us>
Re: return can contains any row or record functions "Pavel Stehule" <pavel.stehule@hotmail.com>
Re: return can contains any row or record functions Bruce Momjian <pgman@candle.pha.pa.us>
Re: return can contains any row or record functions "Pavel Stehule" <pavel.stehule@hotmail.com>
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


В списке pgsql-patches по дате отправления
От: Tom Lane
Дата:
От: Pavel Stehule
Дата:
FAQ