mirror of
https://github.com/postgres/postgres.git
synced 2025-08-31 17:02:12 +03:00
The attached patch fixes a number of issues related to compiling the
client utilities (libpq.dll and psql.exe) for win32 (missing defines, adjustments to includes, pedantic casting, non-existent functions) per: http://developer.postgresql.org/docs/postgres/install-win32.html. It compiles cleanly under Windows 2000 using Visual Studio .net. Also compiles clean and passes all regression tests (regular and contrib) under Linux. In addition to a review by the usual suspects, it would be very desirable for someone well versed in the peculiarities of win32 to take a look. Joe Conway
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.205 2002/09/22 20:57:21 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.206 2002/10/03 17:09:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libpq-fe.h"
|
||||
#include "libpq-int.h"
|
||||
@@ -1053,10 +1052,10 @@ connectDBComplete(PGconn *conn)
|
||||
{
|
||||
PostgresPollingStatusType flag = PGRES_POLLING_WRITING;
|
||||
|
||||
struct timeval remains,
|
||||
*rp = NULL,
|
||||
finish_time,
|
||||
start_time;
|
||||
time_t finish_time = 0,
|
||||
current_time;
|
||||
struct timeval remains,
|
||||
*rp = NULL;
|
||||
|
||||
if (conn == NULL || conn->status == CONNECTION_BAD)
|
||||
return 0;
|
||||
@@ -1074,19 +1073,13 @@ connectDBComplete(PGconn *conn)
|
||||
}
|
||||
remains.tv_usec = 0;
|
||||
rp = &remains;
|
||||
|
||||
/* calculate the finish time based on start + timeout */
|
||||
finish_time = time((time_t *) NULL) + remains.tv_sec;
|
||||
}
|
||||
|
||||
while (rp == NULL || remains.tv_sec > 0 || remains.tv_usec > 0)
|
||||
{
|
||||
/*
|
||||
* If connecting timeout is set, get current time.
|
||||
*/
|
||||
if (rp != NULL && gettimeofday(&start_time, NULL) == -1)
|
||||
{
|
||||
conn->status = CONNECTION_BAD;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait, if necessary. Note that the initial state (just after
|
||||
* PQconnectStart) is to wait for the socket to select for
|
||||
@@ -1128,26 +1121,18 @@ connectDBComplete(PGconn *conn)
|
||||
flag = PQconnectPoll(conn);
|
||||
|
||||
/*
|
||||
* If connecting timeout is set, calculate remain time.
|
||||
* If connecting timeout is set, calculate remaining time.
|
||||
*/
|
||||
if (rp != NULL)
|
||||
{
|
||||
if (gettimeofday(&finish_time, NULL) == -1)
|
||||
if (time(¤t_time) == -1)
|
||||
{
|
||||
conn->status = CONNECTION_BAD;
|
||||
return 0;
|
||||
}
|
||||
if ((finish_time.tv_usec -= start_time.tv_usec) < 0)
|
||||
{
|
||||
remains.tv_sec++;
|
||||
finish_time.tv_usec += 1000000;
|
||||
}
|
||||
if ((remains.tv_usec -= finish_time.tv_usec) < 0)
|
||||
{
|
||||
remains.tv_sec--;
|
||||
remains.tv_usec += 1000000;
|
||||
}
|
||||
remains.tv_sec -= finish_time.tv_sec - start_time.tv_sec;
|
||||
|
||||
remains.tv_sec = finish_time - current_time;
|
||||
remains.tv_usec = 0;
|
||||
}
|
||||
}
|
||||
conn->status = CONNECTION_BAD;
|
||||
@@ -2946,6 +2931,7 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
/* If password file is insecure, alert the user and ignore it. */
|
||||
if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
|
||||
{
|
||||
@@ -2955,6 +2941,7 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
|
||||
free(pgpassfile);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
fp = fopen(pgpassfile, "r");
|
||||
free(pgpassfile);
|
||||
|
@@ -25,7 +25,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.79 2002/09/04 20:31:47 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.80 2002/10/03 17:09:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -150,9 +150,9 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn)
|
||||
* try to grow the buffer. FIXME: The new size could be
|
||||
* chosen more intelligently.
|
||||
*/
|
||||
size_t buflen = conn->outCount + nbytes;
|
||||
size_t buflen = (size_t) conn->outCount + nbytes;
|
||||
|
||||
if (buflen > conn->outBufSize)
|
||||
if (buflen > (size_t) conn->outBufSize)
|
||||
{
|
||||
char *newbuf = realloc(conn->outBuffer, buflen);
|
||||
|
||||
@@ -240,7 +240,7 @@ pqPuts(const char *s, PGconn *conn)
|
||||
int
|
||||
pqGetnchar(char *s, size_t len, PGconn *conn)
|
||||
{
|
||||
if (len < 0 || len > conn->inEnd - conn->inCursor)
|
||||
if (len < 0 || len > (size_t) (conn->inEnd - conn->inCursor))
|
||||
return EOF;
|
||||
|
||||
memcpy(s, conn->inBuffer + conn->inCursor, len);
|
||||
|
@@ -10,7 +10,7 @@
|
||||
* didn't really belong there.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.46 2002/08/29 07:22:30 ishii Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.47 2002/10/03 17:09:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -299,7 +299,7 @@ PQprint(FILE *fout,
|
||||
(PQntuples(res) == 1) ? "" : "s");
|
||||
free(fieldMax);
|
||||
free(fieldNotNum);
|
||||
free(fieldNames);
|
||||
free((void *) fieldNames);
|
||||
if (usePipe)
|
||||
{
|
||||
#ifdef WIN32
|
||||
|
@@ -12,7 +12,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: libpq-int.h,v 1.57 2002/09/04 20:31:47 momjian Exp $
|
||||
* $Id: libpq-int.h,v 1.58 2002/10/03 17:09:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -21,8 +21,10 @@
|
||||
#define LIBPQ_INT_H
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#ifndef WIN32
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && (!defined(ssize_t))
|
||||
typedef int ssize_t; /* ssize_t doesn't exist in VC (atleast
|
||||
|
@@ -1,5 +1,4 @@
|
||||
LIBRARY LIBPQ
|
||||
DESCRIPTION "Postgres Client Access Library"
|
||||
EXPORTS
|
||||
PQconnectdb @ 1
|
||||
PQsetdbLogin @ 2
|
||||
@@ -90,3 +89,7 @@ EXPORTS
|
||||
PQfreeNotify @ 87
|
||||
PQescapeString @ 88
|
||||
PQescapeBytea @ 89
|
||||
printfPQExpBuffer @ 90
|
||||
appendPQExpBuffer @ 91
|
||||
pg_encoding_to_char @ 92
|
||||
pg_utf_mblen @ 93
|
||||
|
@@ -17,7 +17,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.13 2002/06/20 20:29:54 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.14 2002/10/03 17:09:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -192,7 +192,7 @@ printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
|
||||
* actually stored, but at least one returns -1 on failure. Be
|
||||
* conservative about believing whether the print worked.
|
||||
*/
|
||||
if (nprinted >= 0 && nprinted < avail - 1)
|
||||
if (nprinted >= 0 && nprinted < (int) avail - 1)
|
||||
{
|
||||
/* Success. Note nprinted does not include trailing null. */
|
||||
str->len += nprinted;
|
||||
@@ -240,7 +240,7 @@ appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
|
||||
* actually stored, but at least one returns -1 on failure. Be
|
||||
* conservative about believing whether the print worked.
|
||||
*/
|
||||
if (nprinted >= 0 && nprinted < avail - 1)
|
||||
if (nprinted >= 0 && nprinted < (int) avail - 1)
|
||||
{
|
||||
/* Success. Note nprinted does not include trailing null. */
|
||||
str->len += nprinted;
|
||||
|
@@ -22,7 +22,7 @@
|
||||
/*
|
||||
* crypt not available (yet)
|
||||
*/
|
||||
#define crypt(a,b) (a)
|
||||
#define crypt(a,b) ((char *) a)
|
||||
|
||||
#undef EAGAIN /* doesn't apply on sockets */
|
||||
#undef EINTR
|
||||
|
Reference in New Issue
Block a user