diff options
author | Bruce Momjian <bruce@momjian.us> | 2001-07-20 17:45:06 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2001-07-20 17:45:06 +0000 |
commit | 8c79f3c4a30177e8c160fdd158813d4d8318cf5a (patch) | |
tree | ad7931e28ab84f5fc30e25239129e404880fb440 /src/interfaces/libpq/fe-exec.c | |
parent | 8f75c1b0c79868fcdde584b91e96ba05e862c255 (diff) | |
download | postgresql-8c79f3c4a30177e8c160fdd158813d4d8318cf5a.tar.gz postgresql-8c79f3c4a30177e8c160fdd158813d4d8318cf5a.zip |
i've spotted a following problem using DBD::Pg under win32. winsock
functions do not set errno, so some normal conditions are treated as
fatal errors. e.g. fetching large tuples fails, as at some point recv()
returns EWOULDBLOCK. here's a patch, which replaces errno with
WSAGetLastError(). i've tried to to affect non-win32 code.
Dmitry Yurtaev
Diffstat (limited to 'src/interfaces/libpq/fe-exec.c')
-rw-r--r-- | src/interfaces/libpq/fe-exec.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index fcd2724b8eb..924da5fcf25 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.103 2001/07/15 13:45:04 petere Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.104 2001/07/20 17:45:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -223,7 +223,7 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary) } /* 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; @@ -1024,7 +1024,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; } @@ -2051,7 +2051,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) |