Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgwNE-008kZP-T4 for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Mar 2024 00:40:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rgwNC-002ruz-SL for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Mar 2024 00:40:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgwNC-002rur-KL for pgsql-bugs@lists.postgresql.org; Mon, 04 Mar 2024 00:40:07 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgwNA-002d8Z-BN for pgsql-bugs@lists.postgresql.org; Mon, 04 Mar 2024 00:40:06 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 4240e1xX3419250; Sun, 3 Mar 2024 19:40:02 -0500 From: Tom Lane To: jian he cc: "David G. Johnston" , PetSerAl , "pgsql-bugs@lists.postgresql.org" Subject: Re: Record returning function accept not matched columns declaration In-reply-to: References: <2741768.1709237477@sss.pgh.pa.us> <2756762.1709245862@sss.pgh.pa.us> <2969212.1709315759@sss.pgh.pa.us> Comments: In-reply-to jian he message dated "Mon, 04 Mar 2024 08:00:00 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3419248.1709512801.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sun, 03 Mar 2024 19:40:01 -0500 Message-ID: <3419249.1709512801@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk jian he writes: > On Sat, Mar 2, 2024 at 1:56 AM Tom Lane 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