> This may be simplified to the comparison between these two queries:
... or even further into:
CREATE TYPE test AS ( a integer, b integer, c integer, d integer );
EXPLAIN SELECT ((SELECT ROW(1,1,1,1)::test)::test);
EXPLAIN SELECT ((SELECT ROW(1,1,1,1)::test)::test).*;
craig=# EXPLAIN SELECT ((SELECT ROW(1,1,1,1)::test)::test);
QUERY PLAN
--------------------------------------------------
Result (cost=0.01..0.02 rows=1 width=0)
InitPlan
-> Result (cost=0.00..0.01 rows=1 width=0)
(3 rows)
craig=# EXPLAIN SELECT ((SELECT ROW(1,1,1,1)::test)::test).*;
QUERY PLAN
--------------------------------------------------
Result (cost=0.04..0.05 rows=1 width=0)
InitPlan
-> Result (cost=0.00..0.01 rows=1 width=0)
-> Result (cost=0.00..0.01 rows=1 width=0)
-> Result (cost=0.00..0.01 rows=1 width=0)
-> Result (cost=0.00..0.01 rows=1 width=0)
(6 rows)
Something odd I stumbled upon while testing for this:
craig=# SELECT tmp FROM (SELECT ((SELECT ROW(1,1,1,1)::test)::test)) AS tmp;
tmp
---------------
("(1,1,1,1)")
(1 row)
... is fine,
craig=# SELECT tmp.* FROM (SELECT ((SELECT ROW(1,1,1,1)::test)::test))
AS tmp;
test
-----------
(1,1,1,1)
(1 row)
... is fine,
craig=# SELECT (tmp.*).* FROM (SELECT ((SELECT
ROW(1,1,1,1)::test)::test)) AS tmp;
test
-----------
(1,1,1,1)
(1 row)
... is ... WTF? How is "(tmp.*).*" the same as "tmp.*" ?
--
Craig Ringer