Subject: Re: [PORTS] [PATCH]: Building PostgreSQL 7.0.2 on Cygwin 1.1.4 (T ake 2)
From: Pete Forman <[email-masked]>
To: Jason Tishler <[email-masked]>
Cc: [email-masked], Cygwin <[email-masked]>
Date: Thu, 26 Oct 2000 10:25:21 +0100 (BST)

Jason Tishler writes:
 > On Thu, Oct 19, 2000 at 08:07:39AM +0100, Pete Forman wrote:
 > > Jason Tishler writes:
 > >  > Unfortunately, two different version of the Cygwin DLL can not
 > >  > coexist on the same system.  So, if some app needs the b20 DLL and
 > >  > PostgreSQL needs the 1.1.4 DLL you are SOL.
 > > 
 > > Why so?  I have both B20.1 and 1.1.4 on my system at the moment.  PATH
 > > determines which is used by any particular app.  And as Earnie says,
 > > the 1.1.4 DLL should be good for older apps.
 > 
 > I was wrong.  I thought that b20.1 used cygwin.dll not cygwin1.dll --
 > it's been a while since I used b20.1.  I'm very glad to hear that older
 > apps can use the 1.1.4 DLL too.
 > 
 > BTW since you have b20.1, would you be willing to build and test my
 > patched version of PostgreSQL 7.0.2?

That test is now done.  The only tests that fail are those involving
timezones.

The build and test was not that smooth.  Overall I'd recommend
upgrading to Cygwin 1.1.4 or later rather than applying all the fixes
needed for B20.1.

I revised Jason's patches for two of the files.  My attached patch is
against the original 7.0.2 code.  Jason's patch should be edited to
remove the sections for backend/utils/error/elog.c and exc.c.  His
patch was posted to PORTS on Tue, 26 Sep 2000 15:21:46 -0400.

This patch is for 7.0.2.  I am sending a patch to do the same thing
for 7.1 to the PATCHES mailing list.  It works around the lack of
sys_nerr on Cygwin B20.1 and BeOS.  More details on pgsql-patches.

*** src/backend/utils/error/elog.c.orig	Sat Apr 15 20:13:08 2000
--- src/backend/utils/error/elog.c	Fri Oct 20 14:56:05 2000
***************
*** 37,45 ****
  #include "utils/trace.h"
  #include "commands/copy.h"
  
- extern int	errno;
- extern int	sys_nerr;
- 
  extern CommandDest whereToSendOutput;
  
  #ifdef USE_SYSLOG
--- 37,42 ----
***************
*** 105,110 ****
--- 102,108 ----
  	char	   *bp;
  	int			indent = 0;
  	int			space_needed;
+         int			errno_copy = errno;
  
  #ifdef USE_SYSLOG
  	int			log_level;
***************
*** 154,165 ****
  			break;
  	}
  
! 	/* get errno string for %m */
! 	if (errno < sys_nerr && errno >= 0)
! 		errorstr = strerror(errno);
! 	else
  	{
! 		sprintf(errorstr_buf, "error %d", errno);
  		errorstr = errorstr_buf;
  	}
  
--- 152,173 ----
  			break;
  	}
  
! 	/*
! 	 * get errno string for %m
! 	 * Standard UNIX (XPG4v2/UNIX95 and later) says that errno will be set
! 	 * (to EINVAL) if the argument to strerror() is out of range.
! 	 * IRIX and Solaris actually return NULL without setting errno.
! 	 * Others such as AIX, Cygwin and Linux return a string for all values.
! 	 *   This string contains a number for out of range values.
! 	 * HPUX and QNX return the same string for all out of range values.
! 	 *   Those will not be well served by this code.  However it is highly
! 	 *   unlikely that this code will be called with an out of range errno.
! 	 */
! 	errno = 0;
! 	errorstr = strerror(errno_copy);
! 	if (errno != 0 || errorstr == NULL)
  	{
! 		sprintf(errorstr_buf, "error %d", errno_copy);
  		errorstr = errorstr_buf;
  	}
  
*** src/backend/utils/error/exc.c.orig	Wed Jan 26 06:57:20 2000
--- src/backend/utils/error/exc.c	Fri Oct 20 15:59:06 2000
***************
*** 100,108 ****
  		 ExcData data,
  		 ExcMessage message)
  {
! 	extern int	errno;
! 	extern int	sys_nerr;
! 
  #ifdef	lint
  	data = data;
  #endif
--- 100,108 ----
  		 ExcData data,
  		 ExcMessage message)
  {
! 	int errno_copy = errno;
! 	const char *errorstr;
!         
  #ifdef	lint
  	data = data;
  #endif
***************
*** 127,136 ****
  
  	fprintf(stderr, " (%ld)", detail);
  
! 	if (errno > 0 && errno < sys_nerr)
! 		fprintf(stderr, " [%s]", strerror(errno));
! 	else if (errno != 0)
! 		fprintf(stderr, " [Error %d]", errno);
  
  	fprintf(stderr, "\n");
  
--- 127,140 ----
  
  	fprintf(stderr, " (%ld)", detail);
  
! 	if (errno_copy != 0) {
! 		errno = 0;
! 		errorstr = strerror(errno_copy);
! 		if (errno == 0 && errorstr != NULL)
! 			fprintf(stderr, " [Error %d: %s]", errno_copy, errorstr);
! 		else if (errno_copy != 0)
! 			fprintf(stderr, " [Error %d]", errno_copy);
! 	}
  
  	fprintf(stderr, "\n");

-- 
Pete Forman                 -./\.- Disclaimer: This post is originated
Western Geophysical           -./\.-  by myself and does not represent
[email-masked]         -./\.-  the opinion of Baker Hughes or
http://www.crosswinds.net/~petef  -./\.-  its divisions.

--
Want to unsubscribe from this list?
Send a message to [email-masked]