Re: BUG #17769: Assert triggered in indxpath.c

Поиск
Список
Период
Сортировка
От Richard Guo
Тема Re: BUG #17769: Assert triggered in indxpath.c
Дата
Msg-id CAMbWs484gsu4sYFu_YgUXZsZoEMKAVAfHjgTOZTmnmPtVpES+Q@mail.gmail.com
обсуждение исходный текст
Ответ на BUG #17769: Assert triggered in indxpath.c  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #17769: Assert triggered in indxpath.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs

On Thu, Feb 2, 2023 at 8:13 PM PG Bug reporting form <noreply@postgresql.org> wrote:    
SQL
===
SELECT
FROM pg_catalog.pg_statio_all_tables AS ref_0,
     LATERAL (SELECT
              WHERE ref_0.schemaname = ref_0.relname) AS subq_0;
 
Thanks for the report!  I can reproduce this issue with a simplified
query.

SELECT FROM
    (SELECT n.nspname AS schemaname, c.relname
        FROM pg_class c LEFT JOIN pg_namespace n
        ON n.oid = c.relnamespace) AS ref_0,
    LATERAL (SELECT WHERE ref_0.schemaname = ref_0.relname) AS subq_0;

I believe what happens here is that after we pull up the LATERAL
subquery we would have a FromExpr with only one child.  Then
remove_useless_result_rtes elides it and merges its qual, which is
'n.nspname = c.relname', up to its parent.  This qual is then handed to
EC machinery.

When it comes to remove_useless_joins, we try to remove the LEFT join.
We are supposed to remove any joinquals referencing rel 'n'.  But here
remove_rel_from_query only checks rel->joininfo, and neglects to notice
that there is another joinqual referencing rel 'n' existing in EC.  I
think this is where the problem arises.

Another finding is that in remove_useless_result_rtes after we elide the
single-child FromExpr and merge its qual up to its parent, the LEFT join
is actually can be reduced to inner join.  But we fail to perform that
since all this happens after we've done outer join reduction.

Thanks
Richard

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #17768: Assert triggered on initsplan.c
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #17768: Assert triggered on initsplan.c