Re: BUG #17768: Assert triggered on initsplan.c

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: tharakan(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17768: Assert triggered on initsplan.c
Date: 2023-02-02 12:02:44
Message-ID: CAMbWs48Ggc419o1c14OLa=MtP_mgXMv=Y0h=3UcKKugCGiOQyw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Feb 2, 2023 at 5:13 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:

>
> On Thu, Feb 2, 2023 at 3:34 PM PG Bug reporting form <
> noreply(at)postgresql(dot)org> wrote:
>
>> The following bug has been logged on the website:
>>
>> Bug reference: 17768
>> Logged by: Robins Tharakan
>> Email address: tharakan(at)gmail(dot)com
>> PostgreSQL version: 15.1
>> Operating system: Ubuntu 20.04
>> Description:
>>
>> This assert() is not easily reproducible, but thought may be of interest.
>> Can provide full backtrace, if required.
>>
>> Git: 253432f426(at)master
>> OS: Ubuntu 20.04
>>
>> TRAP: failed Assert("j->jointype == JOIN_INNER"), File: "initsplan.c",
>> Line:
>> 1206, PID: 3285978
>
>
> Thanks for the report! I can reproduce this issue with the following
> query.
>
> create table t1(a int);
> create table t2(a int);
> create table t3(a int);
> create table t4(a int);
> create table t5(a int);
>
> select * from t1, lateral (select * from t2 inner join t3 on t1.a = 1
> inner join (t4 right join t5 on true) on true) as sub;
>
> There is something wrong about postponing quals. We are supposed to
> postpone quals only from children to their parent nodes. But here in
> deconstruct_distribute we scan all the jointree nodes in depth-first
> traversal order and any quals postponed by left children may be checked
> against right children. If the right subtree is an outer join as in
> this example, the assertion would be triggered.
>

To fix this issue, I'm considering that we can add two types of info in
JoinTreeItem for each jointree node, one is the jointree's children, and
one is the list of quals that need to be postponed at this join level.
Thus in deconstruct_distribute we can process the quals postponed by
children.

Attach a draft patch (with no tests, no comments, no formats yet) to
show what I'm thinking.

Thanks
Richard

Attachment Content-Type Size
v1-0001-Draft-patch-to-fix-postponed-quals.patch application/octet-stream 8.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-02-02 18:18:54 BUG #17770: SELECT FOR UPDATE on a UNION ALL view doesn't raise an error
Previous Message PG Bug reporting form 2023-02-02 11:56:16 BUG #17769: Assert triggered in indxpath.c