diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-08-26 22:48:55 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-08-26 22:50:23 -0400 |
commit | 9ff79b9d4e71822a875c0f5e38f5ec86c7fb079f (patch) | |
tree | 54ca663a626498195754d48a9b4d2c545210381d /src/include/optimizer/pathnode.h | |
parent | de87d4704432e98a327dbf42dbc4711fa2628a9c (diff) | |
download | postgresql-9ff79b9d4e71822a875c0f5e38f5ec86c7fb079f.tar.gz postgresql-9ff79b9d4e71822a875c0f5e38f5ec86c7fb079f.zip |
Fix up planner infrastructure to support LATERAL properly.
This patch takes care of a number of problems having to do with failure
to choose valid join orders and incorrect handling of lateral references
pulled up from subqueries. Notable changes:
* Add a LateralJoinInfo data structure similar to SpecialJoinInfo, to
represent join ordering constraints created by lateral references.
(I first considered extending the SpecialJoinInfo structure, but the
semantics are different enough that a separate data structure seems
better.) Extend join_is_legal() and related functions to prevent trying
to form unworkable joins, and to ensure that we will consider joins that
satisfy lateral references even if the joins would be clauseless.
* Fill in the infrastructure needed for the last few types of relation scan
paths to support parameterization. We'd have wanted this eventually
anyway, but it is necessary now because a relation that gets pulled up out
of a UNION ALL subquery may acquire a reltargetlist containing lateral
references, meaning that its paths *have* to be parameterized whether or
not we have any code that can push join quals down into the scan.
* Compute data about lateral references early in query_planner(), and save
in RelOptInfo nodes, to avoid repetitive calculations later.
* Assorted corner-case bug fixes.
There's probably still some bugs left, but this is a lot closer to being
real than it was before.
Diffstat (limited to 'src/include/optimizer/pathnode.h')
-rw-r--r-- | src/include/optimizer/pathnode.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index 33f2bf13c09..de889fbfa68 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -55,7 +55,7 @@ extern BitmapOrPath *create_bitmap_or_path(PlannerInfo *root, RelOptInfo *rel, List *bitmapquals); extern TidPath *create_tidscan_path(PlannerInfo *root, RelOptInfo *rel, - List *tidquals); + List *tidquals, Relids required_outer); extern AppendPath *create_append_path(RelOptInfo *rel, List *subpaths, Relids required_outer); extern MergeAppendPath *create_merge_append_path(PlannerInfo *root, @@ -73,8 +73,10 @@ extern Path *create_functionscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer); extern Path *create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer); -extern Path *create_ctescan_path(PlannerInfo *root, RelOptInfo *rel); -extern Path *create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel); +extern Path *create_ctescan_path(PlannerInfo *root, RelOptInfo *rel, + Relids required_outer); +extern Path *create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel, + Relids required_outer); extern ForeignPath *create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel, double rows, Cost startup_cost, Cost total_cost, List *pathkeys, |