mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Restructure handling of inheritance queries so that they work with outer
joins, and clean things up a good deal at the same time. Append plan node no longer hacks on rangetable at runtime --- instead, all child tables are given their own RT entries during planning. Concept of multiple target tables pushed up into execMain, replacing bug-prone implementation within nodeAppend. Planner now supports generating Append plans for inheritance sets either at the top of the plan (the old way) or at the bottom. Expanding at the bottom is appropriate for tables used as sources, since they may appear inside an outer join; but we must still expand at the top when the target of an UPDATE or DELETE is an inheritance set, because we actually need a different targetlist and junkfilter for each target table in that case. Fortunately a target table can't be inside an outer join... Bizarre mutual recursion between union_planner and prepunion.c is gone --- in fact, union_planner doesn't really have much to do with union queries anymore, so I renamed it grouping_planner.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pathnode.h,v 1.30 2000/10/05 19:48:33 momjian Exp $
|
||||
* $Id: pathnode.h,v 1.31 2000/11/12 00:37:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -32,6 +32,7 @@ extern IndexPath *create_index_path(Query *root, RelOptInfo *rel,
|
||||
List *restriction_clauses,
|
||||
ScanDirection indexscandir);
|
||||
extern TidPath *create_tidscan_path(RelOptInfo *rel, List *tideval);
|
||||
extern AppendPath *create_append_path(RelOptInfo *rel, List *subpaths);
|
||||
extern Path *create_subqueryscan_path(RelOptInfo *rel);
|
||||
|
||||
extern NestPath *create_nestloop_path(RelOptInfo *joinrel,
|
||||
@@ -63,6 +64,7 @@ extern HashPath *create_hashjoin_path(RelOptInfo *joinrel,
|
||||
* prototypes for relnode.c
|
||||
*/
|
||||
extern RelOptInfo *get_base_rel(Query *root, int relid);
|
||||
extern RelOptInfo *make_base_rel(Query *root, int relid);
|
||||
extern RelOptInfo *get_join_rel(Query *root, RelOptInfo *outer_rel,
|
||||
RelOptInfo *inner_rel,
|
||||
List **restrictlist_ptr);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: planmain.h,v 1.47 2000/10/26 21:38:24 tgl Exp $
|
||||
* $Id: planmain.h,v 1.48 2000/11/12 00:37:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -28,6 +28,7 @@ extern Plan *query_planner(Query *root, List *tlist, double tuple_fraction);
|
||||
extern Plan *create_plan(Query *root, Path *best_path);
|
||||
extern SubqueryScan *make_subqueryscan(List *qptlist, List *qpqual,
|
||||
Index scanrelid, Plan *subplan);
|
||||
extern Append *make_append(List *appendplans, bool isTarget, List *tlist);
|
||||
extern Sort *make_sort(List *tlist, Plan *lefttree, int keycount);
|
||||
extern Sort *make_sort_from_pathkeys(List *tlist, Plan *lefttree,
|
||||
List *pathkeys);
|
||||
@@ -41,7 +42,6 @@ extern Limit *make_limit(List *tlist, Plan *lefttree,
|
||||
extern SetOp *make_setop(SetOpCmd cmd, List *tlist, Plan *lefttree,
|
||||
List *distinctList, AttrNumber flagColIdx);
|
||||
extern Result *make_result(List *tlist, Node *resconstantqual, Plan *subplan);
|
||||
extern void copy_plan_costsize(Plan *dest, Plan *src);
|
||||
|
||||
/*
|
||||
* prototypes for plan/initsplan.c
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: planner.h,v 1.17 2000/10/05 19:11:37 tgl Exp $
|
||||
* $Id: planner.h,v 1.18 2000/11/12 00:37:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
extern Plan *planner(Query *parse);
|
||||
extern Plan *subquery_planner(Query *parse, double tuple_fraction);
|
||||
extern Plan *union_planner(Query *parse, double tuple_fraction);
|
||||
|
||||
extern Plan *make_sortplan(List *tlist, Plan *plannode, List *sortcls);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: prep.h,v 1.24 2000/10/05 19:11:37 tgl Exp $
|
||||
* $Id: prep.h,v 1.25 2000/11/12 00:37:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -33,10 +33,12 @@ extern List *preprocess_targetlist(List *tlist, int command_type,
|
||||
* prototypes for prepunion.c
|
||||
*/
|
||||
extern Plan *plan_set_operations(Query *parse);
|
||||
|
||||
extern List *find_all_inheritors(Oid parentrel);
|
||||
extern bool find_inheritable_rt_entry(List *rangetable,
|
||||
Index *rt_index, List **inheritors);
|
||||
extern Plan *plan_inherit_queries(Query *root, List *tlist,
|
||||
Index rt_index, List *inheritors);
|
||||
extern List *expand_inherted_rtentry(Query *parse, Index rti);
|
||||
|
||||
extern Node *adjust_inherited_attrs(Node *node,
|
||||
Index old_rt_index, Oid old_relid,
|
||||
Index new_rt_index, Oid new_relid);
|
||||
|
||||
#endif /* PREP_H */
|
||||
|
||||
Reference in New Issue
Block a user