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) ...@@ -1871,7 +1871,6 @@ _outAppendPath(StringInfo str, const AppendPath *node)
_outPathInfo(str, (const Path *) node); _outPathInfo(str, (const Path *) node);
WRITE_NODE_FIELD(partitioned_rels);
WRITE_NODE_FIELD(subpaths); WRITE_NODE_FIELD(subpaths);
WRITE_INT_FIELD(first_partial_path); WRITE_INT_FIELD(first_partial_path);
WRITE_FLOAT_FIELD(limit_tuples, "%.0f"); WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
...@@ -1884,7 +1883,6 @@ _outMergeAppendPath(StringInfo str, const MergeAppendPath *node) ...@@ -1884,7 +1883,6 @@ _outMergeAppendPath(StringInfo str, const MergeAppendPath *node)
_outPathInfo(str, (const Path *) node); _outPathInfo(str, (const Path *) node);
WRITE_NODE_FIELD(partitioned_rels);
WRITE_NODE_FIELD(subpaths); WRITE_NODE_FIELD(subpaths);
WRITE_FLOAT_FIELD(limit_tuples, "%.0f"); WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
} }
......
This diff is collapsed.
...@@ -1279,7 +1279,7 @@ mark_dummy_rel(RelOptInfo *rel) ...@@ -1279,7 +1279,7 @@ mark_dummy_rel(RelOptInfo *rel)
/* Set up the dummy path */ /* Set up the dummy path */
add_path(rel, (Path *) create_append_path(NULL, rel, NIL, NIL, add_path(rel, (Path *) create_append_path(NULL, rel, NIL, NIL,
NIL, rel->lateral_relids, NIL, rel->lateral_relids,
0, false, NIL, -1)); 0, false, -1));
/* Set or update cheapest_total_path and related fields */ /* Set or update cheapest_total_path and related fields */
set_cheapest(rel); set_cheapest(rel);
......
...@@ -1248,7 +1248,6 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags) ...@@ -1248,7 +1248,6 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags)
partpruneinfo = partpruneinfo =
make_partition_pruneinfo(root, rel, make_partition_pruneinfo(root, rel,
best_path->subpaths, best_path->subpaths,
best_path->partitioned_rels,
prunequal); prunequal);
} }
...@@ -1412,7 +1411,6 @@ create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path, ...@@ -1412,7 +1411,6 @@ create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path,
if (prunequal != NIL) if (prunequal != NIL)
partpruneinfo = make_partition_pruneinfo(root, rel, partpruneinfo = make_partition_pruneinfo(root, rel,
best_path->subpaths, best_path->subpaths,
best_path->partitioned_rels,
prunequal); prunequal);
} }
......
...@@ -1726,7 +1726,7 @@ inheritance_planner(PlannerInfo *root) ...@@ -1726,7 +1726,7 @@ inheritance_planner(PlannerInfo *root)
/* Make a dummy path, cf set_dummy_rel_pathlist() */ /* Make a dummy path, cf set_dummy_rel_pathlist() */
dummy_path = (Path *) create_append_path(NULL, final_rel, NIL, NIL, dummy_path = (Path *) create_append_path(NULL, final_rel, NIL, NIL,
NIL, NULL, 0, false, NIL, NULL, 0, false,
NIL, -1); -1);
/* These lists must be nonempty to make a valid ModifyTable node */ /* These lists must be nonempty to make a valid ModifyTable node */
subpaths = list_make1(dummy_path); subpaths = list_make1(dummy_path);
...@@ -4006,7 +4006,6 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -4006,7 +4006,6 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
NULL, NULL,
0, 0,
false, false,
NIL,
-1); -1);
} }
else else
......
...@@ -620,7 +620,7 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root, ...@@ -620,7 +620,7 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root,
* Append the child results together. * Append the child results together.
*/ */
path = (Path *) create_append_path(root, result_rel, pathlist, NIL, 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 * 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, ...@@ -677,7 +677,7 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root,
create_append_path(root, result_rel, NIL, partial_pathlist, create_append_path(root, result_rel, NIL, partial_pathlist,
NIL, NULL, NIL, NULL,
parallel_workers, enable_parallel_append, parallel_workers, enable_parallel_append,
NIL, -1); -1);
ppath = (Path *) ppath = (Path *)
create_gather_path(root, result_rel, ppath, create_gather_path(root, result_rel, ppath,
result_rel->reltarget, NULL, NULL); result_rel->reltarget, NULL, NULL);
...@@ -787,7 +787,7 @@ generate_nonunion_paths(SetOperationStmt *op, PlannerInfo *root, ...@@ -787,7 +787,7 @@ generate_nonunion_paths(SetOperationStmt *op, PlannerInfo *root,
* Append the child results together. * Append the child results together.
*/ */
path = (Path *) create_append_path(root, result_rel, pathlist, NIL, 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 */ /* Identify the grouping semantics */
groupList = generate_setop_grouplist(op, tlist); groupList = generate_setop_grouplist(op, tlist);
......
...@@ -1217,7 +1217,7 @@ create_append_path(PlannerInfo *root, ...@@ -1217,7 +1217,7 @@ create_append_path(PlannerInfo *root,
List *subpaths, List *partial_subpaths, List *subpaths, List *partial_subpaths,
List *pathkeys, Relids required_outer, List *pathkeys, Relids required_outer,
int parallel_workers, bool parallel_aware, int parallel_workers, bool parallel_aware,
List *partitioned_rels, double rows) double rows)
{ {
AppendPath *pathnode = makeNode(AppendPath); AppendPath *pathnode = makeNode(AppendPath);
ListCell *l; ListCell *l;
...@@ -1249,7 +1249,6 @@ create_append_path(PlannerInfo *root, ...@@ -1249,7 +1249,6 @@ create_append_path(PlannerInfo *root,
pathnode->path.parallel_safe = rel->consider_parallel; pathnode->path.parallel_safe = rel->consider_parallel;
pathnode->path.parallel_workers = parallel_workers; pathnode->path.parallel_workers = parallel_workers;
pathnode->path.pathkeys = pathkeys; pathnode->path.pathkeys = pathkeys;
pathnode->partitioned_rels = list_copy(partitioned_rels);
/* /*
* For parallel append, non-partial paths are sorted by descending total * For parallel append, non-partial paths are sorted by descending total
...@@ -1377,8 +1376,7 @@ create_merge_append_path(PlannerInfo *root, ...@@ -1377,8 +1376,7 @@ create_merge_append_path(PlannerInfo *root,
RelOptInfo *rel, RelOptInfo *rel,
List *subpaths, List *subpaths,
List *pathkeys, List *pathkeys,
Relids required_outer, Relids required_outer)
List *partitioned_rels)
{ {
MergeAppendPath *pathnode = makeNode(MergeAppendPath); MergeAppendPath *pathnode = makeNode(MergeAppendPath);
Cost input_startup_cost; Cost input_startup_cost;
...@@ -1394,7 +1392,6 @@ create_merge_append_path(PlannerInfo *root, ...@@ -1394,7 +1392,6 @@ create_merge_append_path(PlannerInfo *root,
pathnode->path.parallel_safe = rel->consider_parallel; pathnode->path.parallel_safe = rel->consider_parallel;
pathnode->path.parallel_workers = 0; pathnode->path.parallel_workers = 0;
pathnode->path.pathkeys = pathkeys; pathnode->path.pathkeys = pathkeys;
pathnode->partitioned_rels = list_copy(partitioned_rels);
pathnode->subpaths = subpaths; pathnode->subpaths = subpaths;
/* /*
...@@ -3847,7 +3844,6 @@ reparameterize_path(PlannerInfo *root, Path *path, ...@@ -3847,7 +3844,6 @@ reparameterize_path(PlannerInfo *root, Path *path,
apath->path.pathkeys, required_outer, apath->path.pathkeys, required_outer,
apath->path.parallel_workers, apath->path.parallel_workers,
apath->path.parallel_aware, apath->path.parallel_aware,
apath->partitioned_rels,
-1); -1);
} }
default: default:
......
...@@ -220,7 +220,7 @@ static void partkey_datum_from_expr(PartitionPruneContext *context, ...@@ -220,7 +220,7 @@ static void partkey_datum_from_expr(PartitionPruneContext *context,
*/ */
PartitionPruneInfo * PartitionPruneInfo *
make_partition_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, make_partition_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel,
List *subpaths, List *unused_partitioned_rels, List *subpaths,
List *prunequal) List *prunequal)
{ {
PartitionPruneInfo *pruneinfo; PartitionPruneInfo *pruneinfo;
......
...@@ -1403,9 +1403,6 @@ typedef struct CustomPath ...@@ -1403,9 +1403,6 @@ typedef struct CustomPath
typedef struct AppendPath typedef struct AppendPath
{ {
Path path; 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 */ List *subpaths; /* list of component Paths */
/* Index of first partial path in subpaths; list_length(subpaths) if none */ /* Index of first partial path in subpaths; list_length(subpaths) if none */
int first_partial_path; int first_partial_path;
...@@ -1430,9 +1427,6 @@ extern bool is_dummy_rel(RelOptInfo *rel); ...@@ -1430,9 +1427,6 @@ extern bool is_dummy_rel(RelOptInfo *rel);
typedef struct MergeAppendPath typedef struct MergeAppendPath
{ {
Path path; 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 */ List *subpaths; /* list of component Paths */
double limit_tuples; /* hard limit on output tuples, or -1 */ double limit_tuples; /* hard limit on output tuples, or -1 */
} MergeAppendPath; } MergeAppendPath;
......
...@@ -67,13 +67,12 @@ extern AppendPath *create_append_path(PlannerInfo *root, RelOptInfo *rel, ...@@ -67,13 +67,12 @@ extern AppendPath *create_append_path(PlannerInfo *root, RelOptInfo *rel,
List *subpaths, List *partial_subpaths, List *subpaths, List *partial_subpaths,
List *pathkeys, Relids required_outer, List *pathkeys, Relids required_outer,
int parallel_workers, bool parallel_aware, int parallel_workers, bool parallel_aware,
List *partitioned_rels, double rows); double rows);
extern MergeAppendPath *create_merge_append_path(PlannerInfo *root, extern MergeAppendPath *create_merge_append_path(PlannerInfo *root,
RelOptInfo *rel, RelOptInfo *rel,
List *subpaths, List *subpaths,
List *pathkeys, List *pathkeys,
Relids required_outer, Relids required_outer);
List *partitioned_rels);
extern GroupResultPath *create_group_result_path(PlannerInfo *root, extern GroupResultPath *create_group_result_path(PlannerInfo *root,
RelOptInfo *rel, RelOptInfo *rel,
PathTarget *target, PathTarget *target,
......
...@@ -71,7 +71,6 @@ typedef struct PartitionPruneContext ...@@ -71,7 +71,6 @@ typedef struct PartitionPruneContext
extern PartitionPruneInfo *make_partition_pruneinfo(struct PlannerInfo *root, extern PartitionPruneInfo *make_partition_pruneinfo(struct PlannerInfo *root,
struct RelOptInfo *parentrel, struct RelOptInfo *parentrel,
List *subpaths, List *subpaths,
List *partitioned_rels,
List *prunequal); List *prunequal);
extern Bitmapset *prune_append_rel_partitions(struct RelOptInfo *rel); extern Bitmapset *prune_append_rel_partitions(struct RelOptInfo *rel);
extern Bitmapset *get_matching_partitions(PartitionPruneContext *context, 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