]> granicus.if.org Git - postgresql/blob - src/include/optimizer/clauses.h
Phase 2 of hashed-aggregation project. nodeAgg.c now knows how to do
[postgresql] / src / include / optimizer / clauses.h
1 /*-------------------------------------------------------------------------
2  *
3  * clauses.h
4  *        prototypes for clauses.c.
5  *
6  *
7  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: clauses.h,v 1.55 2002/11/06 22:31:24 tgl Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef CLAUSES_H
15 #define CLAUSES_H
16
17 #include "nodes/relation.h"
18
19 extern Expr *make_clause(int type, Node *oper, List *args);
20
21 extern bool is_opclause(Node *clause);
22 extern Expr *make_opclause(Oper *op, Var *leftop, Var *rightop);
23 extern Var *get_leftop(Expr *clause);
24 extern Var *get_rightop(Expr *clause);
25
26 extern bool is_funcclause(Node *clause);
27 extern Expr *make_funcclause(Func *func, List *funcargs);
28
29 extern bool or_clause(Node *clause);
30 extern Expr *make_orclause(List *orclauses);
31
32 extern bool not_clause(Node *clause);
33 extern Expr *make_notclause(Expr *notclause);
34 extern Expr *get_notclausearg(Expr *notclause);
35
36 extern bool and_clause(Node *clause);
37 extern Expr *make_andclause(List *andclauses);
38 extern Node *make_and_qual(Node *qual1, Node *qual2);
39 extern Expr *make_ands_explicit(List *andclauses);
40 extern List *make_ands_implicit(Expr *clause);
41
42 extern bool contain_agg_clause(Node *clause);
43 extern bool contain_distinct_agg_clause(Node *clause);
44 extern List *pull_agg_clause(Node *clause);
45
46 extern bool expression_returns_set(Node *clause);
47
48 extern bool contain_subplans(Node *clause);
49 extern List *pull_subplans(Node *clause);
50 extern void check_subplans_for_ungrouped_vars(Query *query);
51
52 extern bool contain_mutable_functions(Node *clause);
53 extern bool contain_volatile_functions(Node *clause);
54
55 extern bool is_pseudo_constant_clause(Node *clause);
56 extern List *pull_constant_clauses(List *quals, List **constantQual);
57
58 extern bool has_distinct_on_clause(Query *query);
59
60 extern void clause_get_relids_vars(Node *clause, Relids *relids, List **vars);
61 extern int      NumRelids(Node *clause);
62 extern void CommuteClause(Expr *clause);
63
64 extern Node *eval_const_expressions(Node *node);
65
66 extern bool expression_tree_walker(Node *node, bool (*walker) (),
67                                                                                            void *context);
68 extern Node *expression_tree_mutator(Node *node, Node *(*mutator) (),
69                                                                                                  void *context);
70
71 /* flags bits for query_tree_walker and query_tree_mutator */
72 #define QTW_IGNORE_SUBQUERIES   0x01    /* subqueries in rtable */
73 #define QTW_IGNORE_JOINALIASES  0x02    /* JOIN alias var lists */
74
75 extern bool query_tree_walker(Query *query, bool (*walker) (),
76                                                           void *context, int flags);
77 extern void query_tree_mutator(Query *query, Node *(*mutator) (),
78                                                            void *context, int flags);
79
80 #define is_subplan(clause)      ((clause) != NULL && \
81                                                          IsA(clause, Expr) && \
82                                                          ((Expr *) (clause))->opType == SUBPLAN_EXPR)
83
84 #endif   /* CLAUSES_H */