mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Allow merge and hash joins to occur on arbitrary expressions (anything not
containing a volatile function), rather than only on 'Var = Var' clauses as before. This makes it practical to do flatten_join_alias_vars at the start of planning, which in turn eliminates a bunch of klugery inside the planner to deal with alias vars. As a free side effect, we now detect implied equality of non-Var expressions; for example in SELECT ... WHERE a.x = b.y and b.y = 42 we will deduce a.x = 42 and use that as a restriction qual on a. Also, we can remove the restriction introduced 12/5/02 to prevent pullup of subqueries whose targetlists contain sublinks. Still TODO: make statistical estimation routines in selfuncs.c and costsize.c smarter about expressions that are more complex than plain Vars. The need for this is considerably greater now that we have to be able to estimate the suitability of merge and hash join techniques on such expressions.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: clauses.h,v 1.58 2002/12/14 00:17:59 tgl Exp $
|
||||
* $Id: clauses.h,v 1.59 2003/01/15 19:35:47 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -25,8 +25,8 @@
|
||||
|
||||
extern Expr *make_opclause(Oid opno, Oid opresulttype, bool opretset,
|
||||
Expr *leftop, Expr *rightop);
|
||||
extern Var *get_leftop(Expr *clause);
|
||||
extern Var *get_rightop(Expr *clause);
|
||||
extern Node *get_leftop(Expr *clause);
|
||||
extern Node *get_rightop(Expr *clause);
|
||||
|
||||
extern Expr *make_funcclause(Oid funcid, Oid funcresulttype, bool funcretset,
|
||||
CoercionForm funcformat, List *funcargs);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pathnode.h,v 1.46 2002/11/30 05:21:03 tgl Exp $
|
||||
* $Id: pathnode.h,v 1.47 2003/01/15 19:35:47 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -74,8 +74,6 @@ extern HashPath *create_hashjoin_path(Query *root,
|
||||
extern void build_base_rel(Query *root, int relid);
|
||||
extern RelOptInfo *build_other_rel(Query *root, int relid);
|
||||
extern RelOptInfo *find_base_rel(Query *root, int relid);
|
||||
extern RelOptInfo *find_other_rel(Query *root, int relid);
|
||||
extern RelOptInfo *find_other_rel_for_join(Query *root, List *relids);
|
||||
extern RelOptInfo *build_join_rel(Query *root,
|
||||
RelOptInfo *outer_rel,
|
||||
RelOptInfo *inner_rel,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: planmain.h,v 1.64 2002/12/12 15:49:41 tgl Exp $
|
||||
* $Id: planmain.h,v 1.65 2003/01/15 19:35:47 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -32,8 +32,6 @@ extern SubqueryScan *make_subqueryscan(List *qptlist, List *qpqual,
|
||||
extern Append *make_append(List *appendplans, bool isTarget, List *tlist);
|
||||
extern Sort *make_sort(Query *root, List *tlist,
|
||||
Plan *lefttree, int keycount);
|
||||
extern Sort *make_sort_from_pathkeys(Query *root, List *tlist,
|
||||
Plan *lefttree, List *pathkeys);
|
||||
extern Agg *make_agg(Query *root, List *tlist, List *qual,
|
||||
AggStrategy aggstrategy,
|
||||
int numGroupCols, AttrNumber *grpColIdx,
|
||||
@@ -54,12 +52,12 @@ extern Result *make_result(List *tlist, Node *resconstantqual, Plan *subplan);
|
||||
/*
|
||||
* prototypes for plan/initsplan.c
|
||||
*/
|
||||
extern List *add_base_rels_to_query(Query *root, Node *jtnode);
|
||||
extern void add_base_rels_to_query(Query *root, Node *jtnode);
|
||||
extern void build_base_rel_tlists(Query *root, List *tlist);
|
||||
extern Relids distribute_quals_to_rels(Query *root, Node *jtnode);
|
||||
extern void process_implied_equality(Query *root, Node *item1, Node *item2,
|
||||
Oid sortop1, Oid sortop2);
|
||||
extern bool vars_known_equal(Query *root, Var *var1, Var *var2);
|
||||
extern bool exprs_known_equal(Query *root, Node *item1, Node *item2);
|
||||
|
||||
/*
|
||||
* prototypes for plan/setrefs.c
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: var.h,v 1.23 2002/12/12 20:35:16 tgl Exp $
|
||||
* $Id: var.h,v 1.24 2003/01/15 19:35:47 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -23,6 +23,6 @@ extern bool contain_var_reference(Node *node, int varno, int varattno,
|
||||
extern bool contain_whole_tuple_var(Node *node, int varno, int levelsup);
|
||||
extern bool contain_var_clause(Node *node);
|
||||
extern List *pull_var_clause(Node *node, bool includeUpperVars);
|
||||
extern Node *flatten_join_alias_vars(Node *node, List *rtable, bool force);
|
||||
extern Node *flatten_join_alias_vars(Node *node, List *rtable);
|
||||
|
||||
#endif /* VAR_H */
|
||||
|
||||
Reference in New Issue
Block a user