Aggregates and row types

Started by Thomas Munroabout 9 years ago2 messageshackers
Jump to latest
#1Thomas Munro
thomas.munro@gmail.com

Hi,

Is is expected that the first query below can be analysed and planned,
but the second can't?

explain select x from (select row(42)) s(x);

explain select count(x) from (select row(42)) s(x);
ERROR: record type has not been registered

That may be a strange thing to want to do, but it's something I
noticed and thought I'd ask about, when I was trying (and failing) to
find a query that would get transient types into a hash table in a
parallel worker for a test case yesterday.

--
Thomas Munro
http://www.enterprisedb.com

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Thomas Munro (#1)
Re: Aggregates and row types

Thomas Munro <thomas.munro@enterprisedb.com> writes:

Is is expected that the first query below can be analysed and planned,
but the second can't?

explain select x from (select row(42)) s(x);

explain select count(x) from (select row(42)) s(x);
ERROR: record type has not been registered

Well, ideally that wouldn't happen, but making it go away isn't
all that trivial. Try coercing the ROW() expression to some named
composite type. For example, in the regression database this works:

regression=# select count(x) from (select row(42)::int4_tbl) s(x);
count
-------
1
(1 row)

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers