Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3133835

Browse files
committed
* Most changes are to fix warnings issued when compiling win32
* removed a few redundant defines* get_user_name safe under win32* rationalized pipe read EOF for win32 (UPDATED PATCH USED)* changed all backend instances of sleep() to pg_usleep - except for the SLEEP_ON_ASSERT in assert.c, as it would exceed a32-bit long [Note to patcher: If a SLEEP_ON_ASSERT of 2000 seconds isacceptable, please replace with pg_usleep(2000000000L)]I added a comment to that part of the code: /* * It would be nice to use pg_usleep() here, but only does 2000 sec * or 33 minutes, which seems too short. */ sleep(1000000);Claudio Natoli
1 parent862b20b commit3133835

File tree

29 files changed

+98
-91
lines changed

29 files changed

+98
-91
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.138 2004/03/22 04:16:57 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.139 2004/04/19 17:42:57 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2830,7 +2830,7 @@ StartupXLOG(void)
28302830
/* This is just to allow attaching to startup process with a debugger */
28312831
#ifdefXLOG_REPLAY_DELAY
28322832
if (ControlFile->state!=DB_SHUTDOWNED)
2833-
sleep(60);
2833+
pg_usleep(60000000L);
28342834
#endif
28352835

28362836
/*
@@ -3360,7 +3360,7 @@ CreateCheckPoint(bool shutdown, bool force)
33603360
while (!LWLockConditionalAcquire(CheckpointLock,LW_EXCLUSIVE))
33613361
{
33623362
CHECK_FOR_INTERRUPTS();
3363-
sleep(1);
3363+
pg_usleep(1000000L);
33643364
}
33653365

33663366
/*

‎src/backend/commands/dbcommands.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.131 2004/02/10 01:55:25 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.132 2004/04/19 17:42:57 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -64,7 +64,9 @@ createdb(const CreatedbStmt *stmt)
6464
char*alt_loc;
6565
char*target_dir;
6666
charsrc_loc[MAXPGPATH];
67+
#ifndefWIN32
6768
charbuf[2*MAXPGPATH+100];
69+
#endif
6870
Oidsrc_dboid;
6971
AclIdsrc_owner;
7072
intsrc_encoding;

‎src/backend/libpq/md5.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*Portions Copyright (c) 1994, Regents of the University of California
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.23 2004/03/24 03:44:58 momjian Exp $
17+
* $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.24 2004/04/19 17:42:57 momjian Exp $
1818
*/
1919

2020

@@ -33,9 +33,7 @@
3333

3434
#ifdefFRONTEND
3535
#include"postgres_fe.h"
36-
#ifndefWIN32
3736
#include"libpq/crypt.h"
38-
#endif/* WIN32 */
3937
#endif/* FRONTEND */
4038

4139
#ifdefMD5_ODBC

‎src/backend/main/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.76 2004/03/15 16:14:26 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.77 2004/04/19 17:42:57 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -50,7 +50,9 @@ int
5050
main(intargc,char*argv[])
5151
{
5252
intlen;
53+
#ifndefWIN32
5354
structpasswd*pw;
55+
#endif
5456
char*pw_name_persist;
5557

5658
/*

‎src/backend/port/sysv_shmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.32 2004/02/25 19:41:22 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.33 2004/04/19 17:42:58 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -259,7 +259,7 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
259259
PGSharedMemoryDetach();
260260
UsedShmemSegAddr=origUsedShmemSegAddr;
261261
#endif
262-
elog(DEBUG3,"Attaching to %x",UsedShmemSegAddr);
262+
elog(DEBUG3,"Attaching to %p",UsedShmemSegAddr);
263263
hdr=PGSharedMemoryAttach((IpcMemoryKey)UsedShmemSegID,&shmid);
264264
if (hdr==NULL)
265265
elog(FATAL,"could not attach to proper memory at fixed address: shmget(key=%d, addr=%p) failed: %m",

‎src/backend/port/win32/shmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.4 2004/02/12 20:37:34 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.5 2004/04/19 17:42:58 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -22,7 +22,7 @@ static DWORD s_segsize = 0;
2222
int
2323
shmdt(constvoid*shmaddr)
2424
{
25-
if (UnmapViewOfFile(shmaddr))
25+
if (UnmapViewOfFile((LPCVOID*)shmaddr))
2626
return0;
2727
else
2828
return-1;

‎src/backend/port/win32/timer.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/port/win32/timer.c,v 1.1 2004/02/18 16:25:12 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/port/win32/timer.c,v 1.2 2004/04/19 17:42:58 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -43,9 +43,9 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
4343
timerHandle=CreateWaitableTimer(NULL, TRUE,NULL);
4444
if (timerHandle==NULL)
4545
ereport(FATAL,
46-
(errmsg_internal("failed to create waitable timer: %i",GetLastError())));
46+
(errmsg_internal("failed to create waitable timer: %i",(int)GetLastError())));
4747
}
48-
48+
4949
if (value->it_value.tv_sec==0&&
5050
value->it_value.tv_usec==0) {
5151
/* Turn timer off */
@@ -55,11 +55,11 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
5555

5656
/* Negative time to SetWaitableTimer means relative time */
5757
dueTime.QuadPart=-(value->it_value.tv_usec*10+value->it_value.tv_sec*10000000L);
58-
58+
5959
/* Turn timer on, or change timer */
60-
if (!SetWaitableTimer(timerHandle,&dueTime,0,timer_completion,NULL, FALSE))
60+
if (!SetWaitableTimer(timerHandle,&dueTime,0,timer_completion,NULL, FALSE))
6161
ereport(FATAL,
62-
(errmsg_internal("failed to set waitable timer: %i",GetLastError())));
62+
(errmsg_internal("failed to set waitable timer: %i",(int)GetLastError())));
6363

6464
return0;
6565
}

‎src/backend/postmaster/pgstat.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2003, PostgreSQL Global Development Group
1515
*
16-
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.66 2004/04/12 16:19:18 momjian Exp $
16+
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.67 2004/04/19 17:42:58 momjian Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -1730,13 +1730,6 @@ pgstat_mainChild(PGSTAT_FORK_ARGS)
17301730
{
17311731
if (errno==EINTR)
17321732
continue;
1733-
#ifdefWIN32
1734-
if (WSAGetLastError()==WSAECONNRESET)/* EOF on the pipe! (win32 socket based implementation) */
1735-
{
1736-
pipeEOF= true;
1737-
break;
1738-
}
1739-
#endif
17401733
ereport(LOG,
17411734
(errcode_for_socket_access(),
17421735
errmsg("could not read from statistics collector pipe: %m")));

‎src/backend/postmaster/postmaster.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.380 2004/04/12 16:19:18 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.381 2004/04/19 17:42:58 momjian Exp $
4141
*
4242
* NOTES
4343
*
@@ -314,8 +314,6 @@ static unsigned long tmpBackendFileNum = 0;
314314
voidread_backend_variables(unsigned longid,Port*port);
315315
staticboolwrite_backend_variables(Port*port);
316316

317-
size_tShmemBackendArraySize(void);
318-
voidShmemBackendArrayAllocation(void);
319317
staticvoidShmemBackendArrayAdd(Backend*bn);
320318
staticvoidShmemBackendArrayRemove(pid_tpid);
321319
#endif
@@ -2561,7 +2559,7 @@ BackendRun(Port *port)
25612559
* PGOPTIONS, but it is not honored until after authentication.)
25622560
*/
25632561
if (PreAuthDelay>0)
2564-
sleep(PreAuthDelay);
2562+
pg_usleep(PreAuthDelay*1000000L);
25652563

25662564
/* Will exit on failure */
25672565
BackendInit(port);
@@ -3455,8 +3453,8 @@ static void ShmemBackendArrayAdd(Backend *bn)
34553453
}
34563454
}
34573455

3458-
/* FIXME: [fork/exec] some sort of error */
3459-
abort();
3456+
ereport(FATAL,
3457+
(errmsg_internal("unable to add backend entry")));
34603458
}
34613459

34623460
staticvoidShmemBackendArrayRemove(pid_tpid)
@@ -3472,7 +3470,6 @@ static void ShmemBackendArrayRemove(pid_t pid)
34723470
}
34733471
}
34743472

3475-
/* Something stronger than WARNING here? */
34763473
ereport(WARNING,
34773474
(errmsg_internal("unable to find backend entry with pid %d",
34783475
pid)));
@@ -3565,8 +3562,9 @@ static void win32_AddChild(pid_t pid, HANDLE handle)
35653562
++win32_numChildren;
35663563
}
35673564
else
3568-
/* FIXME: [fork/exec] some sort of error */
3569-
abort();
3565+
ereport(FATAL,
3566+
(errmsg_internal("unable to add child entry with pid %lu",
3567+
pid)));
35703568
}
35713569

35723570
staticvoidwin32_RemoveChild(pid_tpid)
@@ -3588,7 +3586,6 @@ static void win32_RemoveChild(pid_t pid)
35883586
}
35893587
}
35903588

3591-
/* Something stronger than WARNING here? */
35923589
ereport(WARNING,
35933590
(errmsg_internal("unable to find child entry with pid %lu",
35943591
pid)));

‎src/backend/storage/smgr/md.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.103 2004/02/11 22:55:25 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.104 2004/04/19 17:42:58 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -607,7 +607,7 @@ mdsync(void)
607607
{
608608
sync();
609609
if (IsUnderPostmaster)
610-
sleep(2);
610+
pg_usleep(2000000L);
611611
sync();
612612
return true;
613613
}

‎src/backend/tcop/postgres.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.399 2004/04/11 00:54:44 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.400 2004/04/19 17:42:58 momjian Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -2456,7 +2456,7 @@ PostgresMain(int argc, char *argv[], const char *username)
24562456
/*
24572457
* wait N seconds to allow attach from a debugger
24582458
*/
2459-
sleep(atoi(optarg));
2459+
pg_usleep(atoi(optarg)*1000000L);
24602460
break;
24612461

24622462
case'x':

‎src/backend/utils/error/assert.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.25 2003/11/29 19:52:01 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.26 2004/04/19 17:42:58 momjian Exp $
1212
*
1313
* NOTE
1414
* This should eventually work with elog()
@@ -40,7 +40,11 @@ ExceptionalCondition(char *conditionName,
4040
}
4141

4242
#ifdefSLEEP_ON_ASSERT
43-
sleep(1000000);
43+
/*
44+
*It would be nice to use pg_usleep() here, but only does 2000 sec
45+
*or 33 minutes, which seems too short.
46+
*/
47+
sleep(1000000);
4448
#endif
4549

4650
abort();

‎src/backend/utils/hash/dynahash.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.50 2003/12/29 23:54:22 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.51 2004/04/19 17:42:58 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -85,6 +85,7 @@ DynaHashAlloc(Size size)
8585
}
8686

8787
#defineMEM_ALLOCDynaHashAlloc
88+
#undef MEM_FREE/* already in windows header files */
8889
#defineMEM_FREEpfree
8990

9091

‎src/backend/utils/init/miscinit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.123 2004/02/10 01:55:26 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.124 2004/04/19 17:42:58 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -213,11 +213,11 @@ SetDataDir(const char *dir)
213213
* generating funny-looking paths to individual files.
214214
*/
215215
newlen=strlen(new);
216-
if (newlen>1&&new[newlen-1]=='/'
216+
if (newlen>1&&(new[newlen-1]=='/'
217217
#ifdefWIN32
218218
||new[newlen-1]=='\\'
219219
#endif
220-
)
220+
))
221221
new[newlen-1]='\0';
222222

223223
if (DataDir)

‎src/bin/psql/common.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.34 2004/01/25 03:07:22 neilc Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.35 2004/04/19 17:42:58 momjian Exp $
77
*/
88
#ifndefCOMMON_H
99
#defineCOMMON_H
@@ -60,12 +60,6 @@ extern const char *session_username(void);
6060
*/
6161
externcharparse_char(char**buf);
6262

63-
/* Used for all Win32 popen/pclose calls */
64-
#ifdefWIN32
65-
#definepopen(x,y) _popen(x,y)
66-
#definepclose(x) _pclose(x)
67-
#endif
68-
6963
externchar*expand_tilde(char**filename);
7064

7165
#endif/* COMMON_H */

‎src/bin/psql/copy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.44 2004/04/19 17:22:31 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.45 2004/04/19 17:42:58 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"copy.h"
@@ -26,7 +26,7 @@
2626
#include"prompt.h"
2727
#include"stringutils.h"
2828

29-
#ifdefWIN32
29+
#if defined(WIN32)&& (!defined(__MINGW32__))
3030
#definestrcasecmp(x,y) stricmp(x,y)
3131
#define__S_ISTYPE(mode,mask)(((mode) & S_IFMT) == (mask))
3232
#defineS_ISDIR(mode) __S_ISTYPE((mode), S_IFDIR)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp