]> granicus.if.org Git - postgresql/blobdiff - src/include/optimizer/clauses.h
Arrange to "inline" SQL functions that appear in a query's FROM clause,
[postgresql] / src / include / optimizer / clauses.h
index ad6976760a5f5877972642b955f88de66bb85bfc..b5d618595f74f08331ea83ea66155331e5d44c90 100644 (file)
@@ -4,9 +4,10 @@
  *       prototypes for clauses.c.
  *
  *
- * Copyright (c) 1994, Regents of the University of California
+ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: clauses.h,v 1.24 1999/07/27 03:51:00 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/clauses.h,v 1.89 2008/03/18 22:04:14 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #include "nodes/relation.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);
+#define is_opclause(clause)            ((clause) != NULL && IsA(clause, OpExpr))
+#define is_funcclause(clause)  ((clause) != NULL && IsA(clause, FuncExpr))
+#define is_subplan(clause)             ((clause) != NULL && IsA(clause, SubPlan))
 
-extern bool is_funcclause(Node *clause);
-extern Expr *make_funcclause(Func *func, List *funcargs);
+typedef struct
+{
+       int                     numAggs;                /* total number of aggregate calls */
+       int                     numDistinctAggs;        /* number that use DISTINCT */
+       Size            transitionSpace;        /* for pass-by-ref transition data */
+} AggClauseCounts;
 
-extern bool or_clause(Node *clause);
-extern Expr *make_orclause(List *orclauses);
+
+extern Expr *make_opclause(Oid opno, Oid opresulttype, bool opretset,
+                         Expr *leftop, Expr *rightop);
+extern Node *get_leftop(Expr *clause);
+extern Node *get_rightop(Expr *clause);
 
 extern bool not_clause(Node *clause);
 extern Expr *make_notclause(Expr *notclause);
 extern Expr *get_notclausearg(Expr *notclause);
 
+extern bool or_clause(Node *clause);
+extern Expr *make_orclause(List *orclauses);
+
 extern bool and_clause(Node *clause);
 extern Expr *make_andclause(List *andclauses);
+extern Node *make_and_qual(Node *qual1, Node *qual2);
 extern Expr *make_ands_explicit(List *andclauses);
 extern List *make_ands_implicit(Expr *clause);
 
-extern bool case_clause(Node *clause);
+extern bool contain_agg_clause(Node *clause);
+extern void count_agg_clauses(Node *clause, AggClauseCounts *counts);
+
+extern bool expression_returns_set(Node *clause);
+extern double expression_returns_set_rows(Node *clause);
+
+extern bool contain_subplans(Node *clause);
+
+extern bool contain_mutable_functions(Node *clause);
+extern bool contain_volatile_functions(Node *clause);
+extern bool contain_nonstrict_functions(Node *clause);
+extern Relids find_nonnullable_rels(Node *clause);
+
+extern bool is_pseudo_constant_clause(Node *clause);
+extern bool is_pseudo_constant_clause_relids(Node *clause, Relids relids);
+
+extern bool has_distinct_clause(Query *query);
+extern bool has_distinct_on_clause(Query *query);
 
-extern List *pull_constant_clauses(List *quals, List **constantQual);
-extern void clause_get_relids_vars(Node *clause, Relids *relids, List **vars);
 extern int     NumRelids(Node *clause);
-extern bool is_joinable(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 targetrelid,
-                                                 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);
+
+extern void CommuteOpExpr(OpExpr *clause);
+extern void CommuteRowCompareExpr(RowCompareExpr *clause);
+
+extern Node *strip_implicit_coercions(Node *node);
+
+extern void set_coercionform_dontcare(Node *node);
+
+extern Node *eval_const_expressions(Node *node);
+
+extern Node *estimate_expression_value(PlannerInfo *root, Node *node);
+
+extern Query *inline_set_returning_function(PlannerInfo *root, Node *node);
 
 extern bool expression_tree_walker(Node *node, bool (*walker) (),
-                                                                  void *context);
+                                                                                          void *context);
+extern Node *expression_tree_mutator(Node *node, Node *(*mutator) (),
+                                                                                                void *context);
+
+/* flags bits for query_tree_walker and query_tree_mutator */
+#define QTW_IGNORE_RT_SUBQUERIES       0x01            /* subqueries in rtable */
+#define QTW_IGNORE_JOINALIASES         0x02            /* JOIN alias var lists */
+#define QTW_DONT_COPY_QUERY                    0x04            /* do not copy top Query */
+
+extern bool query_tree_walker(Query *query, bool (*walker) (),
+                                                                                 void *context, int flags);
+extern Query *query_tree_mutator(Query *query, Node *(*mutator) (),
+                                                                                        void *context, int flags);
+
+extern bool range_table_walker(List *rtable, bool (*walker) (),
+                                                                                  void *context, int flags);
+extern List *range_table_mutator(List *rtable, Node *(*mutator) (),
+                                                                                        void *context, int flags);
 
-#define is_subplan(clause)     ((Node*) (clause) != NULL && \
-                                               nodeTag((Node*) (clause)) == T_Expr && \
-                                               ((Expr *) (clause))->opType == SUBPLAN_EXPR)
+extern bool query_or_expression_tree_walker(Node *node, bool (*walker) (),
+                                                                                                  void *context, int flags);
+extern Node *query_or_expression_tree_mutator(Node *node, Node *(*mutator) (),
+                                                                                                  void *context, int flags);
 
-#endif  /* CLAUSES_H */
+#endif   /* CLAUSES_H */