Re: BUG #15613: Bug in PG Planner for Foreign Data Wrappers
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>
Cc: srinivasan.sa@zohocorp.com, pgsql-bugs@lists.postgresql.org
Date: 2019-01-30T16:25:57Z
Lists: pgsql-bugs
Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp> writes: > (2019/01/30 18:46), PG Bug reporting form wrote: >> Foreign scan of a table (part of join), has a column of another table >> involved in its qual. > I haven't looked into this in details yet, but do you have this issue in > the latest release of 9.6 (ie 9.6.11), not in 9.6.3? I just thought > this might have been fixed already by commits [1][2]. Nope, cause it's still there in HEAD :-(. What I'm wondering is why the ref_0.t1_col2 IS NOT NULL condition is being pushed down to the ref_1 scan in the first place, rather than ref_0 where you'd think it should go. Yes, this plan shape could have been made to work if the Var reference had been converted to a NestLoopParam reference, but it wasn't. So there are a few interesting questions here: * Why was the IS NOT NULL pushed down to the wrong place? * Having made that mistake, why didn't the NLP mechanism fix it and create a valid plan anyway? * I find that s/RIGHT JOIN/JOIN/ makes the problem go away: the IS NOT NULL is pushed to the right place and there's no error. This is even weirder, because the planner successfully simplifies the outer join to a plain join on its own, and you'd think that that would happen before any mistake that could cause the other two problems. Join strength reduction runs before distribute_qual_to_rels, so how's that happening? Probably the answers to these questions are interrelated and there's only one bug at bottom. But maybe not. I've not really dug into it yet. regards, tom lane
Commits
-
Ensure that foreign scans with lateral refs are planned correctly.
- 1eeee69099e0 9.5.16 landed
- d468da0d6590 9.6.12 landed
- e3101a0317a9 10.7 landed
- 9d6d2b21343d 11.2 landed
- 876fd37fc812 9.4.21 landed
-
Split create_foreignscan_path() into three functions.
- 34ea1ab7fd30 12.0 landed
-
Change more places to be less trusting of RestrictInfo.is_pushed_down.
- c792c7db4146 11.0 cited
-
Remove quick path in ExecInitPartitionInfo for equal tupdescs
- 79b2e52615fa 11.0 cited