diff options
| author | Marc G. Fournier | 1996-08-28 07:27:54 +0000 |
|---|---|---|
| committer | Marc G. Fournier | 1996-08-28 07:27:54 +0000 |
| commit | 870be9fa8e5ead7a9fec1b1cf539c701bba57d2a (patch) | |
| tree | 0980ed1b45ec7974d2ceea9df3d0570c165804b6 /src/include/optimizer | |
| parent | 907c884fe8b88d3df5883c278cacb094a1cfc7ac (diff) | |
Clean up th ecompile process by centralizing the include files
- code compile tested, but due to a yet unresolved problem with
parse.h's creation, compile not completed...
Diffstat (limited to 'src/include/optimizer')
| -rw-r--r-- | src/include/optimizer/clauseinfo.h | 24 | ||||
| -rw-r--r-- | src/include/optimizer/clauses.h | 54 | ||||
| -rw-r--r-- | src/include/optimizer/cost.h | 59 | ||||
| -rw-r--r-- | src/include/optimizer/internal.h | 92 | ||||
| -rw-r--r-- | src/include/optimizer/joininfo.h | 20 | ||||
| -rw-r--r-- | src/include/optimizer/keys.h | 22 | ||||
| -rw-r--r-- | src/include/optimizer/ordering.h | 24 | ||||
| -rw-r--r-- | src/include/optimizer/pathnode.h | 50 | ||||
| -rw-r--r-- | src/include/optimizer/paths.h | 89 | ||||
| -rw-r--r-- | src/include/optimizer/plancat.h | 65 | ||||
| -rw-r--r-- | src/include/optimizer/planmain.h | 60 | ||||
| -rw-r--r-- | src/include/optimizer/planner.h | 24 | ||||
| -rw-r--r-- | src/include/optimizer/prep.h | 51 | ||||
| -rw-r--r-- | src/include/optimizer/tlist.h | 36 | ||||
| -rw-r--r-- | src/include/optimizer/var.h | 21 | ||||
| -rw-r--r-- | src/include/optimizer/xfunc.h | 84 |
16 files changed, 775 insertions, 0 deletions
diff --git a/src/include/optimizer/clauseinfo.h b/src/include/optimizer/clauseinfo.h new file mode 100644 index 00000000000..922571aa07a --- /dev/null +++ b/src/include/optimizer/clauseinfo.h @@ -0,0 +1,24 @@ +/*------------------------------------------------------------------------- + * + * clauseinfo.h-- + * prototypes for clauseinfo.c. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: clauseinfo.h,v 1.1 1996/08/28 07:23:10 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef CLAUSEINFO_H +#define CLAUSEINFO_H + +extern bool valid_or_clause(CInfo *clauseinfo); +extern List *get_actual_clauses(List *clauseinfo_list); +extern void get_relattvals(List *clauseinfo_list, List **attnos, + List **values, List **flags); +extern void get_joinvars(Oid relid, List *clauseinfo_list, + List **attnos, List **values, List **flags); +extern List *get_opnos(List *clauseinfo_list); + +#endif /* CLAUSEINFO_H */ diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h new file mode 100644 index 00000000000..bb00180c50f --- /dev/null +++ b/src/include/optimizer/clauses.h @@ -0,0 +1,54 @@ +/*------------------------------------------------------------------------- + * + * clauses.h-- + * prototypes for clauses.c. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: clauses.h,v 1.1 1996/08/28 07:23:11 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef CLAUSES_H +#define CLAUSES_H + +#include "nodes/pg_list.h" +#include "nodes/primnodes.h" + +extern Expr *make_clause(int type, Node *oper, List *args); +extern bool is_opclause(Node *clause); +extern Expr *make_opclause(Oper *op, Var *leftop, Var *rightop); +extern Var *get_leftop(Expr *clause); +extern Var *get_rightop(Expr *clause); + +extern bool agg_clause(Node *clause); + +extern bool is_funcclause(Node *clause); +extern Expr *make_funcclause(Func *func, List *funcargs); + +extern bool or_clause(Node *clause); +extern Expr *make_orclause(List *orclauses); + +extern bool not_clause(Node *clause); +extern Expr *make_notclause(Expr *notclause); +extern Expr *get_notclausearg(Expr *notclause); + +extern bool and_clause(Node *clause); +extern Expr *make_andclause(List *andclauses); + +extern List *pull_constant_clauses(List *quals, List **constantQual); +extern void clause_relids_vars(Node *clause, List **relids, List **vars); +extern int NumRelids(Node *clause); +extern bool contains_not(Node *clause); +extern bool join_clause_p(Node *clause); +extern bool qual_clause_p(Node *clause); +extern void fix_opid(Node *clause); +extern List *fix_opids(List *clauses); +extern void get_relattval(Node *clause, int *relid, + AttrNumber *attno, Datum *constval, int *flag); +extern void get_rels_atts(Node *clause, int *relid1, + AttrNumber *attno1, int *relid2, AttrNumber *attno2); +extern void CommuteClause(Node *clause); + +#endif /* CLAUSES_H */ diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h new file mode 100644 index 00000000000..97bcba20eec --- /dev/null +++ b/src/include/optimizer/cost.h @@ -0,0 +1,59 @@ +/*------------------------------------------------------------------------- + * + * cost.h-- + * prototypes for costsize.c and clausesel.c. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: cost.h,v 1.1 1996/08/28 07:23:12 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef COST_H +#define COST_H + +/* + * prototypes for costsize.c-- + * routines to compute costs and sizes + */ +extern bool _enable_seqscan_; +extern bool _enable_indexscan_; +extern bool _enable_sort_; +extern bool _enable_hash_; +extern bool _enable_nestloop_; +extern bool _enable_mergesort_; +extern bool _enable_hashjoin_; + +extern Cost cost_seqscan(int relid, int relpages, int reltuples); +extern Cost cost_index(Oid indexid, int expected_indexpages, Cost selec, + int relpages, int reltuples, int indexpages, + int indextuples, bool is_injoin); +extern Cost cost_sort(List *keys, int tuples, int width, bool noread); +extern Cost cost_result(int tuples, int width); +extern Cost cost_nestloop(Cost outercost, Cost innercost, int outertuples, + int innertuples, int outerpages, bool is_indexjoin); +extern Cost cost_mergesort(Cost outercost, Cost innercost, + List *outersortkeys, List *innersortkeys, + int outersize, int innersize, int outerwidth, int innerwidth); +extern Cost cost_hashjoin(Cost outercost, Cost innercost, List *outerkeys, + List *innerkeys, int outersize, int innersize, + int outerwidth, int innerwidth); +extern int compute_rel_size(Rel *rel); +extern int compute_rel_width(Rel *rel); +extern int compute_targetlist_width(List *targetlist); +extern int compute_joinrel_size(JoinPath *joinpath); +extern int page_size(int tuples, int width); + +/* + * prototypes for fuctions in clausesel.h-- + * routines to compute clause selectivities + */ +extern void set_clause_selectivities(List *clauseinfo_list, Cost new_selectivity); +extern Cost product_selec(List *clauseinfo_list); +extern void set_rest_relselec(Query *root, List *rel_list); +extern void set_rest_selec(Query *root,List *clauseinfo_list); +extern Cost compute_clause_selec(Query *root, + Node *clause, List *or_selectivities); + +#endif /* COST_H */ diff --git a/src/include/optimizer/internal.h b/src/include/optimizer/internal.h new file mode 100644 index 00000000000..789c82085ab --- /dev/null +++ b/src/include/optimizer/internal.h @@ -0,0 +1,92 @@ +/*------------------------------------------------------------------------- + * + * internal.h-- + * Definitions required throughout the query optimizer. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: internal.h,v 1.1 1996/08/28 07:23:12 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef INTERNAL_H +#define INTERNAL_H + +/* + * ---------- SHARED MACROS + * + * Macros common to modules for creating, accessing, and modifying + * query tree and query plan components. + * Shared with the executor. + * + */ + +#include "nodes/nodes.h" +#include "nodes/primnodes.h" +#include "nodes/plannodes.h" +#include "parser/parsetree.h" +#include "nodes/relation.h" +#include "catalog/pg_index.h" /* for INDEX_MAX_KEYS */ +#include "utils/syscache.h" /* for SearchSysCacheGetAttribute, etc. */ + +/* + * System-dependent tuning constants + * + */ +#define _CPU_PAGE_WEIGHT_ 0.065 /* CPU-to-page cost weighting factor */ +#define _PAGE_SIZE_ 8192 /* BLCKSZ (from ../h/bufmgr.h) */ +#define _MAX_KEYS_ INDEX_MAX_KEYS /* maximum number of keys in an index */ +#define _TID_SIZE_ 6 /* sizeof(itemid) (from ../h/itemid.h) */ + +/* + * Size estimates + * + */ + +/* The cost of sequentially scanning a materialized temporary relation + */ +#define _TEMP_SCAN_COST_ 10 + +/* The number of pages and tuples in a materialized relation + */ +#define _TEMP_RELATION_PAGES_ 1 +#define _TEMP_RELATION_TUPLES_ 10 + +/* The length of a variable-length field in bytes + */ +#define _DEFAULT_ATTRIBUTE_WIDTH_ (2 * _TID_SIZE_) + +/* + * Flags and identifiers + * + */ + +/* Identifier for (sort) temp relations */ +/* used to be -1 */ +#define _TEMP_RELATION_ID_ InvalidOid + +/* Identifier for invalid relation OIDs and attribute numbers for use by + * selectivity functions + */ +#define _SELEC_VALUE_UNKNOWN_ -1 + +/* Flag indicating that a clause constant is really a parameter (or other + * non-constant?), a non-parameter, or a constant on the right side + * of the clause. + */ +#define _SELEC_NOT_CONSTANT_ 0 +#define _SELEC_IS_CONSTANT_ 1 +#define _SELEC_CONSTANT_LEFT_ 0 +#define _SELEC_CONSTANT_RIGHT_ 2 + +#define TOLERANCE 0.000001 + +#define FLOAT_EQUAL(X,Y) ((X) - (Y) < TOLERANCE) +#define FLOAT_IS_ZERO(X) (FLOAT_EQUAL(X,0.0)) + +extern int BushyPlanFlag; +/* #define deactivate_joininfo(joininfo) joininfo->inactive=true*/ +/*#define joininfo_inactive(joininfo) joininfo->inactive */ + +#endif /* INTERNAL_H */ diff --git a/src/include/optimizer/joininfo.h b/src/include/optimizer/joininfo.h new file mode 100644 index 00000000000..5c3a7ee2910 --- /dev/null +++ b/src/include/optimizer/joininfo.h @@ -0,0 +1,20 @@ +/*------------------------------------------------------------------------- + * + * joininfo.h-- + * prototypes for joininfo.c. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: joininfo.h,v 1.1 1996/08/28 07:23:14 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef JOININFO_H +#define JOININFO_H + +extern JInfo *joininfo_member(List *join_relids, List *joininfo_list); +extern JInfo *find_joininfo_node(Rel *this_rel, List *join_relids); +extern Var *other_join_clause_var(Var *var, Expr *clause); + +#endif /* JOININFO_H */ diff --git a/src/include/optimizer/keys.h b/src/include/optimizer/keys.h new file mode 100644 index 00000000000..17be635f4e8 --- /dev/null +++ b/src/include/optimizer/keys.h @@ -0,0 +1,22 @@ +/*------------------------------------------------------------------------- + * + * keys.h-- + * prototypes for keys.c. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: keys.h,v 1.1 1996/08/28 07:23:16 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef KEYS_H +#define KEYS_H + +extern bool match_indexkey_operand(int indexkey, Var *operand, Rel *rel); +extern bool equal_indexkey_var(int index_key, Var *var); +extern Var *extract_subkey(JoinKey *jk, int which_subkey); +extern bool samekeys(List *keys1, List *keys2); +extern List *collect_index_pathkeys(int *index_keys, List *tlist); + +#endif /* KEYS_H */ diff --git a/src/include/optimizer/ordering.h b/src/include/optimizer/ordering.h new file mode 100644 index 00000000000..c8f38a2d2ec --- /dev/null +++ b/src/include/optimizer/ordering.h @@ -0,0 +1,24 @@ +/*------------------------------------------------------------------------- + * + * ordering.h-- + * prototypes for ordering.c. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: ordering.h,v 1.1 1996/08/28 07:23:17 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef ORDERING_H +#define ORDERING_H + +extern bool equal_path_path_ordering(PathOrder *path_ordering1, + PathOrder *path_ordering2); +extern bool equal_path_merge_ordering(Oid *path_ordering, + MergeOrder *merge_ordering); +extern bool equal_merge_merge_ordering(MergeOrder *merge_ordering1, + MergeOrder *merge_ordering2); +extern bool equal_sortops_order(Oid *ordering1, Oid *ordering2); + +#endif /* ORDERING_H */ diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h new file mode 100644 index 00000000000..b1353cc971c --- /dev/null +++ b/src/include/optimizer/pathnode.h @@ -0,0 +1,50 @@ +/*------------------------------------------------------------------------- + * + * pathnode.h-- + * prototypes for pathnode.c, indexnode.c, relnode.c. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: pathnode.h,v 1.1 1996/08/28 07:23:18 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PATHNODE_H +#define PATHNODE_H + +/* + * prototypes for pathnode.c + */ +extern bool path_is_cheaper(Path *path1, Path *path2); +extern Path *set_cheapest(Rel *parent_rel, List *pathlist); +extern List *add_pathlist(Rel *parent_rel, List *unique_paths, + List *new_paths); +extern Path *create_seqscan_path(Rel *rel); +extern IndexPath *create_index_path(Query *root, Rel *rel, Rel *index, + List *restriction_clauses, bool is_join_scan); +extern JoinPath *create_nestloop_path(Rel *joinrel, Rel *outer_rel, + Path *outer_path, Path *inner_path, List *keys); +extern MergePath *create_mergesort_path(Rel *joinrel, int outersize, + int innersize, int outerwidth, int innerwidth, Path *outer_path, + Path *inner_path, List *keys, MergeOrder *order, + List *mergeclauses, List *outersortkeys, List *innersortkeys); + +extern HashPath *create_hashjoin_path(Rel *joinrel, int outersize, + int innersize, int outerwidth, int innerwidth, Path *outer_path, + Path *inner_path, List *keys, Oid operator, List *hashclauses, + List *outerkeys, List *innerkeys); + +/* + * prototypes for rel.c + */ +extern Rel *rel_member(List *relid, List *rels); +extern Rel *get_base_rel(Query* root, int relid); +extern Rel *get_join_rel(Query* root, List *relid); + +/* + * prototypes for indexnode.h + */ +extern List *find_relation_indices(Query *root,Rel *rel); + +#endif /* PATHNODE_H */ diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h new file mode 100644 index 00000000000..9f76e65ce51 --- /dev/null +++ b/src/include/optimizer/paths.h @@ -0,0 +1,89 @@ +/*------------------------------------------------------------------------- + * + * paths.h-- + * prototypes for various files in optimizer/paths (were separate + * header files + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: paths.h,v 1.1 1996/08/28 07:23:19 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PATHS_H +#define PATHS_H + +/* + * allpaths.h + */ +extern List *find_paths(Query *root, List *rels); + +/* + * indxpath.h + * routines to generate index paths + */ +extern List *find_index_paths(Query *root, Rel *rel, List *indices, + List *clauseinfo_list, + List *joininfo_list); + +/* + * joinpath.h + * routines to create join paths + */ +extern void find_all_join_paths(Query *root, List *joinrels); + + +/* + * orindxpath.h + */ +extern List *create_or_index_paths(Query *root, Rel *rel, List *clauses); + +/* + * hashutils.h + * routines to deal with hash keys and clauses + */ +extern List *group_clauses_by_hashop(List *clauseinfo_list, + int inner_relid); + +/* + * joinutils.h + * generic join method key/clause routines + */ +extern List *match_pathkeys_joinkeys(List *pathkeys, + List *joinkeys, List *joinclauses, int which_subkey, + List **matchedJoinClausesPtr); +extern List *extract_path_keys(List *joinkeys, List *tlist, + int which_subkey); +extern Path *match_paths_joinkeys(List *joinkeys, PathOrder *ordering, + List *paths, int which_subkey); +extern List *new_join_pathkeys(List *outer_pathkeys, + List *join_rel_tlist, List *joinclauses); + +/* + * mergeutils.h + * routines to deal with merge keys and clauses + */ +extern List *group_clauses_by_order(List *clauseinfo_list, + int inner_relid); +extern MInfo *match_order_mergeinfo(PathOrder *ordering, + List *mergeinfo_list); + +/* + * joinrels.h + * routines to determine which relations to join + */ +extern List *find_join_rels(Query *root, List *outer_rels); +extern void add_new_joininfos(Query *root, List *joinrels, List *outerrels); +extern List *final_join_rels(List *join_rel_list); + +/* + * prototypes for path/prune.c + */ +extern List *prune_joinrels(List *rel_list); +extern void prune_rel_paths(List *rel_list); +extern Path *prune_rel_path(Rel *rel, Path *unorderedpath); +extern List *merge_joinrels(List *rel_list1, List *rel_list2); +extern List *prune_oldrels(List *old_rels); + +#endif /* PATHS_H */ diff --git a/src/include/optimizer/plancat.h b/src/include/optimizer/plancat.h new file mode 100644 index 00000000000..3279985b164 --- /dev/null +++ b/src/include/optimizer/plancat.h @@ -0,0 +1,65 @@ +/*------------------------------------------------------------------------- + * + * plancat.h-- + * prototypes for plancat.c. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: plancat.h,v 1.1 1996/08/28 07:23:20 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PLANCAT_H +#define PLANCAT_H + +#include "c.h" + +/* + * transient data structure to hold return value of index_info. Note that + * indexkeys, orderOprs and classlist is "null-terminated". + */ +typedef struct IdxInfoRetval { + Oid relid; /* OID of the index relation (not the OID + * of the relation being indexed) + */ + Oid relam; /* OID of the pg_am of this index */ + int pages; /* number of pages in the index relation */ + int tuples; /* number of tuples in the index relation */ + int *indexkeys; /* keys over which we're indexing */ + Oid *orderOprs; /* operators used for ordering purposes */ + Oid *classlist; /* classes of AM operators */ + Oid indproc; + Node *indpred; +} IdxInfoRetval; + + +extern void relation_info(Query *root, + Oid relid, + bool *hashindex, int *pages, + int *tuples); + +extern bool index_info(Query *root, + bool first, int relid, IdxInfoRetval *info); + +extern Cost +restriction_selectivity(Oid functionObjectId, + Oid operatorObjectId, + Oid relationObjectId, + AttrNumber attributeNumber, + char *constValue, + int32 constFlag); + +extern void +index_selectivity(Oid indid, Oid *classes, List *opnos, + Oid relid, List *attnos, List *values, List *flags, + int32 nkeys, float *idxPages, float *idxSelec); + +extern Cost join_selectivity(Oid functionObjectId, Oid operatorObjectId, + Oid relationObjectId1, AttrNumber attributeNumber1, + Oid relationObjectId2, AttrNumber attributeNumber2); + +extern List *find_inheritance_children(Oid inhparent); +extern List *VersionGetParents(Oid verrelid); + +#endif /* PLANCAT_H */ diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h new file mode 100644 index 00000000000..e0aec7ec635 --- /dev/null +++ b/src/include/optimizer/planmain.h @@ -0,0 +1,60 @@ +/*------------------------------------------------------------------------- + * + * planmain.h-- + * prototypes for various files in optimizer/plan + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: planmain.h,v 1.1 1996/08/28 07:23:23 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PLANMAIN_H +#define PLANMAIN_H + + +/* + * prototypes for plan/planmain.c + */ +extern Plan *query_planner(Query *root, + int command_type, List *tlist, List *qual); + + +/* + * 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 Sort *make_sort(List *tlist, Oid tempid, Plan *lefttree, + int keycount); +extern Agg *make_agg(List *tlist, int nagg, Aggreg **aggs); +extern Group *make_group(List *tlist, bool tuplePerGroup, int ngrp, + AttrNumber *grpColIdx, Sort *lefttree); +extern Unique *make_unique(List *tlist, Plan *lefttree, char *uniqueAttr); +extern List *generate_fjoin(List *tlist); + + +/* + * prototypes for plan/initsplan.c + */ +extern void initialize_base_rels_list(Query *root, List *tlist); +extern void initialize_base_rels_jinfo(Query *root, List *clauses); +extern void initialize_join_clause_info(List *rel_list); +extern void add_missing_vars_to_base_rels(Query *root, List *tlist); + +/* + * prototypes for plan/setrefs.c + */ +extern void set_tlist_references(Plan *plan); +extern List *join_references(List *clauses, List *outer_tlist, + List *inner_tlist); +extern List *index_outerjoin_references(List *inner_indxqual, + List *outer_tlist, Index inner_relid); +extern void set_result_tlist_references(Result *resultNode); +extern void set_agg_tlist_references(Agg *aggNode); +extern void set_agg_agglist_references(Agg *aggNode); + + +#endif /* PLANMAIN_H */ diff --git a/src/include/optimizer/planner.h b/src/include/optimizer/planner.h new file mode 100644 index 00000000000..8c74ae4bb7c --- /dev/null +++ b/src/include/optimizer/planner.h @@ -0,0 +1,24 @@ +/*------------------------------------------------------------------------- + * + * planner.h-- + * prototypes for planner.c. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: planner.h,v 1.1 1996/08/28 07:23:26 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PLANNER_H +#define PLANNER_H + +/* +#include "optimizer/internal.h" +#include "parser/parse_query.h" +*/ + +extern Plan *planner(Query *parse); +extern void pg_checkretval(Oid rettype, QueryTreeList *querytree_list); + +#endif /* PLANNER_H */ diff --git a/src/include/optimizer/prep.h b/src/include/optimizer/prep.h new file mode 100644 index 00000000000..3873669c3f6 --- /dev/null +++ b/src/include/optimizer/prep.h @@ -0,0 +1,51 @@ +/*------------------------------------------------------------------------- + * + * prep.h-- + * prototypes for files in prep.c + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: prep.h,v 1.1 1996/08/28 07:23:27 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PREP_H +#define PREP_H + +#include "nodes/primnodes.h" +#include "nodes/plannodes.h" + +/* + * prototypes for archive.h + */ +extern void plan_archive(List *rt); +extern List *find_archive_rels(Oid relid); + +/* + * prototypes for prepqual.h + */ +extern List *preprocess_qualification(Expr *qual, List *tlist, + List **existentialQualPtr); +extern List *cnfify(Expr *qual, bool removeAndFlag); + +/* + * prototypes for preptlist.h + */ +extern List *preprocess_targetlist(List *tlist, int command_type, + Index result_relation, List *range_table); + +/* + * prototypes for prepunion.h + */ +typedef enum UnionFlag { + INHERITS_FLAG, ARCHIVE_FLAG, VERSION_FLAG +} UnionFlag; + +extern List *find_all_inheritors(List *unexamined_relids, + List *examined_relids); +extern int first_matching_rt_entry(List *rangetable, UnionFlag flag); +extern Append *plan_union_queries(Index rt_index, Query *parse, + UnionFlag flag); + +#endif /* PREP_H */ diff --git a/src/include/optimizer/tlist.h b/src/include/optimizer/tlist.h new file mode 100644 index 00000000000..b70916c10b9 --- /dev/null +++ b/src/include/optimizer/tlist.h @@ -0,0 +1,36 @@ +/*------------------------------------------------------------------------- + * + * tlist.h-- + * prototypes for tlist.c. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: tlist.h,v 1.1 1996/08/28 07:23:28 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef TLIST_H +#define TLIST_H + +extern int exec_tlist_length(List *targelist); +extern TargetEntry *tlistentry_member(Var *var, List *targetlist); +extern Expr *matching_tlvar(Var *var, List *targetlist); +extern void add_tl_element(Rel *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 Resdom *tlist_resdom(List *tlist, Resdom *resnode); + +extern TargetEntry *MakeTLE(Resdom *resdom, Node *expr); +extern Var *get_expr(TargetEntry *tle); + +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 *flatten_tlist_vars(List *full_tlist, + List *flat_tlist); +extern void AddGroupAttrToTlist(List *tlist, List *grpCl); + +#endif /* TLIST_H */ diff --git a/src/include/optimizer/var.h b/src/include/optimizer/var.h new file mode 100644 index 00000000000..2df81e086d7 --- /dev/null +++ b/src/include/optimizer/var.h @@ -0,0 +1,21 @@ +/*------------------------------------------------------------------------- + * + * var.h-- + * prototypes for var.c. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: var.h,v 1.1 1996/08/28 07:23:29 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef VAR_H +#define VAR_H + +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 */ diff --git a/src/include/optimizer/xfunc.h b/src/include/optimizer/xfunc.h new file mode 100644 index 00000000000..b9e5cee2575 --- /dev/null +++ b/src/include/optimizer/xfunc.h @@ -0,0 +1,84 @@ +/*------------------------------------------------------------------------- + * + * xfunc.h-- + * prototypes for xfunc.c and predmig.c. + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: xfunc.h,v 1.1 1996/08/28 07:23:30 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef XFUNC_H +#define XFUNC_H + +#include "nodes/relation.h" + +/* command line arg flags */ +#define XFUNC_OFF -1 /* do no optimization of expensive preds */ +#define XFUNC_NOR 2 /* do no optimization of OR clauses */ +#define XFUNC_NOPULL 4 /* never pull restrictions above joins */ +#define XFUNC_NOPM 8 /* don't do predicate migration */ +#define XFUNC_WAIT 16 /* don't do pullup until predicate migration */ +#define XFUNC_PULLALL 32 /* pull all expensive restrictions up, always */ + +/* constants for local and join predicates */ +#define XFUNC_LOCPRD 1 +#define XFUNC_JOINPRD 2 +#define XFUNC_UNKNOWN 0 + +extern int XfuncMode; /* defined in tcop/postgres.c */ + +/* defaults for function attributes used for expensive function calculations */ +#define BYTE_PCT 100 +#define PERBYTE_CPU 0 +#define PERCALL_CPU 0 +#define OUTIN_RATIO 100 + +/* default width assumed for variable length attributes */ +#define VARLEN_DEFAULT 128; + +/* Macro to get group rank out of group cost and group sel */ +#define get_grouprank(a) ((get_groupsel(a) - 1) / get_groupcost(a)) + +/* Macro to see if a path node is actually a Join */ +#define is_join(pathnode) (length(get_relids(get_parent(pathnode))) > 1 ? 1 : 0) + +/* function prototypes from planner/path/xfunc.c */ +extern void xfunc_trypullup(Rel *rel); +extern int xfunc_shouldpull(Path *childpath, JoinPath *parentpath, + int whichchild, CInfo *maxcinfopt); +extern CInfo *xfunc_pullup(Path *childpath, JoinPath *parentpath, CInfo *cinfo, + int whichchild, int clausetype); +extern Cost xfunc_rank(Expr *clause); +extern Cost xfunc_expense(Query* queryInfo, Expr *clause); +extern Cost xfunc_join_expense(JoinPath *path, int whichchild); +extern Cost xfunc_local_expense(Expr *clause); +extern Cost xfunc_func_expense(Expr *node, List *args); +extern int xfunc_width(Expr *clause); +/* static, moved to xfunc.c */ +/* extern int xfunc_card_unreferenced(Expr *clause, Relid referenced); */ +extern int xfunc_card_product(Relid relids); +extern List *xfunc_find_references(List *clause); +extern List *xfunc_primary_join(JoinPath *pathnode); +extern Cost xfunc_get_path_cost(Path *pathnode); +extern Cost xfunc_total_path_cost(JoinPath *pathnode); +extern Cost xfunc_expense_per_tuple(JoinPath *joinnode, int whichchild); +extern void xfunc_fixvars(Expr *clause, Rel *rel, int varno); +extern int xfunc_cinfo_compare(void *arg1, void *arg2); +extern int xfunc_clause_compare(void *arg1, void *arg2); +extern void xfunc_disjunct_sort(List *clause_list); +extern int xfunc_disjunct_compare(void *arg1, void *arg2); +extern int xfunc_func_width(RegProcedure funcid, List *args); +extern int xfunc_tuple_width(Relation rd); +extern int xfunc_num_join_clauses(JoinPath *path); +extern List *xfunc_LispRemove(List *foo, List *bar); +extern bool xfunc_copyrel(Rel *from, Rel **to); + +/* + * function prototypes for path/predmig.c + */ +extern bool xfunc_do_predmig(Path root); + +#endif /* XFUNC_H */ |
