4 * $Header: /cvsroot/pgpool/pgpool-II/pool_type.h,v 1.9 2008/12/30 00:59:35 t-ishii Exp $
6 * pgpool: a language independent connection pool server for PostgreSQL
7 * written by Tatsuo Ishii
9 * Copyright (c) 2003-2008 PgPool Global Development Group
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.
22 * pool_type.h.: type definition header file
30 #include <sys/types.h>
31 #include <sys/socket.h>
33 /* Define common boolean type. C++ and BEOS already has it so exclude them. */
37 #endif /* __cplusplus */
38 #endif /* c_plusplus */
46 #define true ((bool) 1)
49 #define TRUE ((bool) 1)
52 #define false ((bool) 0)
55 #define FALSE ((bool) 0)
61 * startup packet definitions (v2) stolen from PostgreSQL
63 #define SM_DATABASE 64
69 #define MAX_NUM_BACKENDS 128
70 #define MAX_CONNECTION_SLOTS 128
71 #define MAX_DB_HOST_NAMELEN 128
72 #define MAX_PATH_LENGTH 256
75 CON_UNUSED, /* unused slot */
76 CON_CONNECT_WAIT, /* waiting for connection starting */
77 CON_UP, /* up and running */
78 CON_DOWN /* down, disconnected */
84 } LOAD_BALANCE_STATUS;
87 * PostgreSQL backend descriptor. Placed on shared memory area.
90 char backend_hostname[MAX_DB_HOST_NAMELEN]; /* backend host name */
91 int backend_port; /* backend port numbers */
92 BACKEND_STATUS backend_status; /* backend status */
93 double backend_weight; /* normalized backend load balance ratio */
94 double unnormalized_weight; /* descripted parameter */
95 char backend_data_directory[MAX_PATH_LENGTH];
99 int num_backends; /* number of used PostgreSQL backends */
100 BackendInfo backend_info[MAX_NUM_BACKENDS];
104 * Connection pool information. Placed on shared memory area.
107 char database[SM_DATABASE]; /* Database name */
108 char user[SM_USER]; /* User name */
109 int major; /* protocol major version */
110 int minor; /* protocol minor version */
111 int pid; /* backend process id */
112 int key; /* cancel key */
113 int counter; /* used counter */
114 time_t create_time; /* connection creation time */
115 int load_balancing_node; /* load balancing node */
120 * process information
121 * This object put on shared memory.
124 pid_t pid; /* OS's process id */
125 time_t start_time; /* fork() time */
126 ConnectionInfo *connection_info; /* head of the connection info for this process */
131 * system db structure
134 char *dbname; /* database name */
135 char *schema_name; /* schema name */
136 char *table_name; /* table name */
137 char *dist_key_col_name;/* column name for dist key */
138 int dist_key_col_id; /* column index id for dist key */
139 int col_num; /* number of clumn*/
140 char **col_list; /* column list */
141 char **type_list; /* type list */
142 char *dist_def_func; /* function name of distribution rule */
143 char *prepare_name; /* prepared statement name */
144 int is_created_prepare; /* is prepare statement created? */
148 char *dbname; /* database name */
149 char *schema_name; /* schema name */
150 char *table_name; /* table name */
151 int col_num; /* number of clumn*/
152 char **col_list; /* column list */
153 char **type_list; /* type list */
154 char *prepare_name; /* prepared statement name */
155 int is_created_prepare; /* is prepare statement created? */
159 int has_prepared_statement; /* true if the current session has prepared statement created */
160 char *register_prepared_statement; /* prepared statement name for cache register */
161 } QueryCacheTableInfo;
164 char *hostname; /* host name */
165 int port; /* port number */
166 char *user; /* login user name */
167 char *password; /* login password */
168 char *schema_name; /* schema name */
169 char *database_name; /* database name */
170 int repli_def_num; /* number of replication table */
171 int dist_def_num; /* number of distribution table */
172 RepliDefInfo *repli_def_slot; /* replication rule list */
173 DistDefInfo *dist_def_slot; /* distribution rule list */
174 QueryCacheTableInfo query_cache_table_info; /* query cache db session info */
175 BACKEND_STATUS system_db_status;
179 * It seems that sockaddr_storage is now commonly used in place of sockaddr.
180 * So, define it if it is not define yet, and create new SockAddr structure
181 * that uses sockaddr_storage.
183 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
185 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
186 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY
187 #define ss_family __ss_family
189 #error struct sockaddr_storage does not provide an ss_family member
190 #endif /* HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */
191 #endif /* HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY */
193 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN
194 #define ss_len __ss_len
195 #define HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN 1
196 #endif /* HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN */
198 #else /* !HAVE_STRUCT_SOCKADDR_STORAGE */
200 /* Define a struct sockaddr_storage if we don't have one. */
201 struct sockaddr_storage
205 struct sockaddr sa; /* get the system-dependent fields */
206 long int ss_align; /* ensures struct is properly aligned. original uses int64 */
207 char ss_pad[128]; /* ensures struct has desired size */
212 #define ss_family ss_stuff.sa.sa_family
213 /* It should have an ss_len field if sockaddr has sa_len. */
214 #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
215 #define ss_len ss_stuff.sa.sa_len
216 #define HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN 1
218 #endif /* HAVE_STRUCT_SOCKADDR_STORAGE */
222 struct sockaddr_storage addr;
223 /* ACCEPT_TYPE_ARG3 - Third argument type of accept().
224 * It is defined in ac_func_accept_argtypes.m4
226 ACCEPT_TYPE_ARG3 salen;
230 /* UserAuth type used for HBA which indicates the authentication method */
231 typedef enum UserAuth
247 #define AUTH_REQ_OK 0 /* User is authenticated */
248 #define AUTH_REQ_KRB4 1 /* Kerberos V4 */
249 #define AUTH_REQ_KRB5 2 /* Kerberos V5 */
250 #define AUTH_REQ_PASSWORD 3 /* Password */
251 #define AUTH_REQ_CRYPT 4 /* crypt password */
252 #define AUTH_REQ_MD5 5 /* md5 password */
253 #define AUTH_REQ_SCM_CREDS 6 /* transfer SCM credentials */
255 typedef unsigned int AuthRequest;
257 #endif /* POOL_TYPE_H */