Re: Strange result with LATERAL query - Mailing list pgsql-hackers

From Andrew Gierth
Subject Re: Strange result with LATERAL query
Date
Msg-id 8737lucp4m.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Strange result with LATERAL query  (Jeevan Chalke <jeevan.chalke@enterprisedb.com>)
Responses Re: Strange result with LATERAL query  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Re: Strange result with LATERAL query  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
>>>>> "Jeevan" == Jeevan Chalke <jeevan.chalke@enterprisedb.com> writes:
Jeevan> Hi,Jeevan> While playing with LATERAL along with some aggregates inJeevan> sub-query, I have observed somewhat
unusualbehavior.
 

Simpler example not needing LATERAL:

select array(select sum(x+y) from generate_series(1,3) y group by y) from generate_series(1,3) x;?column? 
----------{2,4,3}{2,4,3}{2,4,3}
(3 rows)

This is broken all the way back, it's not a recent bug.

Something is wrong with the way chgParam is being handled in Agg nodes.
The code in ExecReScanAgg seems to assume that if the lefttree doesn't
have any parameter changes then it suffices to re-project the data from
the existing hashtable; but of course this is nonsense if the parameter
is in an input to an aggregate function.

-- 
Andrew (irc:RhodiumToad)



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Showing parallel status in \df+
Next
From: Andrew Gierth
Date:
Subject: Re: Strange result with LATERAL query