clauses.h 2.48 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * clauses.h
4
 *	  prototypes for clauses.c.
5 6
 *
 *
7
 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
Bruce Momjian's avatar
Add:  
Bruce Momjian committed
8
 * Portions Copyright (c) 1994, Regents of the University of California
9
 *
10
 * $Id: clauses.h,v 1.48 2001/10/30 19:58:58 tgl Exp $
11 12 13 14 15 16
 *
 *-------------------------------------------------------------------------
 */
#ifndef CLAUSES_H
#define CLAUSES_H

17
#include "nodes/relation.h"
18

19
extern Expr *make_clause(int type, Node *oper, List *args);
20

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
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 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);
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 List *pull_agg_clause(Node *clause);
44 45 46

extern bool contain_subplans(Node *clause);
extern List *pull_subplans(Node *clause);
47
extern void check_subplans_for_ungrouped_vars(Query *query);
48

49 50 51
extern bool contain_noncachable_functions(Node *clause);

extern bool is_pseudo_constant_clause(Node *clause);
52
extern List *pull_constant_clauses(List *quals, List **constantQual);
53

54 55
extern bool has_distinct_on_clause(Query *query);

56
extern void clause_get_relids_vars(Node *clause, Relids *relids, List **vars);
57
extern int	NumRelids(Node *clause);
58
extern void CommuteClause(Expr *clause);
59

60 61
extern Node *eval_const_expressions(Node *node);

62
extern bool expression_tree_walker(Node *node, bool (*walker) (),
63
											   void *context);
64
extern Node *expression_tree_mutator(Node *node, Node *(*mutator) (),
65
												 void *context);
66
extern bool query_tree_walker(Query *query, bool (*walker) (),
67
									 void *context, bool visitQueryRTEs);
68
extern void query_tree_mutator(Query *query, Node *(*mutator) (),
69
									 void *context, bool visitQueryRTEs);
70

71 72 73
#define is_subplan(clause)	((clause) != NULL && \
							 IsA(clause, Expr) && \
							 ((Expr *) (clause))->opType == SUBPLAN_EXPR)
74

75
#endif	 /* CLAUSES_H */