* build_join_rel * Returns relation entry corresponding to the union of two given rels, * creating a new relation entry if none already exists. * * 'joinrelids' is the Relids set that uniquely identifies the join * 'outer_rel' and 'inner_rel' are relation nodes for the relations to be * joined * 'sjinfo': join context info * 'restrictlist_ptr': result variable. If not NULL, *restrict
| 974 | * duplicated calculation of the restrictlist... |
| 975 | */ |
| 976 | RelOptInfo * |
| 977 | build_join_rel(PlannerInfo *root, |
| 978 | Relids joinrelids, |
| 979 | RelOptInfo *outer_rel, |
| 980 | RelOptInfo *inner_rel, |
| 981 | SpecialJoinInfo *sjinfo, |
| 982 | List **restrictlist_ptr, |
| 983 | RelAggInfo *agg_info) |
| 984 | { |
| 985 | RelOptInfo *joinrel; |
| 986 | List *restrictlist; |
| 987 | bool grouped = agg_info != NULL; |
| 988 | |
| 989 | /* This function should be used only for join between parents. */ |
| 990 | Assert(!IS_OTHER_REL(outer_rel) && !IS_OTHER_REL(inner_rel)); |
| 991 | |
| 992 | /* |
| 993 | * See if we already have a joinrel for this set of base rels. |
| 994 | * |
| 995 | * NB: We only call this function to build a grouped relation when it does |
| 996 | * not exist, so we won't try to find here. |
| 997 | */ |
| 998 | joinrel = !grouped ? find_join_rel(root, joinrelids) : NULL; |
| 999 | |
| 1000 | if (joinrel) |
| 1001 | { |
| 1002 | /* |
| 1003 | * Yes, so we only need to figure the restrictlist for this particular |
| 1004 | * pair of component relations. |
| 1005 | */ |
| 1006 | if (restrictlist_ptr) |
| 1007 | *restrictlist_ptr = build_joinrel_restrictlist(root, |
| 1008 | joinrel, |
| 1009 | outer_rel, |
| 1010 | inner_rel); |
| 1011 | |
| 1012 | return joinrel; |
| 1013 | } |
| 1014 | |
| 1015 | /* |
| 1016 | * Nope, so make one. |
| 1017 | */ |
| 1018 | joinrel = makeNode(RelOptInfo); |
| 1019 | joinrel->reloptkind = RELOPT_JOINREL; |
| 1020 | joinrel->relids = bms_copy(joinrelids); |
| 1021 | joinrel->rows = 0; |
| 1022 | /* cheap startup cost is interesting iff not all tuples to be retrieved */ |
| 1023 | joinrel->consider_startup = (root->tuple_fraction > 0); |
| 1024 | joinrel->consider_param_startup = false; |
| 1025 | joinrel->consider_parallel = false; |
| 1026 | joinrel->reltarget = create_empty_pathtarget(); |
| 1027 | joinrel->pathlist = NIL; |
| 1028 | joinrel->ppilist = NIL; |
| 1029 | joinrel->partial_pathlist = NIL; |
| 1030 | joinrel->cheapest_startup_path = NULL; |
| 1031 | joinrel->cheapest_total_path = NULL; |
| 1032 | joinrel->cheapest_unique_path = NULL; |
| 1033 | joinrel->cheapest_parameterized_paths = NIL; |
no test coverage detected