Re: [HACKERS] Strange result with LATERAL query

2016-08-24 Thread Tom Lane
Andrew Gierth writes: > "Tom" == Tom Lane writes: > Tom> I think it's a bit too stupid as-is, though. We don't need to > Tom> recalculate for Params in aggdirectargs, do we? > In theory we would need to. How come? Those are only passed to the final function, no? They shouldn't affect what

Re: [HACKERS] Strange result with LATERAL query

2016-08-24 Thread Andrew Gierth
> "Tom" == Tom Lane writes: Tom> Hm, I was just working on inserting something of the sort into Tom> ExecInitAgg. But I guess we could do it in the planner too. Will Tom> run with your approach. Tom> I think it's a bit too stupid as-is, though. We don't need to Tom> recalculate for P

Re: [HACKERS] Strange result with LATERAL query

2016-08-24 Thread Tom Lane
Andrew Gierth writes: > How about: Hm, I was just working on inserting something of the sort into ExecInitAgg. But I guess we could do it in the planner too. Will run with your approach. I think it's a bit too stupid as-is, though. We don't need to recalculate for Params in aggdirectargs, do w

Re: [HACKERS] Strange result with LATERAL query

2016-08-24 Thread Andrew Gierth
> "Pavel" == Pavel Stehule writes: Pavel> The result should not depend on GUC - hashagg on/off changing Pavel> output - it is error. I don't think anyone's suggesting leaving it unfixed, just whether the fix should introduce unnecessary rescans of the aggregate input. -- Andrew (irc:Rhod

Re: [HACKERS] Strange result with LATERAL query

2016-08-24 Thread Andrew Gierth
> "Andrew" == Andrew Gierth writes: > "Tom" == Tom Lane writes: Tom> I'm not sure if it's worth trying to distinguish whether the Param Tom> is inside any aggregate calls or not. How about: -- Andrew (irc:RhodiumToad) diff --git a/src/backend/executor/nodeAgg.c b/src/backend/execut

Re: [HACKERS] Strange result with LATERAL query

2016-08-24 Thread Andrew Gierth
> "Tom" == Tom Lane writes: Tom> I'm not sure if it's worth trying to distinguish whether the Param Tom> is inside any aggregate calls or not. The existing code gets the Tom> right answer for Tom> select array(select x+sum(y) from generate_series(1,3) y group by y) Tom> from generat

Re: [HACKERS] Strange result with LATERAL query

2016-08-24 Thread Pavel Stehule
2016-08-24 17:08 GMT+02:00 Tom Lane : > Andrew Gierth writes: > > 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

Re: [HACKERS] Strange result with LATERAL query

2016-08-24 Thread Tom Lane
Andrew Gierth writes: > 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 nonsens

Re: [HACKERS] Strange result with LATERAL query

2016-08-24 Thread Andrew Gierth
> "Andrew" == Andrew Gierth writes: > "Jeevan" == Jeevan Chalke writes: Jeevan> Hi, Jeevan> While playing with LATERAL along with some aggregates in Jeevan> sub-query, I have observed somewhat unusual behavior. Andrew> Simpler example not needing LATERAL: Andrew> select array(sele

Re: [HACKERS] Strange result with LATERAL query

2016-08-24 Thread Andrew Gierth
> "Jeevan" == Jeevan Chalke writes: Jeevan> Hi, Jeevan> While playing with LATERAL along with some aggregates in Jeevan> sub-query, I have observed somewhat unusual behavior. Simpler example not needing LATERAL: select array(select sum(x+y) from generate_series(1,3) y group by y) from