pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: PetSerAl <petseral@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: Record returning function accept not matched columns declaration
Date: Wed, 06 Mar 2024 15:09:09 -0500
Message-ID: <301471.1709755749@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwbXwwPbwtZ5FDGix1R-XXmvynfi+hcjSKZYk1ifegVbcQ@mail.gmail.com>
References: <CAKygsHSerA1eXsJHR9wft3Gn3wfHQ5RfP8XHBzF70_qcrrRvEg@mail.gmail.com>
	<CAKFQuwZ1-Ha1oHbHgveVgjNu6RWGQfVPNTO87y_=LxOmbyFBvA@mail.gmail.com>
	<2741768.1709237477@sss.pgh.pa.us>
	<CAKFQuwYs7f4OGJJXWCVEfjqab5U9vyZ-j-4oFJN-NJKzMKuKiw@mail.gmail.com>
	<CAKFQuwbXwwPbwtZ5FDGix1R-XXmvynfi+hcjSKZYk1ifegVbcQ@mail.gmail.com>

"David G. Johnston" <david.g.johnston@gmail.com> 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





view thread (12+ messages)

Message-ID: <301471.1709755749@sss.pgh.pa.us>
Permalink:  ../301471.1709755749@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/301471.1709755749@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, petseral@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: Record returning function accept not matched columns declaration
  In-Reply-To: <301471.1709755749@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox