1996-07-09 02:22:35 -04:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
1999-02-13 18:22:53 -05:00
|
|
|
* clauses.h
|
1997-09-07 01:04:48 -04:00
|
|
|
* prototypes for clauses.c.
|
1996-07-09 02:22:35 -04:00
|
|
|
*
|
|
|
|
|
*
|
2003-08-03 22:40:20 -04:00
|
|
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
2000-01-26 00:58:53 -05:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 02:22:35 -04:00
|
|
|
*
|
2003-12-30 18:53:15 -05:00
|
|
|
* $PostgreSQL: pgsql/src/include/optimizer/clauses.h,v 1.70 2003/12/30 23:53:15 tgl Exp $
|
1996-07-09 02:22:35 -04:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
#ifndef CLAUSES_H
|
|
|
|
|
#define CLAUSES_H
|
|
|
|
|
|
1999-07-15 19:04:24 -04:00
|
|
|
#include "nodes/relation.h"
|
1996-07-09 02:22:35 -04:00
|
|
|
|
1999-06-18 23:41:45 -04:00
|
|
|
|
2002-12-12 10:49:42 -05:00
|
|
|
|
|
|
|
|
#define is_opclause(clause) ((clause) != NULL && IsA(clause, OpExpr))
|
|
|
|
|
#define is_funcclause(clause) ((clause) != NULL && IsA(clause, FuncExpr))
|
2002-12-13 19:17:59 -05:00
|
|
|
#define is_subplan(clause) ((clause) != NULL && IsA(clause, SubPlan))
|
2002-12-12 10:49:42 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
extern Expr *make_opclause(Oid opno, Oid opresulttype, bool opretset,
|
2003-08-03 20:43:34 -04:00
|
|
|
Expr *leftop, Expr *rightop);
|
2003-01-15 14:35:48 -05:00
|
|
|
extern Node *get_leftop(Expr *clause);
|
|
|
|
|
extern Node *get_rightop(Expr *clause);
|
1997-09-08 17:56:23 -04:00
|
|
|
|
|
|
|
|
extern bool not_clause(Node *clause);
|
|
|
|
|
extern Expr *make_notclause(Expr *notclause);
|
|
|
|
|
extern Expr *get_notclausearg(Expr *notclause);
|
|
|
|
|
|
2002-12-12 10:49:42 -05:00
|
|
|
extern bool or_clause(Node *clause);
|
|
|
|
|
extern Expr *make_orclause(List *orclauses);
|
|
|
|
|
|
1997-09-08 17:56:23 -04:00
|
|
|
extern bool and_clause(Node *clause);
|
|
|
|
|
extern Expr *make_andclause(List *andclauses);
|
2000-09-29 14:21:41 -04:00
|
|
|
extern Node *make_and_qual(Node *qual1, Node *qual2);
|
1999-07-24 19:21:14 -04:00
|
|
|
extern Expr *make_ands_explicit(List *andclauses);
|
1999-07-26 23:51:11 -04:00
|
|
|
extern List *make_ands_implicit(Expr *clause);
|
1997-09-08 17:56:23 -04:00
|
|
|
|
1999-12-12 20:27:21 -05:00
|
|
|
extern bool contain_agg_clause(Node *clause);
|
2002-11-06 17:31:24 -05:00
|
|
|
extern bool contain_distinct_agg_clause(Node *clause);
|
2003-02-03 19:50:01 -05:00
|
|
|
extern int count_agg_clause(Node *clause);
|
2000-04-03 21:21:48 -04:00
|
|
|
|
2002-05-12 19:43:04 -04:00
|
|
|
extern bool expression_returns_set(Node *clause);
|
2001-12-10 17:54:12 -05:00
|
|
|
|
2000-04-03 21:21:48 -04:00
|
|
|
extern bool contain_subplans(Node *clause);
|
1999-08-22 16:15:04 -04:00
|
|
|
|
2002-04-04 19:31:36 -05:00
|
|
|
extern bool contain_mutable_functions(Node *clause);
|
|
|
|
|
extern bool contain_volatile_functions(Node *clause);
|
2002-12-01 16:05:14 -05:00
|
|
|
extern bool contain_nonstrict_functions(Node *clause);
|
2000-08-12 22:50:35 -04:00
|
|
|
|
|
|
|
|
extern bool is_pseudo_constant_clause(Node *clause);
|
2003-12-30 18:53:15 -05:00
|
|
|
extern bool is_pseudo_constant_clause_relids(Node *clause, Relids relids);
|
2000-09-29 14:21:41 -04:00
|
|
|
extern List *pull_constant_clauses(List *quals, List **constantQual);
|
2000-04-03 21:21:48 -04:00
|
|
|
|
2001-07-31 13:56:31 -04:00
|
|
|
extern bool has_distinct_on_clause(Query *query);
|
|
|
|
|
|
1999-05-25 18:43:53 -04:00
|
|
|
extern void clause_get_relids_vars(Node *clause, Relids *relids, List **vars);
|
1997-09-08 17:56:23 -04:00
|
|
|
extern int NumRelids(Node *clause);
|
2003-08-08 17:42:59 -04:00
|
|
|
extern void CommuteClause(OpExpr *clause);
|
1997-09-07 01:04:48 -04:00
|
|
|
|
1999-09-25 22:28:44 -04:00
|
|
|
extern Node *eval_const_expressions(Node *node);
|
|
|
|
|
|
1999-06-18 23:41:45 -04:00
|
|
|
extern bool expression_tree_walker(Node *node, bool (*walker) (),
|
2001-03-21 23:01:46 -05:00
|
|
|
void *context);
|
2000-04-12 13:17:23 -04:00
|
|
|
extern Node *expression_tree_mutator(Node *node, Node *(*mutator) (),
|
2001-03-21 23:01:46 -05:00
|
|
|
void *context);
|
2002-09-11 10:48:55 -04:00
|
|
|
|
|
|
|
|
/* flags bits for query_tree_walker and query_tree_mutator */
|
2003-08-03 20:43:34 -04:00
|
|
|
#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 */
|
2002-09-11 10:48:55 -04:00
|
|
|
|
2000-09-12 17:07:18 -04:00
|
|
|
extern bool query_tree_walker(Query *query, bool (*walker) (),
|
2003-08-03 20:43:34 -04:00
|
|
|
void *context, int flags);
|
2003-01-16 21:01:21 -05:00
|
|
|
extern Query *query_tree_mutator(Query *query, Node *(*mutator) (),
|
2003-08-03 20:43:34 -04:00
|
|
|
void *context, int flags);
|
2003-01-16 21:01:21 -05:00
|
|
|
|
|
|
|
|
extern bool query_or_expression_tree_walker(Node *node, bool (*walker) (),
|
2003-08-03 20:43:34 -04:00
|
|
|
void *context, int flags);
|
2003-01-16 21:01:21 -05:00
|
|
|
extern Node *query_or_expression_tree_mutator(Node *node, Node *(*mutator) (),
|
2003-08-03 20:43:34 -04:00
|
|
|
void *context, int flags);
|
1999-06-18 23:41:45 -04:00
|
|
|
|
2001-11-05 12:46:40 -05:00
|
|
|
#endif /* CLAUSES_H */
|