1 /*
2  *
3  * pgpool: a language independent connection pool server for PostgreSQL
4  * written by Tatsuo Ishii
5  *
6  * Copyright (c) 2003-2020	PgPool Global Development Group
7  *
8  * Permission to use, copy, modify, and distribute this software and
9  * its documentation for any purpose and without fee is hereby
10  * granted, provided that the above copyright notice appear in all
11  * copies and that both that copyright notice and this permission
12  * notice appear in supporting documentation, and that the name of the
13  * author not be used in advertising or publicity pertaining to
14  * distribution of the software without specific, written prior
15  * permission. The author makes no representations about the
16  * suitability of this software for any purpose.  It is provided "as
17  * is" without express or implied warranty.
18  *
19  */
20 
21 
22 #ifndef pool_process_query_h
23 #define pool_process_query_h
24 
25 #define LOCK_COMMENT "/*INSERT LOCK*/"
26 #define LOCK_COMMENT_SZ (sizeof(LOCK_COMMENT)-1)
27 #define NO_LOCK_COMMENT "/*NO INSERT LOCK*/"
28 #define NO_LOCK_COMMENT_SZ (sizeof(NO_LOCK_COMMENT)-1)
29 #define NO_LOAD_BALANCE "/*NO LOAD BALANCE*/"
30 #define NO_LOAD_BALANCE_COMMENT_SZ (sizeof(NO_LOAD_BALANCE)-1)
31 
32 
33 extern void reset_variables(void);
34 extern void reset_connection(void);
35 extern void per_node_statement_log(POOL_CONNECTION_POOL * backend,
36 								   int node_id, char *query);
37 extern int	pool_extract_error_message(bool read_kind, POOL_CONNECTION * backend,
38 									   int major, bool unread, char **message);
39 extern POOL_STATUS do_command(POOL_CONNECTION * frontend, POOL_CONNECTION * backend,
40 							  char *query, int protoMajor, int pid, int key, int no_ready_for_query);
41 extern void do_query(POOL_CONNECTION * backend, char *query, POOL_SELECT_RESULT * *result, int major);
42 extern void free_select_result(POOL_SELECT_RESULT * result);
43 extern int	compare(const void *p1, const void *p2);
44 extern void do_error_execute_command(POOL_CONNECTION_POOL * backend, int node_id, int major);
45 extern POOL_STATUS pool_discard_packet_contents(POOL_CONNECTION_POOL * cp);
46 extern void pool_dump_valid_backend(int backend_id);
47 extern bool pool_push_pending_data(POOL_CONNECTION * backend);
48 
49 
50 extern void pool_send_frontend_exits(POOL_CONNECTION_POOL * backend);
51 extern POOL_STATUS ParameterStatus(POOL_CONNECTION * frontend,
52 								   POOL_CONNECTION_POOL * backend);
53 
54 extern void pool_send_error_message(POOL_CONNECTION * frontend, int protoMajor,
55 						char *code,
56 						char *message,
57 						char *detail,
58 						char *hint,
59 						char *file,
60 						int line);
61 extern void pool_send_fatal_message(POOL_CONNECTION * frontend, int protoMajor,
62 						char *code,
63 						char *message,
64 						char *detail,
65 						char *hint,
66 						char *file,
67 						int line);
68 extern void pool_send_severity_message(POOL_CONNECTION * frontend, int protoMajor,
69 						   char *code,
70 						   char *message,
71 						   char *detail,
72 						   char *hint,
73 						   char *file,
74 						   char *severity,
75 						   int line);
76 
77 extern POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend);
78 extern POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, int len, char *contents);
79 
80 extern POOL_STATUS pool_process_query(POOL_CONNECTION * frontend,
81 POOL_CONNECTION_POOL * backend,
82 int reset_request);
83 extern bool is_backend_cache_empty(POOL_CONNECTION_POOL * backend);
84 extern void pool_send_readyforquery(POOL_CONNECTION * frontend);
85 
86 extern char *extract_error_kind(char *message, int major);
87 
88 #endif /* pool_process_query_h */
89