Re: Record returning function accept not matched columns declaration - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Record returning function accept not matched columns declaration
Date
Msg-id 301471.1709755749@sss.pgh.pa.us
Whole thread Raw
In response to Re: Record returning function accept not matched columns declaration  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
"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



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #18379: LDAP bind password exposed
Next
From: Alexander Korotkov
Date:
Subject: Re: BUG #18374: Printing memory contexts on OOM condition might lead to segmentation fault