diff -r -u -p postgresql-7.1.2/src/interfaces/libpq/fe-connect.c postgresql-7.1.2dy/src/interfaces/libpq/fe-connect.c --- postgresql-7.1.2/src/interfaces/libpq/fe-connect.c Sat Jul 14 16:48:09 2001 +++ postgresql-7.1.2dy/src/interfaces/libpq/fe-connect.c Sat Jul 14 16:37:27 2001 @@ -736,9 +736,6 @@ connectNoDelay(PGconn *conn) printfPQExpBuffer(&conn->errorMessage, "connectNoDelay() -- setsockopt failed: errno=%d\n%s\n", errno, strerror(errno)); -#ifdef WIN32 - printf("Winsock error: %i\n", WSAGetLastError()); -#endif return 0; } @@ -934,11 +931,7 @@ connectDBStart(PGconn *conn) */ if (connect(conn->sock, &conn->raddr.sa, conn->raddr_len) < 0) { -#ifndef WIN32 if (errno == EINPROGRESS || errno == 0) -#else - if (WSAGetLastError() == WSAEINPROGRESS) -#endif { /* @@ -2127,7 +2120,11 @@ PQrequestCancel(PGconn *conn) strcpy(conn->errorMessage.data, "PQrequestCancel() -- connection is not open\n"); conn->errorMessage.len = strlen(conn->errorMessage.data); +#ifdef WIN32 + WSASetLastError(save_errno); +#else errno = save_errno; +#endif return FALSE; } @@ -2169,11 +2166,12 @@ PQrequestCancel(PGconn *conn) /* Sent it, done */ #ifdef WIN32 closesocket(tmpsock); + WSASetLastError(save_errno); #else close(tmpsock); + errno = save_errno; #endif - errno = save_errno; return TRUE; cancel_errReturn: @@ -2184,11 +2182,12 @@ cancel_errReturn: { #ifdef WIN32 closesocket(tmpsock); + WSASetLastError(save_errno); #else close(tmpsock); + errno = save_errno; #endif } - errno = save_errno; return FALSE; } diff -r -u -p postgresql-7.1.2/src/interfaces/libpq/fe-exec.c postgresql-7.1.2dy/src/interfaces/libpq/fe-exec.c --- postgresql-7.1.2/src/interfaces/libpq/fe-exec.c Sat Jul 14 16:48:11 2001 +++ postgresql-7.1.2dy/src/interfaces/libpq/fe-exec.c Sat Jul 14 16:41:35 2001 @@ -223,7 +223,7 @@ pqResultAlloc(PGresult *res, size_t nByt } /* If there's enough space in the current block, no problem. */ - if (nBytes <= res->spaceLeft) + if (nBytes <= (size_t)res->spaceLeft) { space = res->curBlock->space + res->curOffset; res->curOffset += nBytes; @@ -1028,7 +1028,7 @@ getAnotherTuple(PGconn *conn, int binary vlen = 0; if (tup[i].value == NULL) { - tup[i].value = (char *) pqResultAlloc(result, vlen + 1, binary); + tup[i].value = (char *) pqResultAlloc(result, vlen + 1, (bool)binary); if (tup[i].value == NULL) goto outOfMemory; } @@ -2055,7 +2055,11 @@ PQoidValue(const PGresult *res) if (!res || !res->cmdStatus || strncmp(res->cmdStatus, "INSERT ", 7) != 0) return InvalidOid; +#ifdef WIN32 + WSASetLastError(0); +#else errno = 0; +#endif result = strtoul(res->cmdStatus + 7, &endptr, 10); if (!endptr || (*endptr != ' ' && *endptr != '\0') || errno == ERANGE) diff -r -u -p postgresql-7.1.2/src/interfaces/libpq/fe-misc.c postgresql-7.1.2dy/src/interfaces/libpq/fe-misc.c --- postgresql-7.1.2/src/interfaces/libpq/fe-misc.c Sat Jul 14 16:48:16 2001 +++ postgresql-7.1.2dy/src/interfaces/libpq/fe-misc.c Sat Jul 14 16:43:01 2001 @@ -32,16 +32,16 @@ #include "postgres_fe.h" +#include +#include +#include + #ifdef WIN32 #include "win32.h" #else #include #include #endif - -#include -#include -#include #ifdef HAVE_SYS_SELECT_H #include diff -r -u -p postgresql-7.1.2/src/interfaces/libpq/win32.h postgresql-7.1.2dy/src/interfaces/libpq/win32.h --- postgresql-7.1.2/src/interfaces/libpq/win32.h Sat Jul 14 16:48:50 2001 +++ postgresql-7.1.2dy/src/interfaces/libpq/win32.h Sat Jul 14 16:38:20 2001 @@ -21,3 +21,18 @@ * crypt not available (yet) */ #define crypt(a,b) a + +/* + * assumes that errno is used for sockets only + * + */ + +#undef errno +#undef EINTR +#undef EAGAIN /* doesn't apply on sockets */ + +#define errno WSAGetLastError() +#define EINTR WSAEINTR +#define EWOULDBLOCK WSAEWOULDBLOCK +#define ECONNRESET WSAECONNRESET +#define EINPROGRESS WSAEINPROGRESS