]> granicus.if.org Git - postgresql/blob - src/include/optimizer/clauses.h
Update copyright via script for 2017
[postgresql] / src / include / optimizer / clauses.h
1 /*-------------------------------------------------------------------------
2  *
3  * clauses.h
4  *        prototypes for clauses.c.
5  *
6  *
7  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/optimizer/clauses.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef CLAUSES_H
15 #define CLAUSES_H
16
17 #include "nodes/relation.h"
18
19
20 #define is_opclause(clause)             ((clause) != NULL && IsA(clause, OpExpr))
21 #define is_funcclause(clause)   ((clause) != NULL && IsA(clause, FuncExpr))
22
23 typedef struct
24 {
25         int                     numWindowFuncs; /* total number of WindowFuncs found */
26         Index           maxWinRef;              /* windowFuncs[] is indexed 0 .. maxWinRef */
27         List      **windowFuncs;        /* lists of WindowFuncs for each winref */
28 } WindowFuncLists;
29
30 extern Expr *make_opclause(Oid opno, Oid opresulttype, bool opretset,
31                           Expr *leftop, Expr *rightop,
32                           Oid opcollid, Oid inputcollid);
33 extern Node *get_leftop(const Expr *clause);
34 extern Node *get_rightop(const Expr *clause);
35
36 extern bool not_clause(Node *clause);
37 extern Expr *make_notclause(Expr *notclause);
38 extern Expr *get_notclausearg(Expr *notclause);
39
40 extern bool or_clause(Node *clause);
41 extern Expr *make_orclause(List *orclauses);
42
43 extern bool and_clause(Node *clause);
44 extern Expr *make_andclause(List *andclauses);
45 extern Node *make_and_qual(Node *qual1, Node *qual2);
46 extern Expr *make_ands_explicit(List *andclauses);
47 extern List *make_ands_implicit(Expr *clause);
48
49 extern bool contain_agg_clause(Node *clause);
50 extern void get_agg_clause_costs(PlannerInfo *root, Node *clause,
51                                          AggSplit aggsplit, AggClauseCosts *costs);
52
53 extern bool contain_window_function(Node *clause);
54 extern WindowFuncLists *find_window_functions(Node *clause, Index maxWinRef);
55
56 extern double expression_returns_set_rows(Node *clause);
57 extern double tlist_returns_set_rows(List *tlist);
58
59 extern bool contain_subplans(Node *clause);
60
61 extern bool contain_mutable_functions(Node *clause);
62 extern bool contain_volatile_functions(Node *clause);
63 extern bool contain_volatile_functions_not_nextval(Node *clause);
64 extern char max_parallel_hazard(Query *parse);
65 extern bool is_parallel_safe(PlannerInfo *root, Node *node);
66 extern bool contain_nonstrict_functions(Node *clause);
67 extern bool contain_leaked_vars(Node *clause);
68
69 extern Relids find_nonnullable_rels(Node *clause);
70 extern List *find_nonnullable_vars(Node *clause);
71 extern List *find_forced_null_vars(Node *clause);
72 extern Var *find_forced_null_var(Node *clause);
73
74 extern bool is_pseudo_constant_clause(Node *clause);
75 extern bool is_pseudo_constant_clause_relids(Node *clause, Relids relids);
76
77 extern int      NumRelids(Node *clause);
78
79 extern void CommuteOpExpr(OpExpr *clause);
80 extern void CommuteRowCompareExpr(RowCompareExpr *clause);
81
82 extern Node *eval_const_expressions(PlannerInfo *root, Node *node);
83
84 extern Node *estimate_expression_value(PlannerInfo *root, Node *node);
85
86 extern Query *inline_set_returning_function(PlannerInfo *root,
87                                                           RangeTblEntry *rte);
88
89 #endif   /* CLAUSES_H */