Re: BUG #17978: Unexpected error: "wrong varnullingrels (b) (expected (b 5)) for Var 6/2" triggered by JOIN
| От | Richard Guo |
|---|---|
| Тема | Re: BUG #17978: Unexpected error: "wrong varnullingrels (b) (expected (b 5)) for Var 6/2" triggered by JOIN |
| Дата | |
| Msg-id | CAMbWs48pMV0m6UathaqkUtrC=93TsikSPxQnKYun1+SoJxt0Yw@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: BUG #17978: Unexpected error: "wrong varnullingrels (b) (expected (b 5)) for Var 6/2" triggered by JOIN (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: BUG #17978: Unexpected error: "wrong varnullingrels (b) (expected (b 5)) for Var 6/2" triggered by JOIN
|
| Список | pgsql-bugs |
On Sun, Jun 18, 2023 at 3:57 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Temporarily disabling the setrefs.c crosscheck shows that it's
trying to create this plan:
which is the wrong join order: the filter condition can't be
applied at that join level. So the nullingrel cross-check
has caught a real bug, but why the bug?
FWIW, I found that we have an existing test query in sql/join.sql that
almost exposes this issue.
explain (costs off)
select * from int4_tbl t1
left join ((select t2.f1 from int4_tbl t2
left join int4_tbl t3 on t2.f1 > 0
where t3.f1 is null) s
left join tenk1 t4 on s.f1 > 1)
on s.f1 = t1.f1;
If we change the WHERE clause to 't2.f1 != coalesce(t3.f1, 1)', we will
see this issue.
explain (costs off)
select * from int4_tbl t1
left join ((select t2.f1 from int4_tbl t2
left join int4_tbl t3 on t2.f1 > 0
where t2.f1 != coalesce(t3.f1, 1)) s
left join tenk1 t4 on s.f1 > 1)
on s.f1 = t1.f1;
ERROR: wrong varnullingrels (b) (expected (b 5)) for Var 6/1
Thanks
Richard
almost exposes this issue.
explain (costs off)
select * from int4_tbl t1
left join ((select t2.f1 from int4_tbl t2
left join int4_tbl t3 on t2.f1 > 0
where t3.f1 is null) s
left join tenk1 t4 on s.f1 > 1)
on s.f1 = t1.f1;
If we change the WHERE clause to 't2.f1 != coalesce(t3.f1, 1)', we will
see this issue.
explain (costs off)
select * from int4_tbl t1
left join ((select t2.f1 from int4_tbl t2
left join int4_tbl t3 on t2.f1 > 0
where t2.f1 != coalesce(t3.f1, 1)) s
left join tenk1 t4 on s.f1 > 1)
on s.f1 = t1.f1;
ERROR: wrong varnullingrels (b) (expected (b 5)) for Var 6/1
Thanks
Richard
В списке pgsql-bugs по дате отправления: