Index: main.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/main.c,v
retrieving revision 1.102
diff -c -r1.102 main.c
*** main.c	25 May 2011 17:14:24 -0000	1.102
--- main.c	27 May 2011 10:14:53 -0000
***************
*** 1837,1846 ****
  
   Retry:
  	/*
! 	 * First we try with "postgres" database.
  	 */
  	if (is_first)
! 		dbname = "postgres";
  
  	memset(&mysp, 0, sizeof(mysp));
  	mysp.len = htonl(296);
--- 1837,1846 ----
  
   Retry:
  	/*
! 	 * First we try with user specified database.
  	 */
  	if (is_first)
! 		dbname = pool_config->pool_conn_dbname;
  
  	memset(&mysp, 0, sizeof(mysp));
  	mysp.len = htonl(296);
***************
*** 2473,2479 ****
  		bkinfo = pool_get_node_info(i);
  		s = make_persistent_db_connection(bkinfo->backend_hostname, 
  										  bkinfo->backend_port,
! 										  "postgres",
  										  pool_config->health_check_user,
  										  "");
  		if (!s)
--- 2473,2479 ----
  		bkinfo = pool_get_node_info(i);
  		s = make_persistent_db_connection(bkinfo->backend_hostname, 
  										  bkinfo->backend_port,
! 										  pool_config->pool_conn_dbname,
  										  pool_config->health_check_user,
  										  "");
  		if (!s)
Index: pgpool.conf.sample
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pgpool.conf.sample,v
retrieving revision 1.45
diff -c -r1.45 pgpool.conf.sample
*** pgpool.conf.sample	21 Apr 2011 05:00:52 -0000	1.45
--- pgpool.conf.sample	27 May 2011 10:14:57 -0000
***************
*** 46,51 ****
--- 46,53 ----
  
  # - Backend Connection Settings -
  
+ #pool_conn_dbname = 'postgres'	   # Database name to which pgpool will connect.
+ 
  #backend_hostname0 = 'host1'       # Host name or IP address to connect to for backend 0
  #backend_port0 = 5432              # Port number for backend 0
  #backend_weight0 = 1               # Weight for backend 0 (only in load balancing mode)
Index: pgpool.conf.sample-master-slave
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pgpool.conf.sample-master-slave,v
retrieving revision 1.19
diff -c -r1.19 pgpool.conf.sample-master-slave
*** pgpool.conf.sample-master-slave	11 May 2011 01:51:36 -0000	1.19
--- pgpool.conf.sample-master-slave	27 May 2011 10:15:04 -0000
***************
*** 46,51 ****
--- 46,53 ----
  
  # - Backend Connection Settings -
  
+ #pool_conn_dbname = 'postgres'	   # Database name to which pgpool will connect.
+ 
  backend_hostname0 = 'host1'        # Host name or IP address to connect to for backend 0
  backend_port0 = 5432               # Port number for backend 0
  backend_weight0 = 1                # Weight for backend 0 (only in load balancing mode)
Index: pgpool.conf.sample-replication
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pgpool.conf.sample-replication,v
retrieving revision 1.17
diff -c -r1.17 pgpool.conf.sample-replication
*** pgpool.conf.sample-replication	21 Apr 2011 05:00:52 -0000	1.17
--- pgpool.conf.sample-replication	27 May 2011 10:15:49 -0000
***************
*** 46,51 ****
--- 46,53 ----
  
  # - Backend Connection Settings -
  
+ #pool_conn_dbname = 'postgres'	   # Database name to which pgpool will connect.
+ 
  backend_hostname0 = 'host1'        # Host name or IP address to connect to for backend 0
  backend_port0 = 5432               # Port number for backend 0
  backend_weight0 = 1                # Weight for backend 0 (only in load balancing mode)
Index: pgpool.conf.sample-stream
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pgpool.conf.sample-stream,v
retrieving revision 1.12
diff -c -r1.12 pgpool.conf.sample-stream
*** pgpool.conf.sample-stream	11 May 2011 01:51:36 -0000	1.12
--- pgpool.conf.sample-stream	27 May 2011 10:15:50 -0000
***************
*** 46,51 ****
--- 46,53 ----
  
  # - Backend Connection Settings -
  
+ #pool_conn_dbname = 'postgres'	   # Database name to which pgpool will connect.
+ 
  backend_hostname0 = 'host1'       # Host name or IP address to connect to for backend 0
  backend_port0 = 5432              # Port number for backend 0
  backend_weight0 = 1               # Weight for backend 0 (only in load balancing mode)
Index: pool_config.h
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pool_config.h,v
retrieving revision 1.13
diff -c -r1.13 pool_config.h
*** pool_config.h	30 Mar 2011 02:13:07 -0000	1.13
--- pool_config.h	27 May 2011 10:15:50 -0000
***************
*** 169,174 ****
--- 169,175 ----
  	char *ssl_ca_cert_dir;	/* path to directory containing CA certificates */
  
  	time_t relcache_expire;		/* relation cache life time in seconds */
+ 	char *pool_conn_dbname;     /* dbname used for making connection to PostgreSQL server */
  
  	/* followings are for regex support and do not exist in the configuration file */
  	RegPattern *lists_patterns; /* Precompiled regex patterns for black/white lists */
Index: pool_config.l
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pool_config.l,v
retrieving revision 1.56
diff -c -r1.56 pool_config.l
*** pool_config.l	6 May 2011 23:43:26 -0000	1.56
--- pool_config.l	27 May 2011 10:15:52 -0000
***************
*** 210,215 ****
--- 210,216 ----
  	pool_config->lists_patterns = NULL;
  	pool_config->pattc = 0;
  	pool_config->current_pattern_size = 0;
+ 	pool_config->pool_conn_dbname = "postgres";
  
  	res = gethostname(localhostname,sizeof(localhostname));
  	if(res !=0 )
***************
*** 1716,1721 ****
--- 1717,1740 ----
  			}
  			pool_config->relcache_expire = v;
  		}
+ 		else if (!strcmp(key, "pool_conn_dbname") && CHECK_CONTEXT(INIT_CONFIG, context))
+ 		{
+ 			char *str;
+ 
+ 			if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ 			{
+ 				PARSE_ERROR();
+ 				fclose(fd);
+ 				return(-1);
+ 			}
+ 			str = extract_string(yytext, token);
+ 			if (str == NULL)
+ 			{
+ 				fclose(fd);
+ 				return(-1);
+ 			}
+ 			pool_config->pool_conn_dbname = str;
+ 		}
  
  	}
  
Index: pool_worker_child.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pool_worker_child.c,v
retrieving revision 1.9
diff -c -r1.9 pool_worker_child.c
*** pool_worker_child.c	23 May 2011 19:44:00 -0000	1.9
--- pool_worker_child.c	27 May 2011 10:15:53 -0000
***************
*** 154,160 ****
  			bkinfo = pool_get_node_info(i);
  			s = make_persistent_db_connection(bkinfo->backend_hostname, 
  											  bkinfo->backend_port,
! 											  "postgres",
  											  pool_config->health_check_user,
  											  "");
  			if (s)
--- 154,160 ----
  			bkinfo = pool_get_node_info(i);
  			s = make_persistent_db_connection(bkinfo->backend_hostname, 
  											  bkinfo->backend_port,
! 											  pool_config->pool_conn_dbname,
  											  pool_config->health_check_user,
  											  "");
  			if (s)
Index: recovery.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/recovery.c,v
retrieving revision 1.21
diff -c -r1.21 recovery.c
*** recovery.c	25 Apr 2011 22:58:04 -0000	1.21
--- recovery.c	27 May 2011 10:15:53 -0000
***************
*** 281,289 ****
  	snprintf(port_str, sizeof(port_str),"%d", backend->backend_port);
  
  	/*
! 	 * First we try with "postgres" database.
  	 */
! 	dbname = "postgres";
  
  	do {
  		ConnStatusType r;
--- 281,289 ----
  	snprintf(port_str, sizeof(port_str),"%d", backend->backend_port);
  
  	/*
! 	 * First we try with user specified database.
  	 */
! 	dbname = pool_config->pool_conn_dbname;
  
  	do {
  		ConnStatusType r;
