Re: Wrong results with subquery pullup and grouping sets

Поиск
Список
Период
Сортировка
От Richard Guo
Тема Re: Wrong results with subquery pullup and grouping sets
Дата
Msg-id CAMbWs49jahdToB3C4mfoskWcShqqT9Yn-uf-X+GKyZUcP2u7fQ@mail.gmail.com
обсуждение исходный текст
Ответ на Wrong results with subquery pullup and grouping sets  (Richard Guo <guofenglinux@gmail.com>)
Список pgsql-hackers
On Wed, Mar 5, 2025 at 11:02 AM Richard Guo <guofenglinux@gmail.com> wrote:
> create table t (a int);
> insert into t values (1);
>
> # select a, b
>   from (select a, a as b from t) ss
>   group by grouping sets(a, b)
>   having b = 1;
>  a | b
> ---+---
>  1 |
> (1 row)
>
> Note that the having clause filters out the wrong row.

BTW, this issue is not limited to HAVING clause; it can also happen to
targetlist.

# select a, b+1
  from (select a, a as b from t) ss
  group by grouping sets(a, b);
 a | ?column?
---+----------
 1 |        2
   |
(2 rows)

Surely this is wrong.

Thanks
Richard



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