pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
BUG #7622: Incorrect aggregate level processing 2+ messages / 2 participants [nested] [flat]
* BUG #7622: Incorrect aggregate level processing @ 2012-10-26 05:20 andrew@tao11.riddles.org.uk 2012-10-26 13:44 ` Re: BUG #7622: Incorrect aggregate level processing Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 1 reply; 2+ messages in thread From: andrew@tao11.riddles.org.uk @ 2012-10-26 05:20 UTC (permalink / raw) To: pgsql-bugs The following bug has been logged on the website: Bug reference: 7622 Logged by: Andrew Gierth Email address: andrew@tao11.riddles.org.uk PostgreSQL version: 9.2.1 Operating system: n/a Description: Tested on git-master, 9.2.1, various older versions. select (select array_agg(random()*i) from (values (1),(2)) v(a)) from generate_series(1,3) i; Expected output is three rows each with a 2-element array; actual output is: ERROR: more than one row returned by a subquery used as an expression Looking at the explain, the aggregate is being pulled out of the subplan and evaluated at the top query level. (This came up while doing some random data generation, I've simplified it a bit.) ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #7622: Incorrect aggregate level processing 2012-10-26 05:20 BUG #7622: Incorrect aggregate level processing andrew@tao11.riddles.org.uk @ 2012-10-26 13:44 ` Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2012-10-26 13:44 UTC (permalink / raw) To: andrew@tao11.riddles.org.uk; +Cc: pgsql-bugs andrew@tao11.riddles.org.uk writes: > select (select array_agg(random()*i) from (values (1),(2)) v(a)) from > generate_series(1,3) i; > Expected output is three rows each with a 2-element array; actual output > is: > ERROR: more than one row returned by a subquery used as an expression > Looking at the explain, the aggregate is being pulled out of the subplan and > evaluated at the top query level. (This came up while doing some random data > generation, I've simplified it a bit.) This is not a bug, it's the behavior required by SQL standard. An aggregate belongs to the lowest query level supplying a variable to it (except of course when it contains no variable at all). So it's effectively an outer-reference constant for that inner select. regards, tom lane ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2012-10-26 13:44 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2012-10-26 05:20 BUG #7622: Incorrect aggregate level processing andrew@tao11.riddles.org.uk 2012-10-26 13:44 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox