4
* $Header: /cvsroot/pgpool/pgpool-II/pool.h,v 1.36.2.4 2009/07/22 08:46:55 t-ishii Exp $
4
* $Header: /cvsroot/pgpool/pgpool-II/pool.h,v 1.56 2010/02/03 08:11:42 t-ishii Exp $
6
6
* pgpool: a language independent connection pool server for PostgreSQL
7
7
* written by Tatsuo Ishii
9
* Copyright (c) 2003-2009 PgPool Global Development Group
9
* Copyright (c) 2003-2010 PgPool Global Development Group
11
11
* Permission to use, copy, modify, and distribute this software and
12
12
* its documentation for any purpose and without fee is hereby
161
170
char *health_check_user; /* PostgreSQL user name for health check */
162
171
char *failover_command; /* execute command when failover happens */
163
172
char *failback_command; /* execute command when failback happens */
175
* If true, trigger fail over when writing to the backend
176
* communication socket fails. This is the same behavior of
177
* pgpool-II 2.2.x or earlier. If set to false, pgpool will report
178
* an error and disconnect the session.
180
int fail_over_on_backend_error;
164
182
char *recovery_user; /* PostgreSQL user name for online recovery */
165
183
char *recovery_password; /* PostgreSQL user password for online recovery */
166
184
char *recovery_1st_stage_command; /* Online recovery command in 1st stage */
173
191
data consistency */
174
192
int ignore_leading_white_space; /* ignore leading white spaces of each query */
175
193
int log_statement; /* 0:false, 1: true - logs all SQL statements */
194
int log_per_node_statement; /* 0:false, 1: true - logs per node detailed SQL statements */
177
196
int parallel_mode; /* if non 0, run in parallel query mode */
186
205
char *system_db_user; /* user name to access system DB */
187
206
char *system_db_password; /* password to access system DB */
208
char *lobj_lock_table; /* table name to lock for rewriting lo_creat */
189
210
BackendDesc *backend_desc; /* PostgreSQL Server description. Placed on shared memory */
191
212
LOAD_BALANCE_STATUS load_balance_status[MAX_NUM_BACKENDS]; /* to remember which DB node is selected for load balancing */
195
216
int replication_enabled; /* replication mode enabled */
196
217
int master_slave_enabled; /* master/slave mode enabled */
197
218
int num_reset_queries; /* number of queries in reset_query_list */
220
/* ssl configuration */
221
int ssl; /* if non 0, activate ssl support (frontend+backend) */
222
char *ssl_cert; /* path to ssl certificate (frontend only) */
223
char *ssl_key; /* path to ssl key (frontend only) */
224
char *ssl_ca_cert; /* path to root (CA) certificate */
225
char *ssl_ca_cert_dir; /* path to directory containing CA certificates */
200
228
#define MAX_PASSWORD_SIZE 1024
215
243
int wbufsz; /* write buffer size */
216
244
int wbufpo; /* buffer offset */
247
SSL_CTX *ssl_ctx; /* SSL connection context */
248
SSL *ssl; /* SSL connection */
250
int ssl_active; /* SSL is failed if < 0, off if 0, on if > 0 */
218
252
char *hp; /* pending data buffer head address */
219
253
int po; /* pending data offset */
220
254
int bufsz; /* pending data buffer size */
347
* Relation cache structure
349
#define MAX_ITEM_LENGTH 1024
351
/* Relation lookup cache structure */
353
typedef void *(*func_ptr) ();
356
char dbname[MAX_ITEM_LENGTH]; /* database name */
357
char relname[MAX_ITEM_LENGTH]; /* table name */
358
void *data; /* user data */
359
int refcnt; /* reference count */
360
int session_id; /* LocalSessionId */
364
int num; /* number of cache items */
365
char sql[MAX_ITEM_LENGTH]; /* Query to relation */
367
* User defined function to be called at data register.
368
* Argument is POOL_SELECT_RESULT *.
369
* This function must return a pointer to be
370
* saved in cache->data.
372
func_ptr register_func;
374
* User defined function to be called at data unregister.
375
* Argument cache->data.
377
func_ptr unregister_func;
378
bool cache_is_session_local; /* True if cache life time is session local */
379
PoolRelCache *cache; /* cache data */
313
384
#define NUM_BACKENDS (in_load_balance? (selected_slot+1) : \
314
385
(((!REPLICATION && !PARALLEL_MODE)||master_slave_dml)? Req_info->master_node_id+1: \
350
421
#define LOCK_COMMENT_SZ (sizeof(LOCK_COMMENT)-1)
351
422
#define NO_LOCK_COMMENT "/*NO INSERT LOCK*/"
352
423
#define NO_LOCK_COMMENT_SZ (sizeof(NO_LOCK_COMMENT)-1)
424
#define NO_LOAD_BALANCE "/*NO LOAD BALANCE*/"
425
#define NO_LOAD_BALANCE_COMMENT_SZ (sizeof(NO_LOAD_BALANCE)-1)
354
427
#define MAX_NUM_SEMAPHORES 3
355
428
#define CONN_COUNTER_SEM 0
454
529
extern int pool_init_cp(void);
455
530
extern POOL_STATUS pool_process_query(POOL_CONNECTION *frontend,
456
531
POOL_CONNECTION_POOL *backend,
457
int connection_reuse,
458
int first_ready_for_query_received);
460
534
extern POOL_CONNECTION *pool_open(int fd);
461
535
extern void pool_close(POOL_CONNECTION *cp);
477
551
extern void pool_discard_cp(char *user, char *database, int protoMajor);
478
552
extern void pool_backend_timer(void);
554
/* SSL functionality */
555
extern void pool_ssl_negotiate_serverclient(POOL_CONNECTION *cp);
556
extern void pool_ssl_negotiate_clientserver(POOL_CONNECTION *cp);
557
extern void pool_ssl_close(POOL_CONNECTION *cp);
558
extern int pool_ssl_read(POOL_CONNECTION *cp, void *buf, int size);
559
extern int pool_ssl_write(POOL_CONNECTION *cp, const void *buf, int size);
480
561
extern POOL_STATUS ErrorResponse(POOL_CONNECTION *frontend,
481
562
POOL_CONNECTION_POOL *backend);
607
extern void pool_send_fatal_message(POOL_CONNECTION *frontend, int protoMajor,
614
extern void pool_send_severity_message(POOL_CONNECTION *frontend, int protoMajor,
526
622
extern void pool_send_readyforquery(POOL_CONNECTION *frontend);
527
623
extern int send_startup_packet(POOL_CONNECTION_POOL_SLOT *cp);
528
624
extern void pool_free_startup_packet(StartupPacket *sp);
529
625
extern void child_exit(int code);
531
extern void connection_count_up(void);
532
extern void connection_count_down(void);
534
627
extern int health_check(void);
535
628
extern int system_db_health_check(void);
553
646
extern POOL_CONNECTION_POOL_SLOT *make_persistent_db_connection(
554
647
char *hostname, int port, char *dbname, char *user, char *password);
556
extern POOL_STATUS do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT **result);
558
649
/* define pool_system.c */
559
650
extern POOL_CONNECTION_POOL_SLOT *pool_system_db_connection(void);
560
651
extern DistDefInfo *pool_get_dist_def_info (char * dbname, char * schema_name, char * table_name);
596
687
extern void pool_set_nonblock(int fd);
597
688
extern void pool_unset_nonblock(int fd);
598
689
extern void cancel_request(CancelPacket *sp);
690
extern void check_stop_request(void);
692
/* pool_process_query.c */
693
extern void reset_variables(void);
694
extern void reset_connection(void);
695
extern void per_node_statement_log(POOL_CONNECTION_POOL *backend, int node_id, char *query);
696
extern void per_node_error_log(POOL_CONNECTION_POOL *backend, int node_id, char *query, char *prefix, bool unread);
697
extern int pool_extract_error_message(bool read_kind, POOL_CONNECTION *backend, int major, bool unread, char **message);
698
extern POOL_STATUS do_command(POOL_CONNECTION *frontend, POOL_CONNECTION *backend,
699
char *query, int protoMajor, int pid, int key, int no_ready_for_query);
700
extern POOL_STATUS do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT **result, int major);
701
extern void free_select_result(POOL_SELECT_RESULT *result);
703
/* pool_relcache.c */
704
extern POOL_RELCACHE *pool_create_relcache(int cachesize, char *sql,
705
func_ptr register_func, func_ptr unregister_func,
706
bool issessionlocal);
707
extern void pool_discard_relcache(POOL_RELCACHE *relcache);
708
extern void *pool_search_relcache(POOL_RELCACHE *relcache, POOL_CONNECTION_POOL *backend, char *table);
709
extern void *int_register_func(POOL_SELECT_RESULT *res);
710
extern void *int_unregister_func(void *data);
713
extern char *pool_rewrite_lo_creat(char kind, char *packet, int packet_len, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, int* len);
600
715
#endif /* POOL_H */