Re: BUG #17826: An assert failed in /src/backend/optimizer/util/var.c

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #17826: An assert failed in /src/backend/optimizer/util/var.c
Дата
Msg-id 402866.1678378153@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #17826: An assert failed in /src/backend/optimizer/util/var.c  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #17826: An assert failed in /src/backend/optimizer/util/var.c  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> When executing the following query:

> WITH table1 AS ( SELECT 1 ) SELECT 1 FROM ( SELECT RANK ( ) OVER ( ) column0
> FROM table1 JOIN table1 AS alias0 ON TRUE ) AS alias1 WHERE ( CASE WHEN ( 1
> IN ( SELECT 1 ) ) THEN 1 END = column0 ) ;

> I get a failed assertion with the following stacktrace:

The assertion is complaining about a SubPlan that has gotten pushed down
into the subquery, where it should not have been.  Tracing through it,
the blame appears to fall on commit 9d9c02ccd, which added this rather
astonishing bit of coding:

            if (!rinfo->pseudoconstant &&
                qual_is_pushdown_safe(subquery, rti, rinfo, &safetyInfo))
            {
                /* Push it down */
                subquery_push_qual(subquery, rte, rti, clause);
            }
            else
            {
+               /*
+                * Since we can't push the qual down into the subquery, check
+                * if it happens to reference a window function.  If so then
+                * it might be useful to use for the WindowAgg's runCondition.
+                */
+               if (!subquery->hasWindowFuncs ||
+                   check_and_push_window_quals(subquery, rte, rti, clause,
+                                               &run_cond_attrs))

In other words, after qual_is_pushdown_safe has rejected a qual as being
unsafe to push down, check_and_push_window_quals merrily does it anyway,
apparently on the theory that window functions are exempt from all rules.
How is this even a little bit sane?

We could fix the given problem by adding a duplicative contain_subplans
check in check_and_push_window_quals, but first I want to see an argument
why it's okay to ignore any of the other things qual_is_pushdown_safe is
checking for, because I think this is dangerously broken on every single
count.  My druthers would be to remove check_and_push_window_quals
altogether.

            regards, tom lane



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

Предыдущее
От: "Salavessa, Joao (Senior Developer)"
Дата:
Сообщение: RE: [EXTERNAL] Re: PostgreSQL 14.7 "ALTER TABLE IF EXISTS" fails - ERROR: schema/relation "" does not exist
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #17828: postgres_fdw leaks file descriptors on error and aborts aborted transaction in lack of fds