The pg_options.sample that is included in 7.0.x cannot actually be used
because of bugs in the routine that reads it. First, it reads only 4095
bytes and second it does not cope with white space within lines.  The
attached patch cures the problem.

It seems to be relevant only to 7.0.x because the entire code has been
removed from 7.1.

Index: src/backend/utils/misc/trace.c
===================================================================
RCS file: /cvs/pgsql-deb/postgresql/src/backend/utils/misc/trace.c,v
retrieving revision 1.1.1.2
diff -c -b -r1.1.1.2 trace.c
*** src/backend/utils/misc/trace.c	2000/11/14 10:40:10	1.1.1.2
--- src/backend/utils/misc/trace.c	2000/11/28 07:43:13
***************
*** 438,444 ****
--- 438,446 ----
  	int			fd;
  	int			n;
  	int			verbose;
+ 	int		incomment = 0;
  	char		buffer[BUF_SIZE];
+ 	char		optbuf[BUF_SIZE];
  	char		c;
  	char	   *s,
  			   *p;
***************
*** 455,478 ****
  #else
  	if ((fd = open(buffer, O_RDONLY | O_BINARY)) < 0)
  #endif
  		return;
  
! 	if ((n = read(fd, buffer, BUF_SIZE - 1)) > 0)
  	{
! 		/* collpse buffer in place removing comments and spaces */
! 		for (s = buffer, p = buffer, c = '\0'; s < (buffer + n);)
  		{
  			switch (*s)
  			{
  				case '#':
  					while ((s < (buffer + n)) && (*s++ != '\n'));
  					break;
- 				case ' ':
- 				case '\t':
- 				case '\n':
  				case '\r':
  					if (c != ',')
  						c = *p++ = ',';
  					s++;
  					break;
  				default:
--- 457,490 ----
  #else
  	if ((fd = open(buffer, O_RDONLY | O_BINARY)) < 0)
  #endif
+ 	{
+ 		fprintf(stderr,"Couldn't open %s\n",buffer);
  		return;
+ 	}
  
! 	p = optbuf;
! 	c = '\0';
! 	while ((n = read(fd, buffer, BUF_SIZE - 1)) > 0)
  	{
! 		if (incomment && (*buffer != '\n'))
! 			*buffer = '#';
! 
! 		/* read in options removing comments and spaces */
! 		for (s = buffer; s < (buffer + n);)
  		{
  			switch (*s)
  			{
  				case '#':
+ 					incomment = 1;
  					while ((s < (buffer + n)) && (*s++ != '\n'));
  					break;
  				case '\r':
+ 				case '\n':
+ 					incomment = 0;
  					if (c != ',')
  						c = *p++ = ',';
+ 				case ' ':
+ 				case '\t':
  					s++;
  					break;
  				default:
***************
*** 480,494 ****
  					break;
  			}
  		}
  		if (c == ',')
  			p--;
  		*p = '\0';
  		verbose = pg_options[TRACE_VERBOSE];
! 		parse_options(buffer, true);
  		verbose |= pg_options[TRACE_VERBOSE];
  		if (verbose || postgres_signal_arg == SIGHUP)
! 			tprintf(TRACE_ALL, "read_pg_options: %s", buffer);
! 	}
  
  	close(fd);
  }
--- 492,506 ----
  					break;
  			}
  		}
+ 	}
  	if (c == ',')
  		p--;
  	*p = '\0';
  	verbose = pg_options[TRACE_VERBOSE];
! 	parse_options(optbuf, true);
  	verbose |= pg_options[TRACE_VERBOSE];
  	if (verbose || postgres_signal_arg == SIGHUP)
! 		tprintf(TRACE_ALL, "read_pg_options: %s", optbuf);
  
  	close(fd);
  }

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "The earth is the LORD'S, and the fullness thereof; the
      world, and they that dwell therein."       Psalms 24:1



Tue, 28 Nov 2000 10:47:28 +0000
"Oliver Elphick" <olly@lfix.co.uk>
Patch for 7.0.3 code to read pg_options