| От | Tom Lane |
|---|---|
| Тема | Re: BUG #7622: Incorrect aggregate level processing |
| Дата | |
| Msg-id | 20677.1351259084@sss.pgh.pa.us обсуждение |
| Ответ на | BUG #7622: Incorrect aggregate level processing (andrew@tao11.riddles.org.uk) |
| Список | 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
В списке pgsql-bugs по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера