[PATCH] Allow anonymous rowtypes in function return column definition

Elvis Pranskevichus <el@prans.net>

From: Elvis Pranskevichus <el@prans.net>
To: pgsql-hackers@postgresql.org
Date: 2018-12-06T22:27:32Z
Lists: pgsql-hackers

Attachments

Currently, the following query

    SELECT q.b = row(2)
    FROM unnest(ARRAY[row(1, row(2))]) AS q(a int, b record);

would fail with

    ERROR:  column "b" has pseudo-type record

This is due to CheckAttributeNamesTypes() being used on a function
coldeflist as if it was a real relation definition.  But in the context
of a query there seems to be no harm in allowing this, as other ways of
manipulating anonymous rowtypes work well, e.g.:

    SELECT (ARRAY[ROW(1, ROW(2))])[1];



                                Elvis

Commits

  1. Allow RECORD and RECORD[] to be specified in function coldeflists.