1 /* -*-pgsql-c-*- */
2 /*
3  *
4  * $Header$
5  *
6  * pgpool: a language independent connection pool server for PostgreSQL
7  * written by Tatsuo Ishii
8  *
9  * Copyright (c) 2003-2012	PgPool Global Development Group
10  *
11  * Permission to use, copy, modify, and distribute this software and
12  * its documentation for any purpose and without fee is hereby
13  * granted, provided that the above copyright notice appear in all
14  * copies and that both that copyright notice and this permission
15  * notice appear in supporting documentation, and that the name of the
16  * author not be used in advertising or publicity pertaining to
17  * distribution of the software without specific, written prior
18  * permission. The author makes no representations about the
19  * suitability of this software for any purpose.  It is provided "as
20  * is" without express or implied warranty.
21  *
22  * pool_select_walker.h.: Walker functions for SELECT
23  *
24  */
25 
26 #ifndef POOL_SELECT_WALKER_H
27 #define POOL_SELECT_WALKER_H
28 
29 #include "pool.h"
30 #include "parser/nodes.h"
31 #include "parser/primnodes.h"
32 #include "parser/makefuncs.h"
33 
34 #define POOL_MAX_SELECT_OIDS 128
35 #define POOL_NAMEDATALEN 64		/* from NAMEDATALEN of PostgreSQL */
36 
37 typedef struct
38 {
39 	bool		has_system_catalog; /* True if system catalog table is used */
40 	bool		has_temp_table; /* True if temporary table is used */
41 	bool		has_unlogged_table; /* True if unlogged table is used */
42 	bool		has_view;		/* True if view is used */
43 	bool		has_function_call;	/* True if write function call is used */
44 	int			pg_terminate_backend_pid;	/* pid argument of
45 											 * pg_terminate_backedn_call(if
46 											 * used) */
47 	bool		has_non_immutable_function_call;	/* True if non immutable
48 													 * functions are used */
49 	bool		has_insertinto_or_locking_clause;	/* True if it has SELECT
50 													 * INTO or FOR
51 													 * SHARE/UPDATE */
52 	int			num_oids;		/* number of oids */
53 	int			table_oids[POOL_MAX_SELECT_OIDS];	/* table oids */
54 	char		table_names[POOL_MAX_SELECT_OIDS][POOL_NAMEDATALEN];	/* table names */
55 }			SelectContext;
56 
57 extern int	pool_get_terminate_backend_pid(Node *node);
58 extern bool pool_has_function_call(Node *node);
59 extern bool pool_has_non_immutable_function_call(Node *node);
60 extern bool pool_has_system_catalog(Node *node);
61 extern bool pool_has_temp_table(Node *node);
62 extern void discard_temp_table_relcache(void);
63 extern bool pool_has_unlogged_table(Node *node);
64 extern bool pool_has_view(Node *node);
65 extern bool pool_has_insertinto_or_locking_clause(Node *node);
66 extern bool pool_has_pgpool_regclass(void);
67 extern bool pool_has_to_regclass(void);
68 extern bool raw_expression_tree_walker(Node *node, bool (*walker) (), void *context);
69 extern int	pool_table_name_to_oid(char *table_name);
70 extern int	pool_extract_table_oids_from_select_stmt(Node *node, SelectContext * ctx);
71 extern RangeVar *makeRangeVarFromNameList(List *names);
72 extern char *make_table_name_from_rangevar(RangeVar *rangevar);
73 extern int	pattern_compare(char *str, const int type, const char *param_name);
74 extern bool is_unlogged_table(char *table_name);
75 extern bool is_view(char *table_name);
76 
77 #endif							/* POOL_SELECT_WALKER_H */
78