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 1rhxZj-00EIab-V6 for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Mar 2024 20:09:16 +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 1rhxZi-00Dr2l-7g for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Mar 2024 20:09:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rhxZh-00Dr2c-VV for pgsql-bugs@lists.postgresql.org; Wed, 06 Mar 2024 20:09:14 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rhxZe-003C7F-RZ for pgsql-bugs@lists.postgresql.org; Wed, 06 Mar 2024 20:09:13 +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 426K99wO301472; Wed, 6 Mar 2024 15:09:09 -0500 From: Tom Lane To: "David G. Johnston" cc: 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> Comments: In-reply-to "David G. Johnston" message dated "Thu, 29 Feb 2024 14:55:55 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <301470.1709755749.1@sss.pgh.pa.us> Date: Wed, 06 Mar 2024 15:09:09 -0500 Message-ID: <301471.1709755749@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > with a(b) as (values (row(1,2,3))) > select (a.b).* from a; > ERROR: record type has not been registered I looked into this case. The failure occurs when the parser tries to expand the ".*" notation into separate output columns, as required per SQL spec. All it has is a Var of type RECORD referencing the VALUES RTE entry, so it has to fail. In the specific example given here, you could imagine drilling down into the VALUES and figuring out what concrete rowtype the RECORD value will have at runtime, but I'm not excited about going there. There are too many cases where it wouldn't work. Note that as long as you don't need parse-time expansion of the record, it works: =# with a(b) as (values (row(1,2,3))) select a.b from a; b --------- (1,2,3) (1 row) I pushed the patch for the original problem. After debating with myself I concluded that back-patching it was probably less risky than not back-patching, so I did that. regards, tom lane