Re: Record returning function accept not matched columns declaration

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PetSerAl <petseral(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Record returning function accept not matched columns declaration
Date: 2024-03-04 00:40:01
Message-ID: 3419249.1709512801@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

jian he <jian(dot)universality(at)gmail(dot)com> writes:
> On Sat, Mar 2, 2024 at 1:56 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I'm having mixed feelings about whether to back-patch this. Somebody
>> might complain that we broke a working query in a minor release.

> context: in postgres 9.3.25, dbfiddle[1]
> this query will fail:

> with a(b) as (values (row(1,2,3)))
> select * from a, coalesce(b) as c(d int, e int);

Sure, but in v12 and up (i.e., the supported versions that we might
back-patch into) the query succeeds, and it might not be obvious
to someone that its behavior isn't as-intended.

Admittedly, this seems like a rather contrived case. In cases
where the record-returning function call isn't reducible to a
constant, you'll get the expected error. So maybe I'm worrying
over something that no one is depending on in practice.

> I think by ExecMakeTableFunctionResult you mean `mainly
> ExecMakeTableFunctionResult's function: tupledesc_match`
> since ExecMakeTableFunctionResult is quite long.

Perhaps. I mentioned ExecMakeTableFunctionResult because that's
what's called directly from nodeFunctionscan.c. Referencing a
static function of another module is risky because it's pretty
unlikely the comment would get updated if refactoring in that
module makes it false.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-03-04 07:19:33 BUG #18375: requested statistics kind "f" is not yet built for statistics object 16722
Previous Message Thomas Munro 2024-03-04 00:20:21 Re: BUG #18349: ERROR: invalid DSA memory alloc request size 1811939328, CONTEXT: parallel worker