diff options
Diffstat (limited to 'src/backend/optimizer/util/pathnode.c')
-rw-r--r-- | src/backend/optimizer/util/pathnode.c | 104 |
1 files changed, 46 insertions, 58 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index b1b7aca4a02..7673bed1a2d 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -1118,11 +1118,27 @@ create_bitmap_and_path(PlannerInfo *root, List *bitmapquals) { BitmapAndPath *pathnode = makeNode(BitmapAndPath); + Relids required_outer = NULL; + ListCell *lc; pathnode->path.pathtype = T_BitmapAnd; pathnode->path.parent = rel; pathnode->path.pathtarget = rel->reltarget; - pathnode->path.param_info = NULL; /* not used in bitmap trees */ + + /* + * Identify the required outer rels as the union of what the child paths + * depend on. (Alternatively, we could insist that the caller pass this + * in, but it's more convenient and reliable to compute it here.) + */ + foreach(lc, bitmapquals) + { + Path *bitmapqual = (Path *) lfirst(lc); + + required_outer = bms_add_members(required_outer, + PATH_REQ_OUTER(bitmapqual)); + } + pathnode->path.param_info = get_baserel_parampathinfo(root, rel, + required_outer); /* * Currently, a BitmapHeapPath, BitmapAndPath, or BitmapOrPath will be @@ -1154,11 +1170,27 @@ create_bitmap_or_path(PlannerInfo *root, List *bitmapquals) { BitmapOrPath *pathnode = makeNode(BitmapOrPath); + Relids required_outer = NULL; + ListCell *lc; pathnode->path.pathtype = T_BitmapOr; pathnode->path.parent = rel; pathnode->path.pathtarget = rel->reltarget; - pathnode->path.param_info = NULL; /* not used in bitmap trees */ + + /* + * Identify the required outer rels as the union of what the child paths + * depend on. (Alternatively, we could insist that the caller pass this + * in, but it's more convenient and reliable to compute it here.) + */ + foreach(lc, bitmapquals) + { + Path *bitmapqual = (Path *) lfirst(lc); + + required_outer = bms_add_members(required_outer, + PATH_REQ_OUTER(bitmapqual)); + } + pathnode->path.param_info = get_baserel_parampathinfo(root, rel, + required_outer); /* * Currently, a BitmapHeapPath, BitmapAndPath, or BitmapOrPath will be @@ -3686,7 +3718,18 @@ do { \ !bms_overlap(PATH_REQ_OUTER(path), child_rel->top_parent_relids)) return path; - /* Reparameterize a copy of given path. */ + /* + * If possible, reparameterize the given path, making a copy. + * + * This function is currently only applied to the inner side of a nestloop + * join that is being partitioned by the partitionwise-join code. Hence, + * we need only support path types that plausibly arise in that context. + * (In particular, supporting sorted path types would be a waste of code + * and cycles: even if we translated them here, they'd just lose in + * subsequent cost comparisons.) If we do see an unsupported path type, + * that just means we won't be able to generate a partitionwise-join plan + * using that path type. + */ switch (nodeTag(path)) { case T_Path: @@ -3734,20 +3777,6 @@ do { \ } break; - case T_TidPath: - { - TidPath *tpath; - - /* - * TidPath contains tidquals, which do not contain any - * external parameters per create_tidscan_path(). So don't - * bother to translate those. - */ - FLAT_COPY_PATH(tpath, path, TidPath); - new_path = (Path *) tpath; - } - break; - case T_ForeignPath: { ForeignPath *fpath; @@ -3838,37 +3867,6 @@ do { \ } break; - case T_MergeAppendPath: - { - MergeAppendPath *mapath; - - FLAT_COPY_PATH(mapath, path, MergeAppendPath); - REPARAMETERIZE_CHILD_PATH_LIST(mapath->subpaths); - new_path = (Path *) mapath; - } - break; - - case T_MaterialPath: - { - MaterialPath *mpath; - - FLAT_COPY_PATH(mpath, path, MaterialPath); - REPARAMETERIZE_CHILD_PATH(mpath->subpath); - new_path = (Path *) mpath; - } - break; - - case T_UniquePath: - { - UniquePath *upath; - - FLAT_COPY_PATH(upath, path, UniquePath); - REPARAMETERIZE_CHILD_PATH(upath->subpath); - ADJUST_CHILD_ATTRS(upath->uniq_exprs); - new_path = (Path *) upath; - } - break; - case T_GatherPath: { GatherPath *gpath; @@ -3879,16 +3877,6 @@ do { \ } break; - case T_GatherMergePath: - { - GatherMergePath *gmpath; - - FLAT_COPY_PATH(gmpath, path, GatherMergePath); - REPARAMETERIZE_CHILD_PATH(gmpath->subpath); - new_path = (Path *) gmpath; - } - break; - default: /* We don't know how to reparameterize this path. */ |