*** 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");