Re: ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1) - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)
Date
Msg-id CAKFQuwaZR0F4FL0RoP2sQ2y9v3V5GCZh9UofUmeS9BFPtsgp=Q@mail.gmail.com
Whole thread Raw
In response to ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)  (d <dchuck@yurfish.com>)
Responses Re: ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)
List 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 by date:

Previous
From: d
Date:
Subject: ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)
Next
From: Tom Lane
Date:
Subject: Re: ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)