mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Further planner/optimizer cleanups. Move all set_tlist_references
and fix_opids processing to a single recursive pass over the plan tree executed at the very tail end of planning, rather than haphazardly here and there at different places. Now that tlist Vars do not get modified until the very end, it's possible to get rid of the klugy var_equal and match_varid partial-matching routines, and just use plain equal() throughout the optimizer. This is a step towards allowing merge and hash joins to be done on expressions instead of only Vars ...
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: clauses.h,v 1.28 1999/08/16 02:17:44 tgl Exp $
|
||||
* $Id: clauses.h,v 1.29 1999/08/22 20:14:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,9 +38,13 @@ extern Expr *make_ands_explicit(List *andclauses);
|
||||
extern List *make_ands_implicit(Expr *clause);
|
||||
|
||||
extern List *pull_constant_clauses(List *quals, List **constantQual);
|
||||
extern List *pull_agg_clause(Node *clause);
|
||||
extern bool check_subplans_for_ungrouped_vars(Node *clause,
|
||||
List *groupClause,
|
||||
List *targetList);
|
||||
|
||||
extern void clause_get_relids_vars(Node *clause, Relids *relids, List **vars);
|
||||
extern int NumRelids(Node *clause);
|
||||
extern List *fix_opids(List *clauses);
|
||||
extern void get_relattval(Node *clause, int targetrelid,
|
||||
int *relid, AttrNumber *attno,
|
||||
Datum *constval, int *flag);
|
||||
@@ -53,8 +57,8 @@ extern bool expression_tree_walker(Node *node, bool (*walker) (),
|
||||
extern Node *expression_tree_mutator(Node *node, Node * (*mutator) (),
|
||||
void *context);
|
||||
|
||||
#define is_subplan(clause) ((Node*) (clause) != NULL && \
|
||||
nodeTag((Node*) (clause)) == T_Expr && \
|
||||
((Expr *) (clause))->opType == SUBPLAN_EXPR)
|
||||
#define is_subplan(clause) ((clause) != NULL && \
|
||||
IsA(clause, Expr) && \
|
||||
((Expr *) (clause))->opType == SUBPLAN_EXPR)
|
||||
|
||||
#endif /* CLAUSES_H */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: planmain.h,v 1.31 1999/08/21 03:49:15 tgl Exp $
|
||||
* $Id: planmain.h,v 1.32 1999/08/22 20:14:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -27,14 +27,14 @@ extern Plan *query_planner(Query *root,
|
||||
* prototypes for plan/createplan.c
|
||||
*/
|
||||
extern Plan *create_plan(Path *best_path);
|
||||
extern SeqScan *make_seqscan(List *qptlist, List *qpqual, Index scanrelid,
|
||||
Plan *lefttree);
|
||||
extern SeqScan *make_seqscan(List *qptlist, List *qpqual, Index scanrelid);
|
||||
extern Sort *make_sort(List *tlist, Oid nonameid, Plan *lefttree,
|
||||
int keycount);
|
||||
extern Agg *make_agg(List *tlist, Plan *lefttree);
|
||||
extern Group *make_group(List *tlist, bool tuplePerGroup, int ngrp,
|
||||
AttrNumber *grpColIdx, Plan *lefttree);
|
||||
extern Unique *make_unique(List *tlist, Plan *lefttree, char *uniqueAttr);
|
||||
extern Result *make_result(List *tlist, Node *resconstantqual, Plan *subplan);
|
||||
|
||||
/*
|
||||
* prototypes for plan/initsplan.c
|
||||
@@ -47,17 +47,10 @@ extern void add_missing_vars_to_tlist(Query *root, List *tlist);
|
||||
/*
|
||||
* prototypes for plan/setrefs.c
|
||||
*/
|
||||
extern void set_tlist_references(Plan *plan);
|
||||
extern void set_plan_references(Plan *plan);
|
||||
extern List *join_references(List *clauses, List *outer_tlist,
|
||||
List *inner_tlist);
|
||||
extern void replace_tlist_with_subplan_refs(List *tlist,
|
||||
Index subvarno,
|
||||
List *subplanTargetList);
|
||||
extern bool set_agg_tlist_references(Agg *aggNode);
|
||||
extern List *pull_agg_clause(Node *clause);
|
||||
extern void check_having_for_ungrouped_vars(Node *clause,
|
||||
List *groupClause,
|
||||
List *targetList);
|
||||
List *inner_tlist, Index acceptable_rel);
|
||||
extern void fix_opids(Node *node);
|
||||
|
||||
/*
|
||||
* prep/prepkeyset.c
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: tlist.h,v 1.21 1999/08/21 03:49:15 tgl Exp $
|
||||
* $Id: tlist.h,v 1.22 1999/08/22 20:14:57 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -15,20 +15,16 @@
|
||||
|
||||
#include "nodes/relation.h"
|
||||
|
||||
extern TargetEntry *tlistentry_member(Var *var, List *targetlist);
|
||||
extern Expr *matching_tlist_var(Var *var, List *targetlist);
|
||||
extern TargetEntry *tlistentry_member(Node *node, List *targetlist);
|
||||
extern Node *matching_tlist_expr(Node *node, List *targetlist);
|
||||
extern Resdom *tlist_member(Node *node, List *targetlist);
|
||||
|
||||
extern void add_var_to_tlist(RelOptInfo *rel, Var *var);
|
||||
extern TargetEntry *create_tl_element(Var *var, int resdomno);
|
||||
extern List *get_actual_tlist(List *tlist);
|
||||
extern Resdom *tlist_member(Var *var, List *tlist);
|
||||
|
||||
extern TargetEntry *match_varid(Var *test_var, List *tlist);
|
||||
extern List *new_unsorted_tlist(List *targetlist);
|
||||
extern List *copy_vars(List *target, List *source);
|
||||
extern List *flatten_tlist(List *tlist);
|
||||
extern List *add_to_flat_tlist(List *tlist, List *vars);
|
||||
extern List *unflatten_tlist(List *full_tlist,
|
||||
List *flat_tlist);
|
||||
|
||||
extern Var *get_expr(TargetEntry *tle);
|
||||
extern Node *get_sortgroupclause_expr(SortClause *sortClause,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: var.h,v 1.8 1999/07/15 15:21:23 momjian Exp $
|
||||
* $Id: var.h,v 1.9 1999/08/22 20:14:57 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -18,6 +18,5 @@
|
||||
extern List *pull_varnos(Node *me);
|
||||
extern bool contain_var_clause(Node *clause);
|
||||
extern List *pull_var_clause(Node *clause);
|
||||
extern bool var_equal(Var *var1, Var *var2);
|
||||
|
||||
#endif /* VAR_H */
|
||||
|
||||
Reference in New Issue
Block a user