]> git.8kb.co.uk Git - pgpool-ii/pgpool-ii_2.2.5/blob - pool_proto_modules.h
Attempt to send a proper failure message to frontend when authentication
[pgpool-ii/pgpool-ii_2.2.5] / pool_proto_modules.h
1 /* -*-pgsql-c-*- */
2 /*
3  *
4  * $Header: /cvsroot/pgpool/pgpool-II/pool_proto_modules.h,v 1.1.2.5 2009/10/03 11:55:50 t-ishii Exp $
5  *
6  * pgpool: a language independent connection pool server for PostgreSQL 
7  * written by Tatsuo Ishii
8  *
9  * Copyright (c) 2003-2009      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_proto_modules.h.: header file for pool_proto_modules.c and pool_process_qeury.c
23  *
24  */
25
26 #ifndef POOL_PROTO_MODULES_H
27 #define POOL_PROTO_MODULES_H
28
29 #include "parser/parser.h"
30 #include "parser/pool_memory.h"
31 #include "parser/pg_list.h"
32 #include "parser/parsenodes.h"
33 #include "pool_rewrite_query.h"
34
35 #define SPECIFIED_ERROR 1
36 #define POOL_ERROR_QUERY "send invalid query from pgpool to abort transaction"
37
38
39 /* Prepared statement information */
40 typedef struct {
41         char *portal_name; /* portal name*/
42         Node *stmt;        /* parse tree for prepared statement */
43         char *sql_string;  /* original SQL statement */
44         POOL_MEMORY_POOL *prepare_ctxt; /* memory context for parse tree */
45 } Portal;
46
47 /*
48  * prepared statement list
49  */
50 typedef struct {
51         int size;
52         int cnt;
53         Portal **portal_list;
54 } PreparedStatementList;
55
56 extern int force_replication;
57 extern int replication_was_enabled;             /* replication mode was enabled */
58 extern int master_slave_was_enabled;    /* master/slave mode was enabled */
59 extern int internal_transaction_started;                /* to issue table lock command a transaction
60                                                                                                    has been started internally */
61 extern int in_progress;         /* indicates while doing something after receiving Query */
62 extern int mismatch_ntuples;    /* number of updated tuples */
63 extern char *copy_table;  /* copy table name */
64 extern char *copy_schema;  /* copy table name */
65 extern char copy_delimiter; /* copy delimiter char */
66 extern char *copy_null; /* copy null string */
67 extern void (*pending_function)(PreparedStatementList *p, Portal *portal);
68 extern Portal *pending_prepared_portal;
69 extern Portal *unnamed_statement;
70 extern Portal *unnamed_portal;
71 extern int select_in_transaction; /* non 0 if select query is in transaction */
72 extern int execute_select; /* non 0 if select query is in transaction */
73
74 /* non 0 if "BEGIN" query with extended query protocol received */
75 extern int receive_extended_begin;
76
77 extern int is_select_pgcatalog;
78 extern int is_select_for_update; /* also for SELECT ... INTO */
79 extern bool is_parallel_table;
80 extern char *parsed_query;
81
82 extern PreparedStatementList prepared_list; /* prepared statement name list */
83
84 /*
85  * modules defined in pool_proto_modules.c
86  */
87 extern POOL_STATUS NotificationResponse(POOL_CONNECTION *frontend, 
88                                                                                 POOL_CONNECTION_POOL *backend);
89
90 extern POOL_STATUS SimpleQuery(POOL_CONNECTION *frontend, 
91                                                  POOL_CONNECTION_POOL *backend, char *query);
92
93 extern POOL_STATUS Execute(POOL_CONNECTION *frontend, 
94                                                    POOL_CONNECTION_POOL *backend);
95
96 extern POOL_STATUS Parse(POOL_CONNECTION *frontend,
97                                                  POOL_CONNECTION_POOL *backend);
98
99 extern POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend, 
100                                                                  POOL_CONNECTION_POOL *backend, int send_ready);
101
102 extern POOL_STATUS CompleteCommandResponse(POOL_CONNECTION *frontend, 
103                                                                                    POOL_CONNECTION_POOL *backend);
104
105 extern POOL_STATUS CopyInResponse(POOL_CONNECTION *frontend, 
106                                                                   POOL_CONNECTION_POOL *backend);
107
108 extern POOL_STATUS CopyOutResponse(POOL_CONNECTION *frontend, 
109                                                                    POOL_CONNECTION_POOL *backend);
110
111 extern POOL_STATUS CopyDataRows(POOL_CONNECTION *frontend,
112                                                                 POOL_CONNECTION_POOL *backend, int copyin);
113
114 extern POOL_STATUS CursorResponse(POOL_CONNECTION *frontend, 
115                                                                   POOL_CONNECTION_POOL *backend);
116
117 extern POOL_STATUS EmptyQueryResponse(POOL_CONNECTION *frontend,
118                                                                           POOL_CONNECTION_POOL *backend);
119
120 extern int RowDescription(POOL_CONNECTION *frontend, 
121                                                   POOL_CONNECTION_POOL *backend,
122                                                   short *result);
123
124 extern POOL_STATUS AsciiRow(POOL_CONNECTION *frontend, 
125                                                         POOL_CONNECTION_POOL *backend,
126                                                         short num_fields);
127
128 extern POOL_STATUS BinaryRow(POOL_CONNECTION *frontend, 
129                                                          POOL_CONNECTION_POOL *backend,
130                                                          short num_fields);
131
132 extern POOL_STATUS FunctionCall(POOL_CONNECTION *frontend, 
133                                                                 POOL_CONNECTION_POOL *backend);
134
135 extern POOL_STATUS FunctionResultResponse(POOL_CONNECTION *frontend, 
136                                                                                   POOL_CONNECTION_POOL *backend);
137
138 extern POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION *frontend, 
139                                                                                    POOL_CONNECTION_POOL *backend);
140
141
142 extern POOL_STATUS wait_for_query_response(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, char *string, int protoVersion);
143 extern int is_select_query(Node *node, char *sql);
144 extern int is_sequence_query(Node *node);
145 extern int is_start_transaction_query(Node *node);
146 extern int is_commit_query(Node *node);
147 extern int is_strict_query(Node *node); /* returns non 0 if this is strict query */
148 extern int load_balance_enabled(POOL_CONNECTION_POOL *backend, Node* node, char *sql);
149 extern void start_load_balance(POOL_CONNECTION_POOL *backend);
150 extern void end_load_balance(POOL_CONNECTION_POOL *backend);
151 extern int need_insert_lock(POOL_CONNECTION_POOL *backend, char *query, Node *node);
152 extern POOL_STATUS insert_lock(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, char *query, InsertStmt *node);
153 extern void add_prepared_list(PreparedStatementList *p, Portal *portal);
154 extern void add_unnamed_portal(PreparedStatementList *p, Portal *portal);
155 extern void delete_all_prepared_list(PreparedStatementList *p, Portal *portal);
156 extern char *parse_copy_data(char *buf, int len, char delimiter, int col_id);
157 extern Portal *lookup_prepared_statement_by_portal(PreparedStatementList *p, const char *name);extern Portal *lookup_prepared_statement_by_statement(PreparedStatementList *p, const char *name);
158 extern int check_copy_from_stdin(Node *node); /* returns non 0 if this is a COPY FROM STDIN */
159 extern void query_ps_status(char *query, POOL_CONNECTION_POOL *backend);                /* show ps status */
160 extern POOL_STATUS start_internal_transaction(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, Node *node);
161 extern POOL_STATUS end_internal_transaction(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend);
162 extern int detect_deadlock_error(POOL_CONNECTION *master, int major);
163 extern int detect_serialization_error(POOL_CONNECTION *master, int major);
164 extern int detect_active_sql_transaction_error(POOL_CONNECTION *backend, int major);
165 extern int detect_query_cancel_error(POOL_CONNECTION *backend, int major);
166 extern bool is_partition_table(POOL_CONNECTION_POOL *backend, Node *node);
167 extern POOL_STATUS pool_discard_packet(POOL_CONNECTION_POOL *cp);
168
169 extern int is_drop_database(Node *node);                /* returns non 0 if this is a DROP DATABASE command */
170 extern void process_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend);
171 extern Portal *create_portal(void);
172 extern void del_prepared_list(PreparedStatementList *p, Portal *portal);
173
174 extern POOL_STATUS send_simplequery_message(POOL_CONNECTION *backend, int len, char *string, int major);
175 extern POOL_STATUS send_extended_protocol_message(POOL_CONNECTION_POOL *backend,
176                                                                                                   int node_id, char *kind,
177                                                                                                   int len, char *string);
178
179 extern POOL_STATUS send_execute_message(POOL_CONNECTION_POOL *backend,
180                                                                                 int node_id, int len, char *string);
181
182 extern int synchronize(POOL_CONNECTION *cp);
183 extern POOL_STATUS read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, char *decided_kind);
184 extern POOL_STATUS read_kind_from_one_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, char *kind, int node);
185 extern POOL_STATUS do_error_command(POOL_CONNECTION *backend, int major);
186
187 #endif