Richard Guo <guofengli...@gmail.com> writes: > While wandering around the codes of reducing outer joins, I noticed that > when determining which base rels/Vars are forced nonnullable by given > clause, we don't take SubPlan into consideration. Does anyone happen to > know what is the concern behind that?
Probably just didn't bother with the case at the time. > IMO, for SubPlans of type ALL/ANY/ROWCOMPARE, we should be able to find > additional nonnullable rels/Vars by descending through their testexpr. I think you can make something of this, but you need to be a lot more paranoid than this patch is. * I don't believe you can prove anything from an ALL_SUBLINK SubPlan, because it will return true if the sub-query returns zero rows, no matter what the testexpr is. (Maybe if you could prove the sub-query does return a row, but I doubt it's worth going there.) * You need to explicitly check the subLinkType; as written this'll consider EXPR_SUBLINK and so on. I'm not really on board with assuming that nothing bad will happen with sublink types other than the ones the code is expecting. * It's not apparent to me that it's okay to pass down "top_level" rather than "false". Maybe it's all right, but it could do with a comment. regards, tom lane