public inbox for [email protected]
help / color / mirror / Atom feedFrom: David G. Johnston <[email protected]>
To: d <[email protected]>
Cc: PostgreSQL mailing lists <[email protected]>
Subject: Re: ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)
Date: Sun, 1 May 2022 08:58:38 -0700
Message-ID: <CAKFQuwaZR0F4FL0RoP2sQ2y9v3V5GCZh9UofUmeS9BFPtsgp=Q@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
On Sun, May 1, 2022 at 8:44 AM d <[email protected]> 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.
https://www.postgresql.org/docs/current/plpgsql-implementation.html#PLPGSQL-PLAN-CACHING
"""
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.
view thread (3+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: ERROR: type of parameter 1 (fruit2) does not match that when preparing the plan (fruit1)
In-Reply-To: <CAKFQuwaZR0F4FL0RoP2sQ2y9v3V5GCZh9UofUmeS9BFPtsgp=Q@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox