Re: ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)
Дата
Msg-id CAKFQuwaZR0F4FL0RoP2sQ2y9v3V5GCZh9UofUmeS9BFPtsgp=Q@mail.gmail.com
обсуждение исходный текст
Ответ на ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)  (d <dchuck@yurfish.com>)
Ответы Re: ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Sun, May 1, 2022 at 8:44 AM d <dchuck@yurfish.com> wrote:
-------to reproduce --------------------------------------
CREATE OR REPLACE FUNCTION record_to_form_data(p_r record)
 RETURNS text
 LANGUAGE plpgsql
AS $function$
begin
return (
select string_agg(format('%s=%s',key,urlencode(value)),'&')
       from
        (select p_r.*) i,
        hstore(i.*) as h,each(h) );
       end;
$function$;

Not a bug, it is a documented limitation.

It is your use of "(select p_r.*)" that is problematic.


"""
The mutable nature of record variables presents another problem in this connection. When fields of a record variable are used in expressions or statements, the data types of the fields must not change from one call of the function to the next, since each expression will be analyzed using the data type that is present when the expression is first reached. EXECUTE can be used to get around this problem when necessary.
"""

David J.


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

Предыдущее
От: d
Дата:
Сообщение: ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)