* min_join_parameterization * * Determine the minimum possible parameterization of a joinrel, that is, the * set of other rels it contains LATERAL references to. We save this value in * the join's RelOptInfo. This function is split out of build_join_rel() * because join_is_legal() needs the value to check a prospective join. */
| 1365 | * because join_is_legal() needs the value to check a prospective join. |
| 1366 | */ |
| 1367 | Relids |
| 1368 | min_join_parameterization(PlannerInfo *root, |
| 1369 | Relids joinrelids, |
| 1370 | RelOptInfo *outer_rel, |
| 1371 | RelOptInfo *inner_rel) |
| 1372 | { |
| 1373 | Relids result; |
| 1374 | |
| 1375 | /* |
| 1376 | * Basically we just need the union of the inputs' lateral_relids, less |
| 1377 | * whatever is already in the join. |
| 1378 | * |
| 1379 | * It's not immediately obvious that this is a valid way to compute the |
| 1380 | * result, because it might seem that we're ignoring possible lateral refs |
| 1381 | * of PlaceHolderVars that are due to be computed at the join but not in |
| 1382 | * either input. However, because create_lateral_join_info() already |
| 1383 | * charged all such PHV refs to each member baserel of the join, they'll |
| 1384 | * be accounted for already in the inputs' lateral_relids. Likewise, we |
| 1385 | * do not need to worry about doing transitive closure here, because that |
| 1386 | * was already accounted for in the original baserel lateral_relids. |
| 1387 | */ |
| 1388 | result = bms_union(outer_rel->lateral_relids, inner_rel->lateral_relids); |
| 1389 | result = bms_del_members(result, joinrelids); |
| 1390 | |
| 1391 | /* Maintain invariant that result is exactly NULL if empty */ |
| 1392 | if (bms_is_empty(result)) |
| 1393 | result = NULL; |
| 1394 | |
| 1395 | return result; |
| 1396 | } |
| 1397 | |
| 1398 | /* |
| 1399 | * build_joinrel_tlist |
no test coverage detected