mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Prevent generation of bogus subquery scan paths.
Commit 0927d2f46d
didn't check that
consider_parallel was set for the target relation or account for
the possibility that required_outer might be non-empty.
To prevent future bugs of this ilk, add some assertions to
add_partial_path and do a bit of future-proofing of the code
recently added to recurse_set_operations.
Report by Andreas Seltenreich. Patch by Jeevan Chalke. Review
by Amit Kapila and by me.
Discussion: http://postgr.es/m/CAM2+6=U+9otsyF2fYB8x_2TBeHTR90itarqW=qAEjN-kHaC7kw@mail.gmail.com
This commit is contained in:
@ -2243,26 +2243,31 @@ set_subquery_pathlist(PlannerInfo *root, RelOptInfo *rel,
|
||||
pathkeys, required_outer));
|
||||
}
|
||||
|
||||
/* If consider_parallel is false, there should be no partial paths. */
|
||||
Assert(sub_final_rel->consider_parallel ||
|
||||
sub_final_rel->partial_pathlist == NIL);
|
||||
|
||||
/* Same for partial paths. */
|
||||
foreach(lc, sub_final_rel->partial_pathlist)
|
||||
/* If outer rel allows parallelism, do same for partial paths. */
|
||||
if (rel->consider_parallel && bms_is_empty(required_outer))
|
||||
{
|
||||
Path *subpath = (Path *) lfirst(lc);
|
||||
List *pathkeys;
|
||||
/* If consider_parallel is false, there should be no partial paths. */
|
||||
Assert(sub_final_rel->consider_parallel ||
|
||||
sub_final_rel->partial_pathlist == NIL);
|
||||
|
||||
/* Convert subpath's pathkeys to outer representation */
|
||||
pathkeys = convert_subquery_pathkeys(root,
|
||||
rel,
|
||||
subpath->pathkeys,
|
||||
make_tlist_from_pathtarget(subpath->pathtarget));
|
||||
/* Same for partial paths. */
|
||||
foreach(lc, sub_final_rel->partial_pathlist)
|
||||
{
|
||||
Path *subpath = (Path *) lfirst(lc);
|
||||
List *pathkeys;
|
||||
|
||||
/* Generate outer path using this subpath */
|
||||
add_partial_path(rel, (Path *)
|
||||
create_subqueryscan_path(root, rel, subpath,
|
||||
pathkeys, required_outer));
|
||||
/* Convert subpath's pathkeys to outer representation */
|
||||
pathkeys = convert_subquery_pathkeys(root,
|
||||
rel,
|
||||
subpath->pathkeys,
|
||||
make_tlist_from_pathtarget(subpath->pathtarget));
|
||||
|
||||
/* Generate outer path using this subpath */
|
||||
add_partial_path(rel, (Path *)
|
||||
create_subqueryscan_path(root, rel, subpath,
|
||||
pathkeys,
|
||||
required_outer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user