mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
For application to HEAD, following community review.
* Changes incorrect CYGWIN defines to __CYGWIN__ * Some localtime returns NULL checks (when unchecked cause SEGVs under Win32 regression tests) * Rationalized CreateSharedMemoryAndSemaphores and AttachSharedMemoryAndSemaphores (Bruce, I finally remembered to do it); requires attention. Claudio Natoli
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.176 2004/02/10 01:55:24 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.177 2004/02/25 19:41:22 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -428,7 +428,7 @@ BootstrapMain(int argc, char *argv[])
|
|||||||
|
|
||||||
#ifdef EXEC_BACKEND
|
#ifdef EXEC_BACKEND
|
||||||
if (IsUnderPostmaster)
|
if (IsUnderPostmaster)
|
||||||
AttachSharedMemoryAndSemaphores();
|
CreateSharedMemoryAndSemaphores(false, MaxBackends, 0);
|
||||||
#endif
|
#endif
|
||||||
XLOGPathInit();
|
XLOGPathInit();
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.137 2004/02/10 01:55:25 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.138 2004/02/25 19:41:22 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -140,7 +140,7 @@ write_group_file(Relation grel)
|
|||||||
bufsize = strlen(filename) + 12;
|
bufsize = strlen(filename) + 12;
|
||||||
tempname = (char *) palloc(bufsize);
|
tempname = (char *) palloc(bufsize);
|
||||||
snprintf(tempname, bufsize, "%s.%d", filename, MyProcPid);
|
snprintf(tempname, bufsize, "%s.%d", filename, MyProcPid);
|
||||||
#if defined(WIN32) || defined(CYGWIN)
|
#if defined(WIN32) || defined(__CYGWIN__)
|
||||||
filename = repalloc(filename, strlen(filename) + 1 + strlen(".new"));
|
filename = repalloc(filename, strlen(filename) + 1 + strlen(".new"));
|
||||||
strcat(filename, ".new");
|
strcat(filename, ".new");
|
||||||
#endif
|
#endif
|
||||||
@ -291,7 +291,7 @@ write_user_file(Relation urel)
|
|||||||
bufsize = strlen(filename) + 12;
|
bufsize = strlen(filename) + 12;
|
||||||
tempname = (char *) palloc(bufsize);
|
tempname = (char *) palloc(bufsize);
|
||||||
snprintf(tempname, bufsize, "%s.%d", filename, MyProcPid);
|
snprintf(tempname, bufsize, "%s.%d", filename, MyProcPid);
|
||||||
#if defined(WIN32) || defined(CYGWIN)
|
#if defined(WIN32) || defined(__CYGWIN__)
|
||||||
filename = repalloc(filename, strlen(filename) + 1 + strlen(".new"));
|
filename = repalloc(filename, strlen(filename) + 1 + strlen(".new"));
|
||||||
strcat(filename, ".new");
|
strcat(filename, ".new");
|
||||||
#endif
|
#endif
|
||||||
@ -466,7 +466,7 @@ AtEOXact_UpdatePasswordFile(bool isCommit)
|
|||||||
user_file_update_needed = false;
|
user_file_update_needed = false;
|
||||||
write_user_file(urel);
|
write_user_file(urel);
|
||||||
heap_close(urel, NoLock);
|
heap_close(urel, NoLock);
|
||||||
#if defined(WIN32) || defined(CYGWIN)
|
#if defined(WIN32) || defined(__CYGWIN__)
|
||||||
{
|
{
|
||||||
/* Rename active file while not holding an exclusive lock */
|
/* Rename active file while not holding an exclusive lock */
|
||||||
char *filename = user_getfilename(), *filename_new;
|
char *filename = user_getfilename(), *filename_new;
|
||||||
@ -485,7 +485,7 @@ AtEOXact_UpdatePasswordFile(bool isCommit)
|
|||||||
group_file_update_needed = false;
|
group_file_update_needed = false;
|
||||||
write_group_file(grel);
|
write_group_file(grel);
|
||||||
heap_close(grel, NoLock);
|
heap_close(grel, NoLock);
|
||||||
#if defined(WIN32) || defined(CYGWIN)
|
#if defined(WIN32) || defined(__CYGWIN__)
|
||||||
{
|
{
|
||||||
/* Rename active file while not holding an exclusive lock */
|
/* Rename active file while not holding an exclusive lock */
|
||||||
char *filename = group_getfilename(), *filename_new;
|
char *filename = group_getfilename(), *filename_new;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.31 2004/02/08 22:28:56 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.32 2004/02/25 19:41:22 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -254,7 +254,7 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
|
|||||||
{
|
{
|
||||||
void* origUsedShmemSegAddr = UsedShmemSegAddr;
|
void* origUsedShmemSegAddr = UsedShmemSegAddr;
|
||||||
|
|
||||||
#ifdef CYGWIN
|
#ifdef __CYGWIN__
|
||||||
/* cygipc (currently) appears to not detach on exec. */
|
/* cygipc (currently) appears to not detach on exec. */
|
||||||
PGSharedMemoryDetach();
|
PGSharedMemoryDetach();
|
||||||
UsedShmemSegAddr = origUsedShmemSegAddr;
|
UsedShmemSegAddr = origUsedShmemSegAddr;
|
||||||
@ -373,7 +373,7 @@ PGSharedMemoryDetach(void)
|
|||||||
if (UsedShmemSegAddr != NULL)
|
if (UsedShmemSegAddr != NULL)
|
||||||
{
|
{
|
||||||
if ((shmdt(UsedShmemSegAddr) < 0)
|
if ((shmdt(UsedShmemSegAddr) < 0)
|
||||||
#if (defined(EXEC_BACKEND) && defined(CYGWIN))
|
#if (defined(EXEC_BACKEND) && defined(__CYGWIN__))
|
||||||
/* Work-around for cygipc exec bug */
|
/* Work-around for cygipc exec bug */
|
||||||
&& shmdt(NULL) < 0
|
&& shmdt(NULL) < 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.368 2004/02/23 20:45:59 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.369 2004/02/25 19:41:22 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
@ -2727,7 +2727,7 @@ SubPostmasterMain(int argc, char* argv[])
|
|||||||
load_group();
|
load_group();
|
||||||
|
|
||||||
/* Attach process to shared segments */
|
/* Attach process to shared segments */
|
||||||
AttachSharedMemoryAndSemaphores();
|
CreateSharedMemoryAndSemaphores(false, MaxBackends, 0);
|
||||||
|
|
||||||
/* Run backend */
|
/* Run backend */
|
||||||
proc_exit(BackendRun(&port));
|
proc_exit(BackendRun(&port));
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.64 2004/02/10 01:55:25 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.65 2004/02/25 19:41:22 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -36,8 +36,10 @@
|
|||||||
* Creates and initializes shared memory and semaphores.
|
* Creates and initializes shared memory and semaphores.
|
||||||
*
|
*
|
||||||
* This is called by the postmaster or by a standalone backend.
|
* This is called by the postmaster or by a standalone backend.
|
||||||
* It is NEVER called by a backend forked from the postmaster;
|
* It is also called by a backend forked from the postmaster under
|
||||||
* for such a backend, the shared memory is already ready-to-go.
|
* the EXEC_BACKEND case
|
||||||
|
*
|
||||||
|
* In the non EXEC_BACKEND case, backends already have shared memory ready-to-go.
|
||||||
*
|
*
|
||||||
* If "makePrivate" is true then we only need private memory, not shared
|
* If "makePrivate" is true then we only need private memory, not shared
|
||||||
* memory. This is true for a standalone backend, false for a postmaster.
|
* memory. This is true for a standalone backend, false for a postmaster.
|
||||||
@ -47,9 +49,11 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
|
|||||||
int maxBackends,
|
int maxBackends,
|
||||||
int port)
|
int port)
|
||||||
{
|
{
|
||||||
|
PGShmemHeader *seghdr = NULL;
|
||||||
|
if (!IsUnderPostmaster)
|
||||||
|
{
|
||||||
int size;
|
int size;
|
||||||
int numSemas;
|
int numSemas;
|
||||||
PGShmemHeader *seghdr;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Size of the Postgres shared-memory block is estimated via
|
* Size of the Postgres shared-memory block is estimated via
|
||||||
@ -83,16 +87,29 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
|
|||||||
numSemas = ProcGlobalSemas(maxBackends);
|
numSemas = ProcGlobalSemas(maxBackends);
|
||||||
numSemas += SpinlockSemas();
|
numSemas += SpinlockSemas();
|
||||||
PGReserveSemaphores(numSemas, port);
|
PGReserveSemaphores(numSemas, port);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Attach to the shmem segment.
|
||||||
|
* (this should only ever be reached by EXEC_BACKEND code,
|
||||||
|
* and only then with makePrivate == false)
|
||||||
|
*/
|
||||||
|
Assert(ExecBackend && !makePrivate);
|
||||||
|
seghdr = PGSharedMemoryCreate(-1, makePrivate, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up shared memory allocation mechanism
|
* Set up shared memory allocation mechanism
|
||||||
*/
|
*/
|
||||||
InitShmemAllocation(seghdr, true);
|
InitShmemAllocation(seghdr, !IsUnderPostmaster);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now initialize LWLocks, which do shared memory allocation and are
|
* Now initialize LWLocks, which do shared memory allocation and are
|
||||||
* needed for InitShmemIndex.
|
* needed for InitShmemIndex.
|
||||||
*/
|
*/
|
||||||
|
if (!IsUnderPostmaster)
|
||||||
CreateLWLocks();
|
CreateLWLocks();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -137,41 +154,7 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
|
|||||||
/*
|
/*
|
||||||
* Alloc the win32 shared backend array
|
* Alloc the win32 shared backend array
|
||||||
*/
|
*/
|
||||||
|
if (!IsUnderPostmaster)
|
||||||
ShmemBackendArrayAllocation();
|
ShmemBackendArrayAllocation();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef EXEC_BACKEND
|
|
||||||
/*
|
|
||||||
* AttachSharedMemoryAndSemaphores
|
|
||||||
* Attaches to the existing shared resources.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* FIXME: [fork/exec] This function is starting to look pretty much like
|
|
||||||
CreateSharedMemoryAndSemaphores. Refactor? */
|
|
||||||
void
|
|
||||||
AttachSharedMemoryAndSemaphores(void)
|
|
||||||
{
|
|
||||||
PGShmemHeader *seghdr = PGSharedMemoryCreate(-1,false,-1);
|
|
||||||
|
|
||||||
InitShmemAllocation(seghdr, false);
|
|
||||||
|
|
||||||
InitShmemIndex();
|
|
||||||
|
|
||||||
XLOGShmemInit();
|
|
||||||
CLOGShmemInit();
|
|
||||||
InitBufferPool();
|
|
||||||
|
|
||||||
InitLocks();
|
|
||||||
InitLockTable(MaxBackends);
|
|
||||||
|
|
||||||
InitProcGlobal(MaxBackends);
|
|
||||||
|
|
||||||
CreateSharedInvalidationState(MaxBackends);
|
|
||||||
|
|
||||||
InitFreeSpaceMap();
|
|
||||||
|
|
||||||
PMSignalInit();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.124 2004/01/19 19:04:40 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.125 2004/02/25 19:41:23 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1611,6 +1611,10 @@ DetermineLocalTimeZone(struct tm * tm)
|
|||||||
* and reassemble to get a representation of local time.
|
* and reassemble to get a representation of local time.
|
||||||
*/
|
*/
|
||||||
tx = localtime(&mytime);
|
tx = localtime(&mytime);
|
||||||
|
if (!tx)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||||
|
errmsg("timestamp out of range")));
|
||||||
day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
|
day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
|
||||||
UNIX_EPOCH_JDATE;
|
UNIX_EPOCH_JDATE;
|
||||||
locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
|
locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
|
||||||
@ -1632,6 +1636,10 @@ DetermineLocalTimeZone(struct tm * tm)
|
|||||||
mysec += delta1;
|
mysec += delta1;
|
||||||
mytime = (time_t) mysec;
|
mytime = (time_t) mysec;
|
||||||
tx = localtime(&mytime);
|
tx = localtime(&mytime);
|
||||||
|
if (!tx)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||||
|
errmsg("timestamp out of range")));
|
||||||
day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
|
day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
|
||||||
UNIX_EPOCH_JDATE;
|
UNIX_EPOCH_JDATE;
|
||||||
locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
|
locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
|
||||||
@ -1653,6 +1661,10 @@ DetermineLocalTimeZone(struct tm * tm)
|
|||||||
mysec += (delta2 - delta1);
|
mysec += (delta2 - delta1);
|
||||||
mytime = (time_t) mysec;
|
mytime = (time_t) mysec;
|
||||||
tx = localtime(&mytime);
|
tx = localtime(&mytime);
|
||||||
|
if (!tx)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
||||||
|
errmsg("timestamp out of range")));
|
||||||
day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
|
day = date2j(tx->tm_year + 1900, tx->tm_mon + 1, tx->tm_mday) -
|
||||||
UNIX_EPOCH_JDATE;
|
UNIX_EPOCH_JDATE;
|
||||||
locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
|
locsec = tx->tm_sec + (tx->tm_min + (day * 24 + tx->tm_hour) * 60) * 60;
|
||||||
|
4
src/backend/utils/cache/relcache.c
vendored
4
src/backend/utils/cache/relcache.c
vendored
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.197 2004/02/10 01:55:26 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.198 2004/02/25 19:41:23 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -3266,7 +3266,7 @@ write_relcache_init_file(void)
|
|||||||
* OK, rename the temp file to its final name, deleting any
|
* OK, rename the temp file to its final name, deleting any
|
||||||
* previously-existing init file.
|
* previously-existing init file.
|
||||||
*/
|
*/
|
||||||
#if defined(WIN32) || defined(CYGWIN)
|
#if defined(WIN32) || defined(__CYGWIN__)
|
||||||
rename(tempfilename, finalfilename);
|
rename(tempfilename, finalfilename);
|
||||||
LWLockRelease(RelCacheInitLock);
|
LWLockRelease(RelCacheInitLock);
|
||||||
#else
|
#else
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/port.h,v 1.19 2004/02/10 03:42:45 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/port.h,v 1.20 2004/02/25 19:41:23 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -34,7 +34,7 @@ extern int fseeko(FILE *stream, off_t offset, int whence);
|
|||||||
extern off_t ftello(FILE *stream);
|
extern off_t ftello(FILE *stream);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32) || defined(CYGWIN)
|
#if defined(WIN32) || defined(__CYGWIN__)
|
||||||
/*
|
/*
|
||||||
* Win32 doesn't have reliable rename/unlink during concurrent access
|
* Win32 doesn't have reliable rename/unlink during concurrent access
|
||||||
*/
|
*/
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/storage/ipc.h,v 1.64 2003/12/20 17:31:21 momjian Exp $
|
* $PostgreSQL: pgsql/src/include/storage/ipc.h,v 1.65 2004/02/25 19:41:23 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -32,8 +32,4 @@ extern void on_exit_reset(void);
|
|||||||
extern void CreateSharedMemoryAndSemaphores(bool makePrivate,
|
extern void CreateSharedMemoryAndSemaphores(bool makePrivate,
|
||||||
int maxBackends,
|
int maxBackends,
|
||||||
int port);
|
int port);
|
||||||
#ifdef EXEC_BACKEND
|
|
||||||
extern void AttachSharedMemoryAndSemaphores(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* IPC_H */
|
#endif /* IPC_H */
|
||||||
|
@ -10,20 +10,25 @@
|
|||||||
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
|
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.10 2004/02/02 22:20:33 momjian Exp $
|
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.11 2004/02/25 19:41:23 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TEST_VERSION
|
#ifndef TEST_VERSION
|
||||||
|
|
||||||
#if defined(WIN32) || defined(CYGWIN)
|
#if defined(WIN32) || defined(__CYGWIN__)
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
#include <sys/time.h> /* timeval definition for PG_USLEEP */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef FRONTEND
|
#ifndef FRONTEND
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
#else
|
#else
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "miscadmin.h"
|
||||||
|
|
||||||
#undef rename
|
#undef rename
|
||||||
#undef unlink
|
#undef unlink
|
||||||
@ -36,19 +41,19 @@ pgrename(const char *from, const char *to)
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
while (!MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING))
|
while (!MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING))
|
||||||
#endif
|
#endif
|
||||||
#ifdef CYGWIN
|
#ifdef __CYGWIN__
|
||||||
while (rename(from, to) < 0)
|
while (rename(from, to) < 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (GetLastError() != ERROR_ACCESS_DENIED)
|
if (GetLastError() != ERROR_ACCESS_DENIED)
|
||||||
#endif
|
#endif
|
||||||
#ifdef CYGWIN
|
#ifdef __CYGWIN__
|
||||||
if (errno != EACCES)
|
if (errno != EACCES)
|
||||||
#endif
|
#endif
|
||||||
/* set errno? */
|
/* set errno? */
|
||||||
return -1;
|
return -1;
|
||||||
Sleep(100); /* ms */
|
PG_USLEEP(100000); /* us */
|
||||||
if (loops == 30)
|
if (loops == 30)
|
||||||
#ifndef FRONTEND
|
#ifndef FRONTEND
|
||||||
elog(LOG, "could not rename \"%s\" to \"%s\", continuing to try",
|
elog(LOG, "could not rename \"%s\" to \"%s\", continuing to try",
|
||||||
@ -80,7 +85,7 @@ pgunlink(const char *path)
|
|||||||
if (errno != EACCES)
|
if (errno != EACCES)
|
||||||
/* set errno? */
|
/* set errno? */
|
||||||
return -1;
|
return -1;
|
||||||
Sleep(100); /* ms */
|
PG_USLEEP(100000); /* us */
|
||||||
if (loops == 30)
|
if (loops == 30)
|
||||||
#ifndef FRONTEND
|
#ifndef FRONTEND
|
||||||
elog(LOG, "could not unlink \"%s\", continuing to try",
|
elog(LOG, "could not unlink \"%s\", continuing to try",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifdef CYGWIN
|
#ifdef __CYGWIN__
|
||||||
#include <cygwin/version.h>
|
#include <cygwin/version.h>
|
||||||
#endif
|
#endif
|
||||||
#if CYGWIN_VERSION_DLL_MAJOR < 1001
|
#if CYGWIN_VERSION_DLL_MAJOR < 1001
|
||||||
@ -88,7 +88,9 @@ DllMain(
|
|||||||
__hDllInstance_base = hInst;
|
__hDllInstance_base = hInst;
|
||||||
#endif /* __CYGWIN__ */
|
#endif /* __CYGWIN__ */
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
_impure_ptr = __imp_reent_data;
|
_impure_ptr = __imp_reent_data;
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (reason)
|
switch (reason)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user