Re: [HACKERS] Views which lead to nested aggregates

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] Views which lead to nested aggregates
Дата
Msg-id 19086.930061830@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] Views which lead to nested aggregates  (wieck@debis.com (Jan Wieck))
Список pgsql-hackers
wieck@debis.com (Jan Wieck) writes:
>     Up  to  now  (v6.5)  this  kind  of  nested  aggregates isn't
>     supported.  Not directly over SQL, nor by views. To  be  sure
>     anything  is  fine,  your  views (and however you select from
>     them) should be expressable with a  regular  SELECT  too.  In
>     fact  the rewrite system has to try to build such a query for
>     it - so if you can't how should the rewriter can?

Still, it ought to either do it or produce a useful error message.
6.4's error message doesn't qualify as useful in my book.  But 6.5's
behavior is far worse: it accepts the query and cheerfully generates
a wrong result!  That's definitely a bug.

Looking ahead to the larger problem, I believe that the executor is
perfectly capable of handling nested aggregate plans --- the trick is
to get the planner to produce one.  Maybe we need an extension to the
parsetree language?  It doesn't seem like this ought to be hard to
support, it's just that there's no parsetree configuration that
represents what we want done.  Or, maybe we should rethink the division
of labor between the rewriter and planner --- if the rewriter could
output a partially-converted plan tree, instead of a parse tree, then
it could do as it pleased, but still leave the messy details of lowlevel
plan optimization to the planner.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Guillaume Lairloup
Дата:
Сообщение: ...
Следующее
От: Jeff Hoffmann
Дата:
Сообщение: Re: [HACKERS] has anybody else used r-tree indexes in 6.5?