mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
Fix thinko in outer-join removal.
If we have a RestrictInfo that mentions both the removal-candidate relation and the outer join's relid, then that is a pushed-down condition not a join condition, so it should be grounds for deciding that we can't remove the outer join. In commit2489d76c4
, I'd blindly included the OJ's relid into "joinrelids" as per the new standard convention, but the checks of attr_needed and ph_needed should only allow the join's input rels to be mentioned. Having done that, the check for references in pushed-down quals a few lines further down should be redundant. I left it in place as an Assert, though. While researching this I happened across a couple of comments that worried about the effects of update_placeholder_eval_levels. That's gone as ofb448f1c8d
, so we can remove some worry. Per bug #17769 from Robins Tharakan. The submitted test case triggers this more or less accidentally because we flatten out a LATERAL sub-select after we've done join strength reduction; if we did that in the other order, this problem would be masked because the outer join would get simplified to an inner join. To ensure that the committed test case will continue to test what it means to even if we make that happen someday, use a test clause involving COALESCE(), which will prevent us from using it to do join strength reduction. Patch by me, but thanks to Richard Guo for initial investigation. Discussion: https://postgr.es/m/17769-e4f7a5c9d84a80a7@postgresql.org
This commit is contained in:
@ -494,9 +494,6 @@ extract_lateral_references(PlannerInfo *root, RelOptInfo *brel, Index rtindex)
|
||||
* create_lateral_join_info
|
||||
* Fill in the per-base-relation direct_lateral_relids, lateral_relids
|
||||
* and lateral_referencers sets.
|
||||
*
|
||||
* This has to run after deconstruct_jointree, because we need to know the
|
||||
* final ph_eval_at values for PlaceHolderVars.
|
||||
*/
|
||||
void
|
||||
create_lateral_join_info(PlannerInfo *root)
|
||||
@ -509,6 +506,9 @@ create_lateral_join_info(PlannerInfo *root)
|
||||
if (!root->hasLateralRTEs)
|
||||
return;
|
||||
|
||||
/* We'll need to have the ph_eval_at values for PlaceHolderVars */
|
||||
Assert(root->placeholdersFrozen);
|
||||
|
||||
/*
|
||||
* Examine all baserels (the rel array has been set up by now).
|
||||
*/
|
||||
|
Reference in New Issue
Block a user