Another problem with result type selection in inline_function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Another problem with result type selection in inline_function
Дата
Msg-id 17607.1178033597@sss.pgh.pa.us
обсуждение исходный текст
Ответы Re: Another problem with result type selection in inline_function  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
I just realized that there's a problem with the patch I applied here
http://archives.postgresql.org/pgsql-committers/2007-03/msg00057.php
to ensure that the result type of an inline'd SQL function is correctly
marked in the resulting expression tree.  To wit, it doesn't work for
functions returning pseudotypes:

regression=# create function if(bool,anyelement,anyelement) returns anyelement
regression-# as $$ select case when $1 then $2 else $3 end $$ language sql;
CREATE FUNCTION
regression=# explain verbose select if(true,1,2) from int4_tbl;
server closed the connection unexpectedly

The crash is because this newly-added assert fails:
       Assert(IsBinaryCoercible(exprType(newexpr), funcform->prorettype));

and beyond that, we don't actually want the other added line (adding a
RelabelType node) either, because it'd be relabeling the expression as
type ANYELEMENT which is entirely unhelpful.

I think the correct thing is to do nothing, and assume the expanded
expression must have the right type already, if the function is declared
to return a pseudotype.  The only pseudotypes allowed as SQL-function
results are RECORD, VOID, and polymorphic, and this seems OK and maybe
even required in each case.  But having gotten this wrong once already,
maybe I better call for comments...
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Dave Page
Дата:
Сообщение: Re: Feature freeze progress report
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Heap page diagnostic functions