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 1ruYko-0067Zk-VC for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Apr 2024 14:16:47 +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 1ruYko-003EPN-5D for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Apr 2024 14:16:46 +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 1ruYkn-003EPF-TF for pgsql-bugs@lists.postgresql.org; Wed, 10 Apr 2024 14:16:45 +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 1ruYkl-000CuN-IK for pgsql-bugs@lists.postgresql.org; Wed, 10 Apr 2024 14:16:45 +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 43AEGfI54019338; Wed, 10 Apr 2024 10:16:41 -0400 From: Tom Lane To: Richard Guo cc: Tender Wang , exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18422: Assert in expandTupleDesc() fails on row mismatch with additional SRF In-reply-to: References: <18422-89ca86c8eac5246d@postgresql.org> <3861246.1712691263@sss.pgh.pa.us> <3917908.1712719937@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Wed, 10 Apr 2024 15:58:51 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <4019336.1712758601.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Wed, 10 Apr 2024 10:16:41 -0400 Message-ID: <4019337.1712758601@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > On Wed, Apr 10, 2024 at 11:32 AM Tom Lane wrote: >> I guess we could. It won't matter because the following code will >> reject RECORD in any case; but we could save a few cycles by not >> calling get_expr_result_tupdesc there. > Indeed. I think it would be better to add this same rule to > process_function_rte_ref(), or at least write some comments there to > explain why it is not necessary to check rtfunc->funccolnames while > other places do. Wilco. Another thing I was considering, but didn't pull the trigger on in the draft patch, was to introduce a funcapi.c function on the order of get_expr_result_rtfunc(RangeTblFunction *rtfunc, ...) which would encapsulate applying either BuildDescFromLists or get_expr_result_type. I didn't do it because I found that the only places that would want to use it are the two that are correct already; the places we still need to fix have short-cuts they can take rather than building an intermediate tupdesc. (The present bug could be summarized as "the short-cuts still need to pay attention to the coldeflist".) But the advantage of doing this anyway is that its header comment would be a natural place to document this issue and policy. Thoughts? regards, tom lane