@@ -316,12 +316,8 @@ join_is_removable(PlannerInfo *root, SpecialJoinInfo *sjinfo)
316
316
* Remove the target relid from the planner's data structures, having
317
317
* determined that there is no need to include it in the query.
318
318
*
319
- * We are not terribly thorough here. We must make sure that the rel is
320
- * no longer treated as a baserel, and that attributes of other baserels
321
- * are no longer marked as being needed at joins involving this rel.
322
- * Also, join quals involving the rel have to be removed from the joininfo
323
- * lists, but only if they belong to the outer join identified by ojrelid
324
- * and joinrelids.
319
+ * We are not terribly thorough here. We only bother to update parts of
320
+ * the planner's data structures that will actually be consulted later.
325
321
*/
326
322
static void
327
323
remove_rel_from_query (PlannerInfo * root , int relid , int ojrelid ,
@@ -429,11 +425,18 @@ remove_rel_from_query(PlannerInfo *root, int relid, int ojrelid,
429
425
}
430
426
else
431
427
{
428
+ PlaceHolderVar * phv = phinfo -> ph_var ;
429
+
432
430
phinfo -> ph_eval_at = bms_del_member (phinfo -> ph_eval_at , relid );
433
431
phinfo -> ph_eval_at = bms_del_member (phinfo -> ph_eval_at , ojrelid );
434
- Assert (!bms_is_empty (phinfo -> ph_eval_at ));
432
+ Assert (!bms_is_empty (phinfo -> ph_eval_at )); /* checked previously */
435
433
phinfo -> ph_needed = bms_del_member (phinfo -> ph_needed , relid );
436
434
phinfo -> ph_needed = bms_del_member (phinfo -> ph_needed , ojrelid );
435
+ /* ph_needed might or might not become empty */
436
+ phv -> phrels = bms_del_member (phv -> phrels , relid );
437
+ phv -> phrels = bms_del_member (phv -> phrels , ojrelid );
438
+ Assert (!bms_is_empty (phv -> phrels ));
439
+ Assert (phv -> phnullingrels == NULL ); /* no need to adjust */
437
440
}
438
441
}
439
442
0 commit comments