Index: src/interfaces/libpq/fe-connect.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.264
diff -c -c -r1.264 fe-connect.c
*** src/interfaces/libpq/fe-connect.c	29 Nov 2003 19:52:11 -0000	1.264
--- src/interfaces/libpq/fe-connect.c	19 Dec 2003 21:18:13 -0000
***************
*** 2367,2373 ****
  {
  	char	   *service = conninfo_getval(options, "service");
  	char	   *serviceFile = SYSCONFDIR "/pg_service.conf";
! 	int			group_found = 0;
  	int			linenr = 0,
  				i;
  
--- 2367,2373 ----
  {
  	char	   *service = conninfo_getval(options, "service");
  	char	   *serviceFile = SYSCONFDIR "/pg_service.conf";
! 	bool		group_found = false;
  	int			linenr = 0,
  				i;
  
***************
*** 2431,2439 ****
  
  				if (strncmp(line + 1, service, strlen(service)) == 0 &&
  					line[strlen(service) + 1] == ']')
! 					group_found = 1;
  				else
! 					group_found = 0;
  			}
  			else
  			{
--- 2431,2439 ----
  
  				if (strncmp(line + 1, service, strlen(service)) == 0 &&
  					line[strlen(service) + 1] == ']')
! 					group_found = true;
  				else
! 					group_found = false;
  			}
  			else
  			{
***************
*** 2445,2451 ****
  					 */
  					char	   *key,
  							   *val;
! 					int			found_keyword;
  
  					key = line;
  					val = strchr(line, '=');
--- 2445,2451 ----
  					 */
  					char	   *key,
  							   *val;
! 					bool		found_keyword;
  
  					key = line;
  					val = strchr(line, '=');
***************
*** 2461,2491 ****
  					*val++ = '\0';
  
  					/*
- 					 * If not already set, set the database name to the
- 					 * name of the service
- 					 */
- 					for (i = 0; options[i].keyword; i++)
- 					{
- 						if (strcmp(options[i].keyword, "dbname") == 0)
- 						{
- 							if (options[i].val == NULL)
- 								options[i].val = strdup(service);
- 							break;
- 						}
- 					}
- 
- 					/*
  					 * Set the parameter --- but don't override any
  					 * previous explicit setting.
  					 */
! 					found_keyword = 0;
  					for (i = 0; options[i].keyword; i++)
  					{
  						if (strcmp(options[i].keyword, key) == 0)
  						{
  							if (options[i].val == NULL)
  								options[i].val = strdup(val);
! 							found_keyword = 1;
  							break;
  						}
  					}
--- 2461,2477 ----
  					*val++ = '\0';
  
  					/*
  					 * Set the parameter --- but don't override any
  					 * previous explicit setting.
  					 */
! 					found_keyword = false;
  					for (i = 0; options[i].keyword; i++)
  					{
  						if (strcmp(options[i].keyword, key) == 0)
  						{
  							if (options[i].val == NULL)
  								options[i].val = strdup(val);
! 							found_keyword = true;
  							break;
  						}
  					}
Index: src/interfaces/libpq/pg_service.conf.sample
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/pg_service.conf.sample,v
retrieving revision 1.1
diff -c -c -r1.1 pg_service.conf.sample
*** src/interfaces/libpq/pg_service.conf.sample	3 Feb 2003 14:24:07 -0000	1.1
--- src/interfaces/libpq/pg_service.conf.sample	19 Dec 2003 21:18:13 -0000
***************
*** 5,16 ****
  # multiple services in this file.  Each starts with a service name in  
  # brackets.  Subsequent lines have connection configuration parameters of
  # the pattern  "param=value".  A sample configuration for template1 is 
! # included in this file.  If no database name is specified, it is assumed 
! # to match the service name.  Lines beginning with '#' are comments.
  #
  # Copy this to your sysconf directory (typically /usr/local/pgsql/etc) and
  # rename it pg_service.conf.
  #
  #
  #[template1]
  #user=postgres
--- 5,16 ----
  # multiple services in this file.  Each starts with a service name in  
  # brackets.  Subsequent lines have connection configuration parameters of
  # the pattern  "param=value".  A sample configuration for template1 is 
! # included in this file.  Lines beginning with '#' are comments.
  #
  # Copy this to your sysconf directory (typically /usr/local/pgsql/etc) and
  # rename it pg_service.conf.
  #
  #
  #[template1]
+ #dbname=template1
  #user=postgres
