Commit f003a752 authored by Tom Lane's avatar Tom Lane

Remove [Merge]AppendPath.partitioned_rels.

It turns out that the calculation of [Merge]AppendPath.partitioned_rels
in allpaths.c is faulty and sometimes omits relevant non-leaf partitions,
allowing an assertion added by commit a929e17e to trigger.  Rather
than fix that, it seems better to get rid of those fields altogether.
We don't really need the info until create_plan time, and calculating
it once for the selected plan should be cheaper than calculating it
for each append path we consider.

The preceding two commits did away with all use of the partitioned_rels
values; this commit just mechanically removes the fields and the code
that calculated them.

Discussion: https://postgr.es/m/87sg8tqhsl.fsf@aurora.ydns.eu
Discussion: https://postgr.es/m/CAJKUy5gCXDSmFs2c=R+VGgn7FiYcLCsEFEuDNNLGfoha=pBE_g@mail.gmail.com
parent 5076f88b
......@@ -1871,7 +1871,6 @@ _outAppendPath(StringInfo str, const AppendPath *node)
_outPathInfo(str, (const Path *) node);
WRITE_NODE_FIELD(partitioned_rels);
WRITE_NODE_FIELD(subpaths);
WRITE_INT_FIELD(first_partial_path);
WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
......@@ -1884,7 +1883,6 @@ _outMergeAppendPath(StringInfo str, const MergeAppendPath *node)
_outPathInfo(str, (const Path *) node);
WRITE_NODE_FIELD(partitioned_rels);
WRITE_NODE_FIELD(subpaths);
WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
}
......
This diff is collapsed.
......@@ -1279,7 +1279,7 @@ mark_dummy_rel(RelOptInfo *rel)
/* Set up the dummy path */
add_path(rel, (Path *) create_append_path(NULL, rel, NIL, NIL,
NIL, rel->lateral_relids,
0, false, NIL, -1));
0, false, -1));
/* Set or update cheapest_total_path and related fields */
set_cheapest(rel);
......
......@@ -1248,7 +1248,6 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags)
partpruneinfo =
make_partition_pruneinfo(root, rel,
best_path->subpaths,
best_path->partitioned_rels,
prunequal);
}
......@@ -1412,7 +1411,6 @@ create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path,
if (prunequal != NIL)
partpruneinfo = make_partition_pruneinfo(root, rel,
best_path->subpaths,
best_path->partitioned_rels,
prunequal);
}
......
......@@ -1726,7 +1726,7 @@ inheritance_planner(PlannerInfo *root)
/* Make a dummy path, cf set_dummy_rel_pathlist() */
dummy_path = (Path *) create_append_path(NULL, final_rel, NIL, NIL,
NIL, NULL, 0, false,
NIL, -1);
-1);
/* These lists must be nonempty to make a valid ModifyTable node */
subpaths = list_make1(dummy_path);
......@@ -4006,7 +4006,6 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
NULL,
0,
false,
NIL,
-1);
}
else
......
......@@ -620,7 +620,7 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root,
* Append the child results together.
*/
path = (Path *) create_append_path(root, result_rel, pathlist, NIL,
NIL, NULL, 0, false, NIL, -1);
NIL, NULL, 0, false, -1);
/*
* For UNION ALL, we just need the Append path. For UNION, need to add
......@@ -677,7 +677,7 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root,
create_append_path(root, result_rel, NIL, partial_pathlist,
NIL, NULL,
parallel_workers, enable_parallel_append,
NIL, -1);
-1);
ppath = (Path *)
create_gather_path(root, result_rel, ppath,
result_rel->reltarget, NULL, NULL);
......@@ -787,7 +787,7 @@ generate_nonunion_paths(SetOperationStmt *op, PlannerInfo *root,
* Append the child results together.
*/
path = (Path *) create_append_path(root, result_rel, pathlist, NIL,
NIL, NULL, 0, false, NIL, -1);
NIL, NULL, 0, false, -1);
/* Identify the grouping semantics */
groupList = generate_setop_grouplist(op, tlist);
......
......@@ -1217,7 +1217,7 @@ create_append_path(PlannerInfo *root,
List *subpaths, List *partial_subpaths,
List *pathkeys, Relids required_outer,
int parallel_workers, bool parallel_aware,
List *partitioned_rels, double rows)
double rows)
{
AppendPath *pathnode = makeNode(AppendPath);
ListCell *l;
......@@ -1249,7 +1249,6 @@ create_append_path(PlannerInfo *root,
pathnode->path.parallel_safe = rel->consider_parallel;
pathnode->path.parallel_workers = parallel_workers;
pathnode->path.pathkeys = pathkeys;
pathnode->partitioned_rels = list_copy(partitioned_rels);
/*
* For parallel append, non-partial paths are sorted by descending total
......@@ -1377,8 +1376,7 @@ create_merge_append_path(PlannerInfo *root,
RelOptInfo *rel,
List *subpaths,
List *pathkeys,
Relids required_outer,
List *partitioned_rels)
Relids required_outer)
{
MergeAppendPath *pathnode = makeNode(MergeAppendPath);
Cost input_startup_cost;
......@@ -1394,7 +1392,6 @@ create_merge_append_path(PlannerInfo *root,
pathnode->path.parallel_safe = rel->consider_parallel;
pathnode->path.parallel_workers = 0;
pathnode->path.pathkeys = pathkeys;
pathnode->partitioned_rels = list_copy(partitioned_rels);
pathnode->subpaths = subpaths;
/*
......@@ -3847,7 +3844,6 @@ reparameterize_path(PlannerInfo *root, Path *path,
apath->path.pathkeys, required_outer,
apath->path.parallel_workers,
apath->path.parallel_aware,
apath->partitioned_rels,
-1);
}
default:
......
......@@ -220,7 +220,7 @@ static void partkey_datum_from_expr(PartitionPruneContext *context,
*/
PartitionPruneInfo *
make_partition_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel,
List *subpaths, List *unused_partitioned_rels,
List *subpaths,
List *prunequal)
{
PartitionPruneInfo *pruneinfo;
......
......@@ -1403,9 +1403,6 @@ typedef struct CustomPath
typedef struct AppendPath
{
Path path;
List *partitioned_rels; /* List of Relids containing RT indexes of
* non-leaf tables for each partition
* hierarchy whose paths are in 'subpaths' */
List *subpaths; /* list of component Paths */
/* Index of first partial path in subpaths; list_length(subpaths) if none */
int first_partial_path;
......@@ -1430,9 +1427,6 @@ extern bool is_dummy_rel(RelOptInfo *rel);
typedef struct MergeAppendPath
{
Path path;
List *partitioned_rels; /* List of Relids containing RT indexes of
* non-leaf tables for each partition
* hierarchy whose paths are in 'subpaths' */
List *subpaths; /* list of component Paths */
double limit_tuples; /* hard limit on output tuples, or -1 */
} MergeAppendPath;
......
......@@ -67,13 +67,12 @@ extern AppendPath *create_append_path(PlannerInfo *root, RelOptInfo *rel,
List *subpaths, List *partial_subpaths,
List *pathkeys, Relids required_outer,
int parallel_workers, bool parallel_aware,
List *partitioned_rels, double rows);
double rows);
extern MergeAppendPath *create_merge_append_path(PlannerInfo *root,
RelOptInfo *rel,
List *subpaths,
List *pathkeys,
Relids required_outer,
List *partitioned_rels);
Relids required_outer);
extern GroupResultPath *create_group_result_path(PlannerInfo *root,
RelOptInfo *rel,
PathTarget *target,
......
......@@ -71,7 +71,6 @@ typedef struct PartitionPruneContext
extern PartitionPruneInfo *make_partition_pruneinfo(struct PlannerInfo *root,
struct RelOptInfo *parentrel,
List *subpaths,
List *partitioned_rels,
List *prunequal);
extern Bitmapset *prune_append_rel_partitions(struct RelOptInfo *rel);
extern Bitmapset *get_matching_partitions(PartitionPruneContext *context,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment