* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.138 2004/03/22 04:16:57 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.139 2004/04/19 17:42:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* This is just to allow attaching to startup process with a debugger */
#ifdef XLOG_REPLAY_DELAY
if (ControlFile->state != DB_SHUTDOWNED)
- sleep(60);
+ pg_usleep(60000000L);
#endif
/*
while (!LWLockConditionalAcquire(CheckpointLock, LW_EXCLUSIVE))
{
CHECK_FOR_INTERRUPTS();
- sleep(1);
+ pg_usleep(1000000L);
}
/*
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.131 2004/02/10 01:55:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.132 2004/04/19 17:42:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
char *alt_loc;
char *target_dir;
char src_loc[MAXPGPATH];
+#ifndef WIN32
char buf[2 * MAXPGPATH + 100];
+#endif
Oid src_dboid;
AclId src_owner;
int src_encoding;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.23 2004/03/24 03:44:58 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.24 2004/04/19 17:42:57 momjian Exp $
*/
#ifdef FRONTEND
#include "postgres_fe.h"
-#ifndef WIN32
#include "libpq/crypt.h"
-#endif /* WIN32 */
#endif /* FRONTEND */
#ifdef MD5_ODBC
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.76 2004/03/15 16:14:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.77 2004/04/19 17:42:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
main(int argc, char *argv[])
{
int len;
+#ifndef WIN32
struct passwd *pw;
+#endif
char *pw_name_persist;
/*
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.32 2004/02/25 19:41:22 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.33 2004/04/19 17:42:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
PGSharedMemoryDetach();
UsedShmemSegAddr = origUsedShmemSegAddr;
#endif
- elog(DEBUG3,"Attaching to %x",UsedShmemSegAddr);
+ elog(DEBUG3,"Attaching to %p",UsedShmemSegAddr);
hdr = PGSharedMemoryAttach((IpcMemoryKey) UsedShmemSegID, &shmid);
if (hdr == NULL)
elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%d, addr=%p) failed: %m",
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.4 2004/02/12 20:37:34 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.5 2004/04/19 17:42:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int
shmdt(const void *shmaddr)
{
- if (UnmapViewOfFile(shmaddr))
+ if (UnmapViewOfFile((LPCVOID*)shmaddr))
return 0;
else
return -1;
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/port/win32/timer.c,v 1.1 2004/02/18 16:25:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/port/win32/timer.c,v 1.2 2004/04/19 17:42:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
timerHandle = CreateWaitableTimer(NULL, TRUE, NULL);
if (timerHandle == NULL)
ereport(FATAL,
- (errmsg_internal("failed to create waitable timer: %i",GetLastError())));
+ (errmsg_internal("failed to create waitable timer: %i",(int)GetLastError())));
}
-
+
if (value->it_value.tv_sec == 0 &&
value->it_value.tv_usec == 0) {
/* Turn timer off */
/* Negative time to SetWaitableTimer means relative time */
dueTime.QuadPart = -(value->it_value.tv_usec*10 + value->it_value.tv_sec*10000000L);
-
+
/* Turn timer on, or change timer */
- if (!SetWaitableTimer(timerHandle, &dueTime, 0, timer_completion, NULL, FALSE))
+ if (!SetWaitableTimer(timerHandle, &dueTime, 0, timer_completion, NULL, FALSE))
ereport(FATAL,
- (errmsg_internal("failed to set waitable timer: %i",GetLastError())));
+ (errmsg_internal("failed to set waitable timer: %i",(int)GetLastError())));
return 0;
}
*
* Copyright (c) 2001-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.66 2004/04/12 16:19:18 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.67 2004/04/19 17:42:58 momjian Exp $
* ----------
*/
#include "postgres.h"
{
if (errno == EINTR)
continue;
-#ifdef WIN32
- if (WSAGetLastError() == WSAECONNRESET) /* EOF on the pipe! (win32 socket based implementation) */
- {
- pipeEOF = true;
- break;
- }
-#endif
ereport(LOG,
(errcode_for_socket_access(),
errmsg("could not read from statistics collector pipe: %m")));
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.380 2004/04/12 16:19:18 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.381 2004/04/19 17:42:58 momjian Exp $
*
* NOTES
*
void read_backend_variables(unsigned long id, Port *port);
static bool write_backend_variables(Port *port);
-size_t ShmemBackendArraySize(void);
-void ShmemBackendArrayAllocation(void);
static void ShmemBackendArrayAdd(Backend *bn);
static void ShmemBackendArrayRemove(pid_t pid);
#endif
* PGOPTIONS, but it is not honored until after authentication.)
*/
if (PreAuthDelay > 0)
- sleep(PreAuthDelay);
+ pg_usleep(PreAuthDelay*1000000L);
/* Will exit on failure */
BackendInit(port);
}
}
- /* FIXME: [fork/exec] some sort of error */
- abort();
+ ereport(FATAL,
+ (errmsg_internal("unable to add backend entry")));
}
static void ShmemBackendArrayRemove(pid_t pid)
}
}
- /* Something stronger than WARNING here? */
ereport(WARNING,
(errmsg_internal("unable to find backend entry with pid %d",
pid)));
++win32_numChildren;
}
else
- /* FIXME: [fork/exec] some sort of error */
- abort();
+ ereport(FATAL,
+ (errmsg_internal("unable to add child entry with pid %lu",
+ pid)));
}
static void win32_RemoveChild(pid_t pid)
}
}
- /* Something stronger than WARNING here? */
ereport(WARNING,
(errmsg_internal("unable to find child entry with pid %lu",
pid)));
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.103 2004/02/11 22:55:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.104 2004/04/19 17:42:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
sync();
if (IsUnderPostmaster)
- sleep(2);
+ pg_usleep(2000000L);
sync();
return true;
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.399 2004/04/11 00:54:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.400 2004/04/19 17:42:58 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
/*
* wait N seconds to allow attach from a debugger
*/
- sleep(atoi(optarg));
+ pg_usleep(atoi(optarg)*1000000L);
break;
case 'x':
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.25 2003/11/29 19:52:01 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.26 2004/04/19 17:42:58 momjian Exp $
*
* NOTE
* This should eventually work with elog()
}
#ifdef SLEEP_ON_ASSERT
- sleep(1000000);
+ /*
+ * It would be nice to use pg_usleep() here, but only does 2000 sec
+ * or 33 minutes, which seems too short.
+ */
+ sleep(1000000);
#endif
abort();
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.50 2003/12/29 23:54:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.51 2004/04/19 17:42:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
#define MEM_ALLOC DynaHashAlloc
+#undef MEM_FREE /* already in windows header files */
#define MEM_FREE pfree
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.123 2004/02/10 01:55:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.124 2004/04/19 17:42:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* generating funny-looking paths to individual files.
*/
newlen = strlen(new);
- if (newlen > 1 && new[newlen - 1] == '/'
+ if (newlen > 1 && (new[newlen - 1] == '/'
#ifdef WIN32
|| new[newlen - 1] == '\\'
#endif
- )
+ ))
new[newlen - 1] = '\0';
if (DataDir)
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.34 2004/01/25 03:07:22 neilc Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.35 2004/04/19 17:42:58 momjian Exp $
*/
#ifndef COMMON_H
#define COMMON_H
*/
extern char parse_char(char **buf);
-/* Used for all Win32 popen/pclose calls */
-#ifdef WIN32
-#define popen(x,y) _popen(x,y)
-#define pclose(x) _pclose(x)
-#endif
-
extern char *expand_tilde(char **filename);
#endif /* COMMON_H */
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.44 2004/04/19 17:22:31 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.45 2004/04/19 17:42:58 momjian Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
#include "prompt.h"
#include "stringutils.h"
-#ifdef WIN32
+#if defined(WIN32) && (!defined(__MINGW32__))
#define strcasecmp(x,y) stricmp(x,y)
#define __S_ISTYPE(mode, mask) (((mode) & S_IFMT) == (mask))
#define S_ISDIR(mode) __S_ISTYPE((mode), S_IFDIR)
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.87 2004/03/24 03:10:29 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.88 2004/04/19 17:42:58 momjian Exp $
*/
#include "postgres_fe.h"
char *psqlrc;
char *home;
-#ifdef WIN32
-#define R_OK 0
+#if defined(WIN32) && (!defined(__MINGW32__))
+#define R_OK 4
#endif
/* Look for one in the home dir */
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.6 2003/11/29 19:52:07 pgsql Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.7 2004/04/19 17:42:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
return pw->pw_name;
#else
static char username[128]; /* remains after function exit */
+ DWORD len = sizeof(username)-1;
- GetUserName(username, sizeof(username)-1);
+ if (!GetUserName(username, &len))
+ {
+ perror(progname);
+ exit(1);
+ }
return username;
-#endif
+#endif
}
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/port.h,v 1.24 2004/04/05 03:16:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.25 2004/04/19 17:42:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define pipewrite(a,b,c) write(a,b,c)
#else
extern int pgpipe(int handles[2]);
-#define piperead(a,b,c) recv(a,b,c,0)
+extern int piperead(int s, char* buf, int len);
#define pipewrite(a,b,c) send(a,b,c,0)
#endif
#define open(a,b,...) win32_open(a,b,##__VA_ARGS__)
#endif
+#ifndef __BORLANDC__
+#define popen(a,b) _popen(a,b)
+#define pclose(a) _pclose(a)
+#endif
+
extern int copydir(char *fromdir, char *todir);
/* Missing rand functions */
-/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.21 2004/04/12 16:19:18 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.22 2004/04/19 17:42:59 momjian Exp $ */
/* undefine and redefine after #include */
#undef mkdir
#undef ERROR
#include <windows.h>
#include <winsock.h>
+#include <process.h>
#undef near
/* Must be here to avoid conflicting with prototype in windows.h */
*/
#define lstat slat
-#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
-#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
-
-#define S_IRUSR _S_IREAD
-#define S_IWUSR _S_IWRITE
-#define S_IXUSR _S_IEXEC
-#define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
-
/*
* Supplement to <errno.h>.
*/
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/ipc.h,v 1.65 2004/02/25 19:41:23 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/ipc.h,v 1.66 2004/04/19 17:42:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void CreateSharedMemoryAndSemaphores(bool makePrivate,
int maxBackends,
int port);
+
+#ifdef EXEC_BACKEND
+/* postmaster.c */
+extern size_t ShmemBackendArraySize(void);
+extern void ShmemBackendArrayAllocation(void);
+#endif
+
#endif /* IPC_H */
#
# Copyright (c) 1994, Regents of the University of California
#
-# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.100 2004/03/24 03:54:16 momjian Exp $
+# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.101 2004/04/19 17:42:59 momjian Exp $
#
#-------------------------------------------------------------------------
rm -f $(DESTDIR)$(includedir)/libpq-fe.h $(DESTDIR)$(includedir_internal)/libpq-int.h $(DESTDIR)$(includedir_internal)/pqexpbuffer.h
clean distclean maintainer-clean: clean-lib
- rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c snprintf.c strerror.c path.c thread.c dllist.c md5.c ip.c encnames.c wchar.c
+ rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c snprintf.c strerror.c open.c path.c thread.c dllist.c md5.c ip.c encnames.c wchar.c
* didn't really belong there.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.50 2004/01/09 02:02:43 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.51 2004/04/19 17:42:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
- (po->header != 0) * 2 /* row count and newline */
)))
{
-#ifdef WIN32
- fout = _popen(pagerenv, "w");
-#else
fout = popen(pagerenv, "w");
-#endif
if (fout)
{
usePipe = 1;
}
if (!success)
- sprintf(strerrbuf, "Unknown socket error (0x%08X/%lu)", err, err);
+ sprintf(strerrbuf, "Unknown socket error (0x%08X/%i)", err, err);
else
{
strerrbuf[buflen - 1] = '\0';
offs = strlen(strerrbuf);
if (offs > (int)buflen - 64)
offs = buflen - 64;
- sprintf(strerrbuf + offs, " (0x%08X/%lu)", err, err);
+ sprintf(strerrbuf + offs, " (0x%08X/%i)", err, err);
}
return strerrbuf;
}
#define write(a,b,c) _write(a,b,c)
#endif
-#define popen(a,b) _popen(a,b)
-#define pclose(a) _pclose(a)
#define vsnprintf(a,b,c,d) _vsnprintf(a,b,c,d)
#define snprintf _snprintf
*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/port/open.c,v 1.1 2004/03/24 03:54:16 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/open.c,v 1.2 2004/04/19 17:42:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <errno.h>
#include <assert.h>
-int openFlagsToCreateFileFlags(int openFlags)
+static int
+openFlagsToCreateFileFlags(int openFlags)
{
switch (openFlags & (O_CREAT|O_TRUNC|O_EXCL))
{
* must be replaced with recv/send.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/pipe.c,v 1.1 2004/01/09 04:58:09 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/pipe.c,v 1.2 2004/04/19 17:42:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
closesocket(s);
return 0;
}
+
+
+int piperead(int s, char* buf, int len)
+{
+ int ret = recv(s,buf,len,0);
+ if (ret < 0 && WSAGetLastError() == WSAECONNRESET)
+ /* EOF on the pipe! (win32 socket based implementation) */
+ ret = 0;
+ return ret;
+}
*
*-------------------------------------------------------------------------
*/
+#include "c.h"
/*
* Copyright (c) 1993 Martin Birgmeier
};
unsigned short _rand48_add = RAND48_ADD;
-void
+static void
_dorand48(unsigned short xseed[3])
{
unsigned long accu;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/sprompt.c,v 1.4 2003/11/29 19:52:13 pgsql Exp $
+ * $PostgreSQL: pgsql/src/port/sprompt.c,v 1.5 2004/04/19 17:42:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#else
#ifdef WIN32
- HANDLE t;
- LPDWORD t_orig;
+ HANDLE t = NULL;
+ LPDWORD t_orig = NULL;
#endif
#endif