Re: BUG #17610: Use of multiple composite types incompatible with record-typed function parameter

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: mjurca(at)centrum(dot)cz, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17610: Use of multiple composite types incompatible with record-typed function parameter
Date: 2022-09-08 16:17:14
Message-ID: 4048043.1662653834@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Japin Li <japinli(at)hotmail(dot)com> writes:
> On Thu, 08 Sep 2022 at 18:19, PG Bug reporting form <noreply(at)postgresql(dot)org> wrote:
>> The SQL code at the end of this bug report ends with the following error:
>> 2022-09-08 10:09:02.173 GMT [174] ERROR: type of parameter 1
>> (composite_type_2) does not match that when preparing the plan
>> (composite_type_1)

> The documentation says:

> 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.

I think that is specifically referring to function internal variables of
type RECORD, which are handled specially. For function input arguments,
we could get around this by treating RECORD like a polymorphic type, as
attached. (For some reason I thought we already did that, but nope.)

regards, tom lane

Attachment Content-Type Size
treat-record-inputs-as-polymorphism.patch text/x-diff 2.3 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Davis 2022-09-08 17:30:05 Re: PANIC in heap_delete during ALTER TABLE
Previous Message Japin Li 2022-09-08 15:21:51 Re: BUG #17610: Use of multiple composite types incompatible with record-typed function parameter